Skip to content

Commit

Permalink
Tests are parameterized
Browse files Browse the repository at this point in the history
  • Loading branch information
sbellware committed May 22, 2019
1 parent 9e35460 commit 4cdda80
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 29 deletions.
46 changes: 29 additions & 17 deletions test/automated/excluded_attributes/many.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,36 @@

context "Excluded Attributes" do
context "Many" do
receiver = Controls::Object::New.example
source = Controls::Hash.example

SetAttributes.(receiver, source, exclude: [
:some_other_attribute,
:yet_another_attribute]
)

context "Excluded" do
test "Aren't set" do
assert(receiver.some_other_attribute.nil?)
assert(receiver.yet_another_attribute.nil?)
end
end
hash_source = Controls::Hash.example
object_source = Controls::Object.example

mapping = hash_source.keys

[[hash_source, 'Hash'], [object_source, 'Object']].each do |source_info|

source = source_info[0]
source_type = source_info[1]

context "#{source_type} Source" do
receiver = Controls::Object::New.example

SetAttributes.(receiver, source, include: mapping, exclude: [
:some_other_attribute,
:yet_another_attribute]
)

context "Excluded" do
test "Aren't set" do
assert(receiver.some_other_attribute.nil?)
assert(receiver.yet_another_attribute.nil?)
end
end

context "Not Excluded Attributes" do
test "Are set" do
assert(receiver.some_attribute == 'some value')
context "Not Excluded Attributes" do
test "Are set" do
assert(receiver.some_attribute == 'some value')
end
end
end
end
end
Expand Down
36 changes: 24 additions & 12 deletions test/automated/excluded_attributes/one.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,33 @@

context "Excluded Attributes" do
context "One" do
receiver = Controls::Object::New.example
data = Controls::Hash.example
hash_source = Controls::Hash.example
object_source = Controls::Object.example

SetAttributes.(receiver, data, exclude: :some_other_attribute)
mapping = hash_source.keys

context "Excluded" do
test "Aren't set" do
assert(receiver.some_other_attribute.nil?)
end
end
[[hash_source, 'Hash'], [object_source, 'Object']].each do |source_info|

source = source_info[0]
source_type = source_info[1]

context "#{source_type} Source" do
receiver = Controls::Object::New.example

SetAttributes.(receiver, source, include: mapping, exclude: :some_other_attribute)

context "Excluded" do
test "Aren't set" do
assert(receiver.some_other_attribute.nil?)
end
end

context "Not Excluded Attributes" do
test "Are set" do
assert(receiver.some_attribute == 'some value')
assert(receiver.yet_another_attribute == 'yet another value')
context "Not Excluded Attributes" do
test "Are set" do
assert(receiver.some_attribute == 'some value')
assert(receiver.yet_another_attribute == 'yet another value')
end
end
end
end
end
Expand Down

0 comments on commit 4cdda80

Please sign in to comment.