Hi guys,
I tried reading up the RSPEC Book (Dec 2010) and googled a bit but I
could not find anything.
I’m using Rspec2.
Example:
spec/factories/categories.rb
FactoryGirl.define do
factory :category_intakes, :class => ‘category’ do
name ‘intakes and filters’
description ‘airfilters and etc.’
created_by 1
updated_by 1
end
factory :category_audio, :class => ‘category’ do
name ‘audio’
description ‘in car entertainment’
created_by 1
updated_by 1
end
end
spec/views/categories/index.html.erb
require ‘spec_helper’
describe “categories/index.html.erb” do
before(:each) do
assign( :categories, [
FactoryGirl.create(:category_intakes),
FactoryGirl.create(:category_audio),
]
)
end
it “renders a list of categories” do
render
assert_select “tr>td”, :text => “intakes and filters”.to_s, :count
=> 1
assert_select “tr>td”, :text => “audio”.to_s, :count => 1
end
end
I noticed that the index view spec above passes but when I change the
count to 2, it fails saying that only 1 element is expected.
Question:
- what does :count actually mean? Does it mean the total number of
fixture objects expected? - does the ordering of the rendered fixture items matter
( ie. :category_audio is expected before :category_intakes)?