I am new Rspec and just started by generating a new controller on Rails 3. It generates some Rspec tests by default. I have a question about how to make them pass though. As it stands, I see this test in my terminal"> 1) BuildingsController GET ''show'' > should be successful> Failure/Error: get ''show'' > No route matches {:controller=>"buildings", :action=>"show"} > # ./spec/controllers/buildings_controller_spec.rb:17:in `block (3 levels) in <top (required)>''However, I don''t understand why it''s coming up because I already have this route created ("resources :buildings"), and I ran `rake routes` and made sure it''s there.> building GET /buildings/:id(.:format) {:action=>"show", :controller=>"buildings"}What is necessary to make this pass? Here is the test by the way: describe "GET ''show''" do it "should be successful" do get ''show'' response.should be_success end end
You need to pass :id param as well to get the route recognized: describe "GET ''show''" do it "should be successful" do get ''show'', :id => ''55'' response.should be_success end end On 1/7/2011 8:34 PM, Volkan Unsal wrote:> I am new Rspec and just started by generating a new controller on > Rails 3. It generates some Rspec tests by default. I have a question > about how to make them pass though. As it stands, I see this test in > my terminal" > >> 1) BuildingsController GET ''show'' >> should be successful >> Failure/Error: get ''show'' >> No route matches {:controller=>"buildings", :action=>"show"} >> # ./spec/controllers/buildings_controller_spec.rb:17:in `block (3 levels) in<top (required)>'' > However, I don''t understand why it''s coming up because I already have > this route created ("resources :buildings"), and I ran `rake routes` > and made sure it''s there. > >> building GET /buildings/:id(.:format) {:action=>"show", :controller=>"buildings"} > > What is necessary to make this pass? Here is the test by the way: > > describe "GET ''show''" do > it "should be successful" do > get ''show'' > response.should be_success > end > end > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
On Jan 7, 2011, at 11:34 AM, Volkan Unsal <spocksplanet at gmail.com> wrote:> I am new Rspec and just started by generating a new controller on > Rails 3. It generates some Rspec tests by default. I have a question > about how to make them pass though. As it stands, I see this test in > my terminal" > >> 1) BuildingsController GET ''show'' >> should be successful > >> Failure/Error: get ''show'' >> No route matches {:controller=>"buildings", :action=>"show"} >> # ./spec/controllers/buildings_controller_spec.rb:17:in `block (3 levels) in <top (required)>'' > > However, I don''t understand why it''s coming up because I already have > this route created ("resources :buildings"), and I ran `rake routes` > and made sure it''s there. > >> building GET /buildings/:id(.:format) {:action=>"show", :controller=>"buildings"} > > > What is necessary to make this pass? Here is the test by the way: > > describe "GET ''show''" do > it "should be successful" do > get ''show''building = Building.create! get ''show'', :id => building.id> response.should be_successHTH, David> end > end > >