[rspec-users] how can this pass?

Sergio Bayona lists at ruby-forum.com
Sun Feb 8 20:35:19 EST 2009


how could this test pass?

I have:

class PropertiesController < ApplicationController
  def show
    @property = Property.non_existing_method #causes a method missing
error
  end
end


describe PropertiesController do
  def mock_property(stubs={})
      @mock_property ||= mock_model(Property, stubs)
  end

  describe "responding to GET show" do
    it "should expose the requested property as @property" do
        Property.should_receive(:non_existing_method).and_return(mock_property)
        get :show, :id => "37"
        assigns[:property].should equal(mock_property)
    end
  end
end

SB-MacBook-Pro:test sb$ ruby
./spec/controllers/properties_controller_spec.rb
.

Finished in 0.134667 seconds

1 example, 0 failures


why zero failures? more specifically, why would :non_existing_method
return mock_property? and why would the assigns[:property] be equal to
mock_property? did I eat some bad mushrooms?

Sergio
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list