Search code examples
ruby-on-railsrspec2fixturesrspec-rails

All fixtures in rails


I guess I am missing something very very obvious, but in my RSpec tests I want to do something like this:

it "should assign all channels to @channels" do                                                                                                                                                                      
  get :index                                                                                                                                                                                         
  assigns(:channels).should eq(channels(:all))                                                                                                                                                       
end

As you can see I want all channels in an array for my tests so I don't have to fix all my tests when I add a new fixture in the future.

channels(:all) is not working and channels.kind_of? Array is true and empty by default.

Any suggestions?


Solution

  • What you might need is:

    assigns(:channels).should eq(Channel.all)