/
make_spec.rb
52 lines (41 loc) · 1.08 KB
/
make_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require 'spec_helper'
require 'factory_girl/syntax/make'
describe "a factory using make syntax" do
before do
define_model('User', :first_name => :string, :last_name => :string)
FactoryGirl.define do
factory :user do
first_name 'Bill'
last_name 'Nye'
end
end
end
describe "after make" do
before do
@instance = User.make(:last_name => 'Rye')
end
it "should use attributes from the factory" do
@instance.first_name.should == 'Bill'
end
it "should use attributes passed to make" do
@instance.last_name.should == 'Rye'
end
it "should build the record" do
@instance.should be_new_record
end
end
describe "after make!" do
before do
@instance = User.make!(:last_name => 'Rye')
end
it "should use attributes from the factory" do
@instance.first_name.should == 'Bill'
end
it "should use attributes passed to make" do
@instance.last_name.should == 'Rye'
end
it "should save the record" do
@instance.should_not be_new_record
end
end
end