[Rspec-devel] What is a context?

Jay Levitt lists-rspec at shopwatch.org
Sun Jul 16 12:25:56 EDT 2006

David Chelimsky wrote:

> Some people on the list have requested nested contexts and we've been
> resistant because we want to encourage clarity in specs. However,
> perhaps events could be the intermediate structure that we're looking
> for.

Hmm.. actually, looking at your controller example:

> context "a new session" do
> setup do
> ...
> end
> request :controller => :stories, :action => :new do
> ...
> end
> specify "should redirect to login action" do
> ...
> end
> specify "should render login page" do
> ...
> end
> end

it makes me wonder if the simplest solution isn't just "in a controller 
spec, don't roll back between specifications".  Each context would still 
roll back, but within a context, you'd be able to keep pushing forward.

In fact, I could see that as a generally useful tool, so it could be an 
option to context

context "a new session", :rollback => false do
  the other that depends on this

It might be useful in certain models, but the default would be "true" 
for models and "false" for controllers (taken care of by the generator 

Does that cause new problems?  It seems easier than events, and solves 
many of the problems.


More information about the Rspec-devel mailing list