Neeraj Kumar
2006-Jun-27  15:53 UTC
[Rails] 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060627/d4861773/attachment.html
Ćukasz Piestrzeniewicz
2006-Jun-27  17:04 UTC
[Rails] Re: testing - how to get access to an instance variable
Neeraj Kumar 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> endAnd in general http://manuals.rubyonrails.com/read/chapter/28 is very helpful :) Cheers, ?ukasz Piestrzeniewicz -- Posted via http://www.ruby-forum.com/.
Neeraj Kumar
2006-Jun-27  18:15 UTC
[Rails] Re: testing - how to get access to an instance variable
thanks On 6/27/06, ?ukasz Piestrzeniewicz <bragi.ragnarson+rf@gmail.com> wrote:> > Neeraj Kumar 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 :) > > Cheers, > ?ukasz Piestrzeniewicz > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060627/31f096fb/attachment.html