1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/spec/acceptance/syntax/blueprint_spec.rb
2012-04-23 16:46:42 -05:00

36 lines
940 B
Ruby

require 'spec_helper'
require 'factory_girl/syntax/blueprint'
describe "a blueprint" do
before do
ActiveSupport::Deprecation.silenced = true
define_model('User', first_name: :string, last_name: :string, email: :string)
FactoryGirl.define do
sequence(:email) { |n| "somebody#{n}@example.com" }
end
User.blueprint do
first_name { 'Bill' }
last_name { 'Nye' }
email { FactoryGirl.generate(:email) }
end
end
describe "after making an instance" do
before do
@instance = FactoryGirl.create(:user, last_name: 'Rye')
end
it "uses attributes from the blueprint" do
@instance.first_name.should == 'Bill'
end
it "evaluates attribute blocks for each instance" do
@instance.email.should =~ /somebody\d+@example.com/
FactoryGirl.create(:user).email.should_not == @instance.email
end
end
end