received unexpected message :split [ an error in an rspec controller test ]

original code:

1
2
3
4
5
6
7
it 'should add a flight given the correct data' do
  details = Factory.build(:flight).attributes
  @mock_flight.should_receive(:save).and_return(true)  
  Flight.should_receive(:new).with(details).and_return(@mock_flight)
  post 'create', :flight => details
  response.should redirect_to( @mock_flight
end

correction:
1
2
-    response.should redirect_to( @mock_flight )
+   response.should redirect_to( flight_url(@mock_flight) )

notes:
-  @mock_flight is defined in a before(:all) block.
-  flight_url is generated by the following line in config/routes.rb:
        map.resources :flights

Post a comment


(lesstile enabled - surround code blocks with ---)