[rspec-users] RSPEC and RoR undefined method for hash when running model tests

Tom Stuart tom at experthuman.com
Mon Dec 14 16:39:22 EST 2009


On 14 Dec 2009, at 21:28, Matt Riches wrote:
> describe Address do
>   #Test Fixture - Before Each test Create a Standard Bread with the following attributes and properties
>   before(:each) do
>     @address = {
>       :business_name => 'business', :first_line => '10, This Street', :second_line=> 'erewhon', :town=> 'town', :county=>'county',
>       :postcode =>'AB12 3CD', :user_id => 1, :lat=>1.01, :lng=>2.02, :status=>Address::JUST_REGISTERED, :route_id=>1
>     }
>   end
> 
>   it "should have a status of deleted after reset" do
>     @address.reset
>     @address.status.should == :Address::DELETED
>   end
> end

The problem is that you're setting @address to a hash, not an instance of Address. Did you mean @address = Address.new :business_name => ...?

Cheers,
-Tom


More information about the rspec-users mailing list