I am currently attempt to learn Ruby on Rails, and the testing framework RSpec. What does assigns
do in this RSpec test?
describe "GET index" do
it "assigns all mymodel as @mymodel" do
mymodel = Factory(:mymodel)
get :index
assigns(:mymodels).should eq([mymodel])
end
end
assigns
simply checks the value of the instance variables you set in your controller.
Here it checks @mymodels
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With