[rspec-devel] [ rspec-Bugs-8145 ] fixture use in context_setup bails

noreply at rubyforge.org noreply at rubyforge.org
Wed May 30 12:45:08 EDT 2007


Bugs item #8145, was opened at 2007-01-25 15:35
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=8145&group_id=797

Category: rails plugin
Group: None
>Status: Closed
>Resolution: Out of Date
Priority: 3
Submitted By: Jodi Showers (jodishowers)
Assigned to: David Chelimsky (dchelimsky)
Summary: fixture use in context_setup bails

Initial Comment:
It appears that fixtures are not permissible within a context_setup.

context "Given a Project fixture, " do
  fixtures :projects

  context_setup do
    @project = projects(:project_one)
  end

....

end

Results:

1)
NoMethodError in 'Given a Project fixture,  context_setup'
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
./spec/models/project_spec.rb:56:



----------------------------------------------------------------------

>Comment By: David Chelimsky (dchelimsky)
Date: 2007-05-30 16:45

Message:
I'm going to close this because it's out of date (syntax has changed) and a duplicate has been raised using the new syntax.

http://rubyforge.org/tracker/index.php?func=detail&aid=11231&group_id=797&atid=3149

I'll refer back to this discussion in that report.

----------------------------------------------------------------------

Comment By: Jodi Showers (jodishowers)
Date: 2007-03-10 16:45

Message:
yes. Given your explanation I agree that documentation would
help.

But first, I'd like to propose that if context_setup could
reference fixtures, and a transaction wrapped the entire
context, then a all specifies could share global 'context'.

My experience (not a lot mind you) so far with rspec, tells
me that a number of my specs would be less repetitive and
easier to group under contexts if I could have some fixtures
rollback (setup), and some persist across the entire context.

init_context #internal requirements for a context
Context.transaction do

  context_setup {}
  context "..." do
  setup {}
  specify do
    ...
  end
  end

end

+ since contexts currently don't give access to fixtures,
then this change wouldn't impact any current specs(?). But
perhaps it would break the design goals?

WDYT?

thanx for your inclusiveness David.
Jodi

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2007-03-10 15:13

Message:
context_setup is a bit confusing because it looks like it lives inside the context, but in reality it is processed BEFORE the context is processed. Just as setup is processed before each specify block. So what's really happening is:

context_setup {}
context "..." do
  setup {}
  specify do
    ...
  end
end

So I think that the problem here is one of documentation/perception.

WDYT?

David

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=8145&group_id=797


More information about the rspec-devel mailing list