Testing - how to get access to an instance variable

inside controller

def foo
@city = City.find(@params[:id])
@city.bar = 1234
end

While writing functional tests how do I ensure that the @city.bar is
1234?

def test_edit
get :edit, :id => 1
assert_not_nil assigns(:city)
#?? how to assert that city.bar is 1234
end

Thanks

Neeraj K. wrote:

While writing functional tests how do I ensure that the @city.bar is
1234?

def test_edit
get :edit, :id => 1
assert_not_nil assigns(:city)
assert_equal 1234, assigns(‘city’).bar
end

And in general http://manuals.rubyonrails.com/read/chapter/28 is very
helpful :slight_smile:

Cheers,
Łukasz Piestrzeniewicz

thanks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs