I am using Rspec 3 and I am trying to write a test that is testing values in the db populated by my rake db:seed task
So far I have come up with
describe "Component Data" do
it 'Should have its values in the db' do
expect(Component.where(component_name: 'Literacy')).to eq(id: 1)
end
end
Now this is throwing an error
Failure/Error: expect(Component.where(component_name: 'Literacy')).to eq(id: 1)
expected: {:id=>1}
got: #<ActiveRecord::Relation [#<Component id: 1, component_name: "Literacy", created_at: "2014-12-17 16:33:57", updated_at: "2014-12-17 16:33:57">]>
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-:id => 1,
+[#<Component id: 1, component_name: "Literacy", created_at: "2014-12-17 16:33:57", updated_at: "2014-12-17 16:33:57">]
So i am probably looking at this in the wrong way, what I want to check for is that the Component Id of 1 actually has the component_name value of 'Literacy'
If anyone could point me in the right direction i would be grateful
Thanks
You can do as :