Class: Assay::Matcher
- Inherits:
-
Object
- Object
- Assay::Matcher
- Defined in:
- lib/assay/matcher.rb
Instance Method Summary collapse
-
#exception(message = nil) ⇒ Object
Returns Exception class.
- #fail(backtrace = nil) ⇒ Object
- #fail_class ⇒ Object
-
#fail_message ⇒ Object
This is just for RSpec matcher compatability.
-
#initialize(fail_class, *arguments, &block) ⇒ Matcher
constructor
A new instance of Matcher.
- #matches?(target) ⇒ Boolean
-
#negative_fail_message ⇒ Object
This is just for RSpec matcher compatability.
Constructor Details
#initialize(fail_class, *arguments, &block) ⇒ Matcher
Returns a new instance of Matcher.
5 6 7 8 9 |
# File 'lib/assay/matcher.rb', line 5 def initialize(fail_class, *arguments, &block) @fail_class = fail_class @arguments = arguments @block = block end |
Instance Method Details
#exception(message = nil) ⇒ Object
Returns Exception class.
25 26 27 28 29 |
# File 'lib/assay/matcher.rb', line 25 def exception(=nil) @exception ||= fail_class.new(, @target, *@arguments, &@block) # :negated => options[:negated], # :backtrace => options[:backtrace] || caller, end |
#fail(backtrace = nil) ⇒ Object
43 44 45 |
# File 'lib/assay/matcher.rb', line 43 def fail(backtrace=nil) super exception #(backtrace || caller) end |
#fail_class ⇒ Object
12 13 14 |
# File 'lib/assay/matcher.rb', line 12 def fail_class @fail_class end |
#fail_message ⇒ Object
This is just for RSpec matcher compatability.
32 33 34 |
# File 'lib/assay/matcher.rb', line 32 def exception.to_s end |
#matches?(target) ⇒ Boolean
17 18 19 20 21 22 |
# File 'lib/assay/matcher.rb', line 17 def matches?(target) @exception = nil @target = target @fail_class.pass?(target, *@arguments, &@block) end |
#negative_fail_message ⇒ Object
This is just for RSpec matcher compatability.
37 38 39 40 |
# File 'lib/assay/matcher.rb', line 37 def #exception.set_negative(true) exception.to_s end |