I'm trying to test the order of a factory. (1) I need help on writing a test that tests if the factory ordering is correct. So I assume I would have to create the factory and then alter the results and then sort them.
Also, (2) I would like to know if there is a DRYer way to creating multiple items in the Factories.
spec/models/item_spec.rb
require 'rails_helper'
RSpec.describe Item, :type => :model do
let(:item) { FactoryGirl.create(:item) }
let(:item2) { FactoryGirl.create(:item) }
let(:item3) { FactoryGirl.create(:item) }
it "should sort the items in order" do
# tests order
end
end
spec/factories/items.rb
FactoryGirl.define do
factory :item, :class => 'Item' do
name { Forgery::Name.name }
sequence(:ordering)
end
end