Not sure if this is a Rails 3 issue or an RSpec 2 issue, but I can't seem to get a standard controller test working - it seems that the 'get' method can't be found.I have a controller test that looks like this (named "discrepancies_controller_spec.rb" in spec/controllers directory):require 'spec_helper'describe DiscrepanciesController dobefore :each doDiscrepancy.delete_allendit "resolves a discrepancy" dodiscrepancy = Discrepancy.create(:my_number=>"12345", :status=>"Open")
get :resolve, :id => discrepancy.idretrieved_discrepancy = Discrepancy.find_by_my_number("12345")retrieved_discrepancy.status.should == "Resolved"endend(Yes, I'm aware of the security implications of modifying data with an HTTP/GET - that's a separate issue...)When I run it with rake, I get the following error:1) DiscrepanciesController resolves a discrepancyFailure/Error: Unable to find C to read failed lineundefined method `get' for #<RSpec::Core::ExampleGroup::Nested_1:0xc9170d0 @__memoized={}># ./spec/controllers/discrepancies_controller_spec.rb:38 (ignore the line number, commented out code was removed from the sample)# C:/Users/Patrick_Gannon/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/dependencies.rb:212:in `inject'# C:/Ruby187/bin/rake:19:in `load'# C:/Ruby187/bin/rake:19
_______________________________________________
rspec-users mailing list
rspec...@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
On Jun 25, 9:21 pm, David Chelimsky <dchelim...@gmail.com> wrote:
> On Jun 25, 2010, at 5:02 PM, Patrick Gannon wrote:
>
>
>
>
>
> > Not sure if this is a Rails 3 issue or an RSpec 2 issue, but I can't seem to get a standard controller test working - it seems that the 'get' method can't be found.
>
> > I have a controller test that looks like this (named "discrepancies_controller_spec.rb" in spec/controllers directory):
>
> > require 'spec_helper'
>
> > describe DiscrepanciesController do
> > before :each do
> > Discrepancy.delete_all
> > end
>
> > it "resolves a discrepancy" do
> > discrepancy = Discrepancy.create(:my_number=>"12345", :status=>"Open")
>
> > get :resolve, :id => discrepancy.id
>
> > retrieved_discrepancy = Discrepancy.find_by_my_number("12345")
> > retrieved_discrepancy.status.should == "Resolved"
> > end
> > end
>
> > (Yes, I'm aware of the security implications of modifying data with an HTTP/GET - that's a separate issue...)
> > When I run it with rake, I get the following error:
>
> > 1) DiscrepanciesController resolves a discrepancy
> > Failure/Error: Unable to find C to read failed line
> > undefined method `get' for #<RSpec::Core::ExampleGroup::Nested_1:0xc9170d0 @__memoized={}>
> > # ./spec/controllers/discrepancies_controller_spec.rb:38 (ignore the line number, commented out code was removed from the sample)
> > # C:/Users/Patrick_Gannon/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649f fac24fd5873b875daf66212ad-master/activesupport/lib/active_support/dependenc ies.rb:212:in `inject'
> > # C:/Ruby187/bin/rake:19:in `load'
> > # C:/Ruby187/bin/rake:19
>
> I'm surprised this is the first time this has come up with rspec-2, but here we are :)
>
> This is a path-separator bug that I'll resolve in the next release. For now, you can do this in your controller specs:
>
> describe DiscrepanciesController do
> include RSpec::Rails::ControllerExampleGroup
>
> That should work fine.
>
> If you want to do a more global workaround, add this to your spec_helper config:
>
> RSpec.configure do |c|
> c.include RSpec::Rails::ControllerExampleGroup, :example_group => { :file_path => /\bspec[\\\/]controllers[\\\/]/ }
> end
>
> HTH,
> David
FYI: http://github.com/rspec/rspec-rails/issues/99
> > rspec-us...@rubyforge.org
> >http://rubyforge.org/mailman/listinfo/rspec-users
>
> _______________________________________________
> rspec-users mailing list
> rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
Just add config.include RSpec::Rails::ControllerExampleGroup in
spec_helper.rb
--
Posted via http://www.ruby-forum.com/.