-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix using passed values in callable attributes
It turned out it's not always possible to use the passed value in a block. Passing values requires more attention, there are opened issues about it, but it's a nice improvement anyway
- Loading branch information
1 parent
1ff1ce6
commit dcc652a
Showing
2 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -490,6 +490,43 @@ | |
|
||
expect(user.email).to eql("#{user.first_name}.#{user.last_name}@test-1.org") | ||
end | ||
|
||
it "can use passed values in the block" do | ||
factories.define(:user, relation: :users) do |f| | ||
f.last_name { fake(:name) } | ||
f.email { |first_name, last_name| "#{first_name}.#{last_name}@example.com" } | ||
f.timestamps | ||
end | ||
|
||
user = factories[:user, first_name: "Jane"] | ||
|
||
expect(user.email).to eql("Jane.#{user.last_name}@example.com") | ||
end | ||
|
||
it "can use passed values in the block" do | ||
factories.define(:user, relation: :users) do |f| | ||
f.first_name nil | ||
f.last_name { fake(:name) } | ||
f.email { |first_name| "#{first_name}@example.com" } | ||
f.timestamps | ||
end | ||
|
||
user = factories[:user, first_name: "Jane"] | ||
|
||
expect(user.email).to eql("[email protected]") | ||
end | ||
|
||
it "can use passed values in the block" do | ||
factories.define(:user, relation: :users) do |f| | ||
f.last_name { fake(:name) } | ||
f.email { |first_name| "#{first_name}@example.com" } | ||
f.timestamps | ||
end | ||
|
||
user = factories[:user, first_name: "Jane"] | ||
|
||
expect(user.email).to eql("[email protected]") | ||
end | ||
end | ||
|
||
context "changing values of dependant attributes" do | ||
|