-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Verseth/feature/collections
Add support for collections
- Loading branch information
Showing
10 changed files
with
114 additions
and
5 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 |
---|---|---|
|
@@ -6,3 +6,5 @@ | |
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
.byebug_history | ||
ignore.* |
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 |
---|---|---|
|
@@ -2,4 +2,4 @@ inherit_gem: | |
rubocop-espago: rubocop.yml | ||
|
||
AllCops: | ||
TargetRubyVersion: 2.7 | ||
TargetRubyVersion: 3.0 |
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
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
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 |
---|---|---|
|
@@ -41,6 +41,10 @@ class TestEnhancedTransactionType < TestTransactionType | |
attribute :client_data, TestClientDataType | ||
end | ||
|
||
class TestMultipleClientTransactionType < TestTransactionType | ||
attribute :clients, TestClientDataType, collection: true | ||
end | ||
|
||
context 'inheritance' do | ||
should 'correctly set up a class after inheriting' do | ||
mod_parent = TestTransactionType.builder_methods_module | ||
|
@@ -152,6 +156,44 @@ class TestEnhancedTransactionType < TestTransactionType | |
assert_equal 'USD', obj.amount.currency | ||
end | ||
|
||
should 'build an object with a collection attribute' do | ||
obj = TestMultipleClientTransactionType.build do |t| | ||
t.cvv_code = '321' | ||
t.amount do |a| | ||
a.value = 45.0 | ||
a.currency = 'USD' | ||
end | ||
t.clients do |c| | ||
c.first_name = 'Mateusz' | ||
c.last_name = 'Gobbins' | ||
c.email = '[email protected]' | ||
end | ||
t.clients do |c| | ||
c.first_name = 'Michal' | ||
c.last_name = 'Zapow' | ||
c.email = '[email protected]' | ||
end | ||
end | ||
|
||
assert obj.is_a?(TestTransactionType) | ||
assert_equal '321', obj.cvv_code | ||
assert obj.amount.is_a?(TestAmountType) | ||
assert_equal 45.0, obj.amount.value | ||
assert_equal 'USD', obj.amount.currency | ||
assert obj.clients.is_a?(::Array), "Should be and Array, got: #{obj.clients.class.inspect}" | ||
assert_equal 2, obj.clients.length | ||
|
||
cli = obj.clients.first | ||
assert_equal 'Mateusz', cli.first_name | ||
assert_equal 'Gobbins', cli.last_name | ||
assert_equal '[email protected]', cli.email | ||
|
||
cli = obj.clients.last | ||
assert_equal 'Michal', cli.first_name | ||
assert_equal 'Zapow', cli.last_name | ||
assert_equal '[email protected]', cli.email | ||
end | ||
|
||
should 'build an object through the alt DSL' do | ||
obj = TestTransactionType.build do |t| | ||
t.cvv_code = '321' | ||
|
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 |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
|
||
require 'minitest/autorun' | ||
require 'shoulda-context' | ||
require 'byebug' |