[rspec-devel] [ rspec-Bugs-6730 ] Unable to use fixtures in context

noreply at rubyforge.org noreply at rubyforge.org
Mon Nov 20 09:02:10 EST 2006


Bugs item #6730, was opened at 2006-11-17 10:37
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6730&group_id=797

Category: rails plugin
Group: None
Status: Closed
Resolution: None
Priority: 3
Submitted By: Yossef Mendelssohn (ymendel)
Assigned to: David Chelimsky (dchelimsky)
Summary: Unable to use fixtures in context

Initial Comment:
context "My Problem" do
  fixtures :my_problem
end

[ymendel]$ spec problem.rb
/usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.2/lib/spec/expectations/sugar.rb:13:in `call': undefined method `fixtures' for #<Spec::Runner::ContextEvalModule:0xb7f0aae0> (NoMethodError)
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.2/lib/spec/expectations/sugar.rb:13:in `_method_missing'
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.2/lib/spec/expectations/sugar.rb:9:in `method_missing'
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.2/lib/spec/runner/context_eval.rb:37:in `method_missing'
        from ./problem.rb:2
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.2/lib/spec/runner/context.rb:14:in `initialize'
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.2/lib/spec/runner/extensions/kernel.rb:3:in `context'
        from ./problem.rb:1
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.2/lib/spec/runner/command_line.rb:21:in `run'
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.2/lib/spec/runner/command_line.rb:15:in `run'
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.2/bin/spec:4
        from /usr/local/bin/spec:18




I've seen a similar problem in bug 6411 (http://rubyforge.org/tracker/index.php?func=detail&aid=6411&group_id=797&atid=3149).  The resolution there says it was fixed in r1088, and I'm using r1095

'gem list' returns
rspec (0.7.2, 0.7.0)
    RSpec-0.7.2 (r1095) - BDD for Ruby http://rspec.rubyforge.org/

'spec -v' returns
RSpec-0.7.2 (r1095) - BDD for Ruby
http://rspec.rubyforge.org/


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

>Comment By: Yossef Mendelssohn (ymendel)
Date: 2006-11-20 08:02

Message:
Ah, so it's not determining the context.  However, my
problem still exists if I try a spec in the models
directory.  Could it be that I'm using Engines and not plain
vanilla Rails?  I have my own spec_helper.rb that includes
the line

self.fixture_path = RAILS_ROOT +
'/vendor/plugins/base/spec/fixtures'

(instead of RAILS_ROOT + '/spec/fixtures')

but maybe I need something to also point out the different
path for the specs?

Also, the paths listed on that page are a little confusing.
 Given that I'm in a 'spec' directory, the path should match
'../spec/models/**/*_spec.rb', yes?  If that's the case, the
problem spec matches.  irb confirms that.  If there's
something more, then I don't know.

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

Comment By: David Chelimsky (dchelimsky)
Date: 2006-11-17 11:48

Message:
The error points out that a Spec::Runner::ContextEvalModule is being invoked instead of a Spec::Rails::ModelContext, ::ControllerContext, ::HelperContext or ::ViewContext. The type of context is determined by the directory that the file is in. See http://rspec.rubyforge.org/documentation/rails/writing/index.html. If the path to the file is not in any of the paths listed on that page, the factory returns a Spec::Runner::ContextEvalModule by default.

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

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


More information about the rspec-devel mailing list