[rspec-devel] [ rspec-Patches-14109 ] RailsStory dies badly when no fixtures present

noreply at rubyforge.org noreply at rubyforge.org
Sun Nov 18 20:06:05 EST 2007


Patches item #14109, was opened at 2007-09-20 13:04
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3151&aid=14109&group_id=797

Category: rails plugin
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: James Hughes (jpath)
Assigned to: Nobody (None)
Summary: RailsStory dies badly when no fixtures present

Initial Comment:
A story like the following: 

Story 'Something happens', %{
 As a user
 I want to do something
 So that something will happen.
}, :type => RailsStory do

 Scenario 'User doing something for first time' do
   Given 'a user' do
     @user = User.new
   end
   When 'the user makes a request' do
     post '/some_action', :id => 1
   end
   Then 'something should happen' do
   end
 end
end

will die attempting to post when there are no fixtures present (at least, I think that's what's happening.) It dies at the following line in rails/actionpack/lib/action_controller/integration.rb:

      self.class.fixture_table_names.each do |table_name|

'self.class' at this point is RailsStory. The attached patch just initializes fixture_table_names to an empty array.

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

Comment By: Chad Humphries (spicycode)
Date: 2007-11-18 20:06

Message:
http://rspec.lighthouseapp.com/projects/5645/tickets/11-14109-railsstory-dies-badly-when-no-fixtures-present

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

Comment By: James Hughes (jpath)
Date: 2007-09-24 12:01

Message:
Ok, I've played with this a bit more, and the error seems to
just be with edge rails. Latest rails gem fails too, but
with a different error. My original patch has no effect on
this error, so, probably just a 'works for me' solution.

First, steps to reproduce:

Create a brand new rails app and freeze to edge
Do 'script/generate rspec_model user'
Put the story as it appears here in the stories folder (See
attached file)
Run 'ruby stories/test_story.rb'

This should produce the following stack trace:

FAILURES:
  1) Something happens (User doing something for first time)
FAILED
  NoMethodError: 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.each
 
/home/jhughes/dev/rspec_story_regression/vendor/rails/actionpack/lib/action_controller/integration.rb:522:in
`open_session'
/home/jhughes/dev/rspec_story_regression/vendor/rails/actionpack/lib/action_controller/integration.rb:493:in
`reset!'
/home/jhughes/dev/rspec_story_regression/vendor/rails/actionpack/lib/action_controller/integration.rb:498:in
`post'
stories/test_story.rb:17:in `the user makes a request'
/home/jhughes/dev/rspec_story_regression/vendor/plugins/rspec/lib/spec/story/simple_step.rb:13:in
`__send__'
/home/jhughes/dev/rspec_story_regression/vendor/plugins/rspec/lib/spec/story/simple_step.rb:13:in
`perform'
/home/jhughes/dev/rspec_story_regression/vendor/plugins/rspec/lib/spec/story/world.rb:58:in
`store_and_call'
/home/jhughes/dev/rspec_story_regression/vendor/plugins/rspec/lib/spec/story/world.rb:73:in
`When'
stories/test_story.rb:16
/home/jhughes/dev/rspec_story_regression/vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb:14:in
`instance_eval'
/home/jhughes/dev/rspec_story_regression/vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb:14:in
`run'
/home/jhughes/dev/rspec_story_regression/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:48:in
`run_stories'
/home/jhughes/dev/rspec_story_regression/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:43:in
`each'
/home/jhughes/dev/rspec_story_regression/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:43:in
`run_stories'
/home/jhughes/dev/rspec_story_regression/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in
`each'
/home/jhughes/dev/rspec_story_regression/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in
`run_stories'
/home/jhughes/dev/rspec_story_regression/vendor/plugins/rspec/lib/spec/story/runner.rb:38:in
`register_exit_hook'
stories/test_story.rb:6

With the latest rails gem instead of edge, I get (note,
again, this happens whether my patch is applied or not:

/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb:328:in
`send': undefined method `session=' for
ActionController::Base:Class (NoMethodError)
        from
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb:328:in
`initialize_framework_settings'
        from
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb:327:in
`each'
        from
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb:327:in
`initialize_framework_settings'
        from
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb:324:in
`each'
        from
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb:324:in
`initialize_framework_settings'
        from
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb:96:in
`process'
        from
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb:43:in
`send'
        from
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb:43:in
`run'
        from
/home/jhughes/dev/rspec_story_regression/config/environment.rb:13
        from stories/test_story.rb:2:in `require'
        from stories/test_story.rb:2


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

Comment By: David Chelimsky (dchelimsky)
Date: 2007-09-22 23:56

Message:
Please post a real example with a real stack trace. I haven't seen this problem and would like to understand it better before adding anything like this.

Cheers,
David

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

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


More information about the rspec-devel mailing list