2010-11-12 15:58:25 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
require 'acceptance/acceptance_helper'
|
|
|
|
|
|
|
|
describe "sequences" do
|
2011-05-19 10:56:45 -04:00
|
|
|
include FactoryGirl::Syntax::Methods
|
|
|
|
|
2010-11-12 15:58:25 -05:00
|
|
|
it "generates several values in the correct format" do
|
|
|
|
FactoryGirl.define do
|
|
|
|
sequence :email do |n|
|
|
|
|
"somebody#{n}@example.com"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-05-19 10:56:45 -04:00
|
|
|
first_value = generate(:email)
|
|
|
|
another_value = generate(:email)
|
2010-11-12 15:58:25 -05:00
|
|
|
|
|
|
|
first_value.should =~ /^somebody\d+@example\.com$/
|
|
|
|
another_value.should =~ /^somebody\d+@example\.com$/
|
|
|
|
first_value.should_not == another_value
|
|
|
|
end
|
2011-01-25 17:55:40 -05:00
|
|
|
|
2011-01-27 16:25:31 -05:00
|
|
|
it "generates sequential numbers if no block is given" do
|
|
|
|
FactoryGirl.define do
|
|
|
|
sequence :order
|
|
|
|
end
|
|
|
|
|
2011-05-19 10:56:45 -04:00
|
|
|
first_value = generate(:order)
|
|
|
|
another_value = generate(:order)
|
2010-11-12 15:58:25 -05:00
|
|
|
|
2011-01-27 16:25:31 -05:00
|
|
|
first_value.should == 1
|
|
|
|
another_value.should == 2
|
|
|
|
first_value.should_not == another_value
|
|
|
|
end
|
|
|
|
end
|