-
Notifications
You must be signed in to change notification settings - Fork 1
/
builder_spec.rb
46 lines (39 loc) · 1.36 KB
/
builder_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
require "spec_helper"
describe FactoryBurgers::Builder do
let(:builder) { FactoryBurgers::Builder.new }
describe "build" do
it "builds a resource" do
user = builder.build(:user, [], {}, nil)
expect(user).to be_persisted
end
it "can use a trait" do
user = builder.build(:user, [:silly], {}, nil)
expect(user.name.last).to eq("?")
end
it "can override attributes" do
user = builder.build(:user, [], {name: "Sir Regynald J Bubblesworth"}, nil)
expect(user.name).to eq("Sir Regynald J Bubblesworth")
end
# This is currently borked
skip "specifying an owner" do
context "when the owner is a belongs_to association" do
it "sets the resource's owner" do
group = Group.create!
user = builder.build(:user, [], {name: "Sir Regynald J Bubblesworth"}, group)
end
end
context "when the owner is a has_one association" do
it "sets the resource's owner" do
profile = UserProfile.create!
user = builder.build(:user, [], {name: "Sir Regynald J Bubblesworth"}, profile)
end
end
context "when the owner is a has_many association" do
it "sets the resource's owner" do
post = create :post
user = builder.build(:user, [], {name: "Sir Regynald J Bubblesworth"}, post)
end
end
end
end
end