Hi Not sure if this is the place to ask this or not. I''ve upgraded to RSpec 1.0.5, installed the latest TextMate bundle, but whenever I do "Run Behaviour Descriptions in selected files/directories" I get this: /Users/ashleymoran/Library/Application Support/TextMate/Pristine Copy/ Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:18:in `run_files'': private method `split'' called for nil:NilClass (NoMethodError) from / tmp/temp_textmate.ii9VqG:4 If I try the "Run Behaviour Description" I get this: /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'': no such file to load -- cgi (MissingSourceFile) from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/ custom_require.rb:27:in `require'' from /opt/local/lib/ruby/gems/1.8/ gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require'' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/ lib/active_support/dependencies.rb:342:in `new_constants_in'' from / opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/ active_support/dependencies.rb:495:in `require'' from /opt/local/lib/ ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/routing.rb: 1 from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb: 32:in `gem_original_require'' from /opt/local/lib/ruby/vendor_ruby/1.8/ rubygems/custom_require.rb:32:in `require'' from /opt/local/lib/ruby/ gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb: 495:in `require'' ... 34 levels... from /Users/ashleymoran/Library/ Application Support/TextMate/Pristine Copy/Bundles/RSpec.tmbundle/ Support/lib/spec_mate.rb:46:in `chdir'' from /Users/ashleymoran/ Library/Application Support/TextMate/Pristine Copy/Bundles/ RSpec.tmbundle/Support/lib/spec_mate.rb:46:in `run'' from /Users/ ashleymoran/Library/Application Support/TextMate/Pristine Copy/ Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:25:in `run_file'' from /tmp/temp_textmate.f8ruvl:4 However, doing a "Run Focused Example" works fine! I''ve seen reports of similar problems but I can''t figure out what''s going on. Can anyone help? Thanks Ashley
Sorry I was just making noise - it''s started working now. No idea why but I''m happy... Ashley On 14 Jun 2007, at 16:44, Ashley Moran wrote:> Hi > > Not sure if this is the place to ask this or not. I''ve upgraded to > RSpec 1.0.5, installed the latest TextMate bundle, but whenever I do > "Run Behaviour Descriptions in selected files/directories" I get this: > > /Users/ashleymoran/Library/Application Support/TextMate/Pristine Copy/ > Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:18:in `run_files'': > private method `split'' called for nil:NilClass (NoMethodError) from / > tmp/temp_textmate.ii9VqG:4 > > If I try the "Run Behaviour Description" I get this: > > /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require'': no such file to load -- cgi > (MissingSourceFile) from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/ > custom_require.rb:27:in `require'' from /opt/local/lib/ruby/gems/1.8/ > gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in > `require'' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/ > lib/active_support/dependencies.rb:342:in `new_constants_in'' from / > opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/ > active_support/dependencies.rb:495:in `require'' from /opt/local/lib/ > ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/routing.rb: > 1 from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb: > 32:in `gem_original_require'' from /opt/local/lib/ruby/vendor_ruby/1.8/ > rubygems/custom_require.rb:32:in `require'' from /opt/local/lib/ruby/ > gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb: > 495:in `require'' ... 34 levels... from /Users/ashleymoran/Library/ > Application Support/TextMate/Pristine Copy/Bundles/RSpec.tmbundle/ > Support/lib/spec_mate.rb:46:in `chdir'' from /Users/ashleymoran/ > Library/Application Support/TextMate/Pristine Copy/Bundles/ > RSpec.tmbundle/Support/lib/spec_mate.rb:46:in `run'' from /Users/ > ashleymoran/Library/Application Support/TextMate/Pristine Copy/ > Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:25:in `run_file'' > from /tmp/temp_textmate.f8ruvl:4 > > However, doing a "Run Focused Example" works fine! > > I''ve seen reports of similar problems but I can''t figure out what''s > going on. Can anyone help? > > Thanks > Ashley > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
On 6/14/07, Ashley Moran <work at ashleymoran.me.uk> wrote:> > Hi > > Not sure if this is the place to ask this or not. I''ve upgraded to > RSpec 1.0.5, installed the latest TextMate bundle, but whenever I do > "Run Behaviour Descriptions in selected files/directories" I get this: > > /Users/ashleymoran/Library/Application Support/TextMate/Pristine Copy/ > Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:18:in `run_files'': > private method `split'' called for nil:NilClass (NoMethodError) from / > tmp/temp_textmate.ii9VqG:4I haven''t had time to debug yet, but wanted to throw out that I''m seeing this same behavior when running some files consistently, but only appears on other files intermittently. -- Josh Knowles joshknowles at gmail.com http://joshknowles.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070614/63ac57be/attachment.html
Great it works for you! However I still get this when I run ''Run Behaviour Description'': /Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/ lib/spec_mate.rb:2:in `require'': No such file to load -- rubygems (LoadError) from /Library/Application Support/TextMate/Bundles/ RSpec.tmbundle/Support/lib/spec_mate.rb:2 from /tmp/ temp_textmate.CCT9dt:3:in `require'' from /tmp/temp_textmate.CCT9dt:3 Ingo On Jun 14, 2007, at 12:09 PM, Ashley Moran wrote:> Sorry I was just making noise - it''s started working now. No idea > why but I''m happy... > > Ashley > > > On 14 Jun 2007, at 16:44, Ashley Moran wrote: > >> Hi >> >> Not sure if this is the place to ask this or not. I''ve upgraded to >> RSpec 1.0.5, installed the latest TextMate bundle, but whenever I do >> "Run Behaviour Descriptions in selected files/directories" I get >> this: >> >> /Users/ashleymoran/Library/Application Support/TextMate/Pristine >> Copy/ >> Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:18:in `run_files'': >> private method `split'' called for nil:NilClass (NoMethodError) from / >> tmp/temp_textmate.ii9VqG:4 >> >> If I try the "Run Behaviour Description" I get this: >> >> /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in >> `gem_original_require'': no such file to load -- cgi >> (MissingSourceFile) from /opt/local/lib/ruby/vendor_ruby/1.8/ >> rubygems/ >> custom_require.rb:27:in `require'' from /opt/local/lib/ruby/gems/1.8/ >> gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in >> `require'' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/ >> lib/active_support/dependencies.rb:342:in `new_constants_in'' from / >> opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/ >> active_support/dependencies.rb:495:in `require'' from /opt/local/lib/ >> ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ >> routing.rb: >> 1 from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/ >> custom_require.rb: >> 32:in `gem_original_require'' from /opt/local/lib/ruby/vendor_ruby/ >> 1.8/ >> rubygems/custom_require.rb:32:in `require'' from /opt/local/lib/ruby/ >> gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb: >> 495:in `require'' ... 34 levels... from /Users/ashleymoran/Library/ >> Application Support/TextMate/Pristine Copy/Bundles/RSpec.tmbundle/ >> Support/lib/spec_mate.rb:46:in `chdir'' from /Users/ashleymoran/ >> Library/Application Support/TextMate/Pristine Copy/Bundles/ >> RSpec.tmbundle/Support/lib/spec_mate.rb:46:in `run'' from /Users/ >> ashleymoran/Library/Application Support/TextMate/Pristine Copy/ >> Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:25:in `run_file'' >> from /tmp/temp_textmate.f8ruvl:4 >> >> However, doing a "Run Focused Example" works fine! >> >> I''ve seen reports of similar problems but I can''t figure out what''s >> going on. Can anyone help? >> >> Thanks >> Ashley >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
Ingo Weiss
2007-Jun-14 20:43 UTC
[rspec-users] problem getting started with stubbing in rails controller specs
Hi, I am getting started with writing controller specs with rspec/rails, and seem to have trouble fully grasping the concept of mocks and stubs. I can''t figure out what''s wrong with the following. This is the action I want to spec: def index @stations = Station.find(:all, :order => ''name'') end and this is my spec: describe "GET to index" do controller_name :stations before(:each) do @mock_station = mock_model(Station) @mock_stations = [@mock_station] Station.stub!(:find).and_return(@mock_stations) get ''index'', :locale => ''en'' end it "should find stations" do Station.should_receive(:find).with(:all).and_return (@mock_stations) end end It fails with this error: Spec::Mocks::MockExpectationError in ''GET to index should find stations'' Station expected :find with (:all) once, but received it 0 times ./spec/controllers/stations_controller_spec.rb:22: I can see in the log that the database is not hit for Station.find (:all), so the stubbing seems to have worked. Guess I''m stuck. Thanks for any hint to get me going again! Ingo