-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved duplicate testing code over to test_helpers
- Loading branch information
Showing
4 changed files
with
25 additions
and
48 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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module TestHelpers | ||
def assert_ancestry(node, value, child: :skip, db: :value) | ||
column_name = node.class.ancestry_column | ||
if value.nil? | ||
assert_nil node.send(column_name) | ||
else | ||
assert_equal value, node.send(column_name) | ||
end | ||
|
||
db = value if db == :value | ||
if db.nil? | ||
assert_nil node.send("#{column_name}_in_database") | ||
else | ||
assert_equal db, node.send("#{column_name}_in_database") | ||
end | ||
|
||
if child.nil? | ||
assert_nil node.child_ancestry | ||
elsif child != :skip | ||
assert_equal child, node.child_ancestry | ||
end | ||
end | ||
end |