On Wed, 2007-11-07 at 06:39 +0100, Chris Olsen wrote:
> but when the specs are run I get errors saying that the country and
> province object properties are null
> 11)
> NoMethodError in 'Address additional properties should ensure spacing
> between the st/ave on the address'
> You have a nil object when you didn't expect it!
> The error occurred while evaluating nil.name
> /Users/chris/Documents/Projects/Rails/MyProject/trunk/config/../app/models/address.rb:25:in
> `full_address'
> ./spec/models/address_spec.rb:66:
> script/spec:4:
>
> Here is one of the tests that fail:
> describe Address, "additional properties" do
>
> before(:each) do
> @address = Address.new(valid_params)
> end
>
> def valid_params
> {
> :country_id => 1,
> :province_id => 1,
> :region_code => "T5Z3J4",
> :address_1 => "13245-56 st",
> :address_2 => "NW",
> :city => "Edmonton"
> }
> endThe question is where this country and province with id 1 are defined. I don't see anything in your spec to indicate that they are ever created. If you are using fixtures then you'll need to explicitly include them. Otherwise they may or may not still be loaded in the test database and at best you'll get a clear failure and at worst inconsistent results. describe Address do fixtures :provinces, countries before ... etc Kind regards, Hans
signature.asc
Description: This is a digitally signed message part
_______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
