On testing the Get Index I am getting an error:
Failures:
1) ContactsController GET #index with params[:letter] populates an array of contacts starting with params[:letter]
Failure/Error: expect(assigns(:contacts)).to match_array(['smith'])
**expected collection contained: ["smith"]
01:54:50">]
the missing elements were: ["smith"]
the extra elements were: [#<Contact id: 980190963, firstname: "Alexzander", lastname: "Smith", email: "rosie@weber.biz", created_at: "2016-12-18 01:54:50", updated_at: "2016-12-18 01:54:50">]
./spec/controllers/contacts_controller_spec.rb:13:in `block (4 levels) in <top (required)>'
My code is as in the book:
it 'populates an array of contacts starting with params[:letter]' do
smith = create(:contact, lastname: 'Smith')
jones = create(:contact, lastname: 'Jones')
get :index, letter:'S'
expect(assigns(:contacts)).to match_array(['smith'])
end
On testing the Get Index I am getting an error: Failures:
1) ContactsController GET #index with params[:letter] populates an array of contacts starting with params[:letter] Failure/Error: expect(assigns(:contacts)).to match_array(['smith']) **expected collection contained: ["smith"] 01:54:50">] the missing elements were: ["smith"] the extra elements were: [#<Contact id: 980190963, firstname: "Alexzander", lastname: "Smith", email: "rosie@weber.biz", created_at: "2016-12-18 01:54:50", updated_at: "2016-12-18 01:54:50">]
./spec/controllers/contacts_controller_spec.rb:13:in `block (4 levels) in <top (required)>'
My code is as in the book:
it 'populates an array of contacts starting with params[:letter]' do smith = create(:contact, lastname: 'Smith') jones = create(:contact, lastname: 'Jones') get :index, letter:'S' expect(assigns(:contacts)).to match_array(['smith']) end