On Mar 18, 2010, at 4:18 PM, drewB wrote: > I am writing some specs related to permissions for different kinds of > users. Every user has some common examples to test in many different > specs. For example, all users can view, and edit their profile. > Also, all users can view their own "history." So I have two spec > files, say profile_controller_spec and history_controller_spec. > > They might look like http://gist.github.com/336898 > > Using these files RSpec will give an error that 'User' is already > registered as a shared group, even though they are defined in separate > files and example groups.
Shared examples are not scoped to groups they are defined in. They are global. > Is it suppose to behave that way? Yes > Seems like a hassle to have to prepend the controller name to each > shared_example_for. It's not really behaving like a User so this: it_should_behave_like "User" doesn't tell me anything I need to know. It's actually behaving like a profile controller handling any user, so I'd probably write this: it_should_behave_like "the profile controller handling any user" In terms of being able to scope shared examples, I think that's a good idea and something we should consider for rspec-2. If you're interested, feel free to create an issue at http://github.com/rspec/rspec-core/issues and, even better, fork the repo and submit a patch. Cheers, David _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users