aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support/matchers/disambiguate_attributes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/matchers/disambiguate_attributes.rb')
-rw-r--r--spec/support/matchers/disambiguate_attributes.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/support/matchers/disambiguate_attributes.rb b/spec/support/matchers/disambiguate_attributes.rb
new file mode 100644
index 0000000000..bc4a5215d4
--- /dev/null
+++ b/spec/support/matchers/disambiguate_attributes.rb
@@ -0,0 +1,28 @@
+module DisambiguateAttributesMatcher
+ class DisambiguateAttributes
+ def initialize(attributes)
+ @attributes = attributes
+ end
+
+ def matches?(actual)
+ @actual = actual
+ attribute1, attribute2 = @attributes
+ @actual[attribute1].descends_from?(attribute1) &&
+ !@actual[attribute1].descends_from?(attribute2) &&
+ @actual[attribute2].descends_from?(attribute2)
+ end
+
+ def failure_message
+ ""
+ # "expected #{@actual} to disambiguate its attributes"
+ end
+
+ def negative_failure_message
+ "expected #{@actual} to not disambiguate its attributes"
+ end
+ end
+
+ def disambiguate_attributes(*attributes)
+ DisambiguateAttributes.new(attributes)
+ end
+end