Class: Spec::Matchers::ThrowSymbol
- Defined in:
- lib/gems/rspec-1.1.11/lib/spec/matchers/throw_symbol.rb
Overview
:nodoc:
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(expected = nil) ⇒ ThrowSymbol
constructor
A new instance of ThrowSymbol.
- #matches?(given_proc) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(expected = nil) ⇒ ThrowSymbol
Returns a new instance of ThrowSymbol.
5 6 7 8 |
# File 'lib/gems/rspec-1.1.11/lib/spec/matchers/throw_symbol.rb', line 5 def initialize(expected=nil) @expected = expected @actual = nil end |
Instance Method Details
#description ⇒ Object
41 42 43 |
# File 'lib/gems/rspec-1.1.11/lib/spec/matchers/throw_symbol.rb', line 41 def description "throw #{expected}" end |
#failure_message ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/gems/rspec-1.1.11/lib/spec/matchers/throw_symbol.rb', line 25 def if @actual "expected #{expected}, got #{@actual.inspect}" else "expected #{expected} but nothing was thrown" end end |
#matches?(given_proc) ⇒ Boolean
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gems/rspec-1.1.11/lib/spec/matchers/throw_symbol.rb', line 10 def matches?(given_proc) begin given_proc.call rescue NameError => e raise e unless e. =~ /uncaught throw/ @actual = e.name.to_sym ensure if @expected.nil? return @actual.nil? ? false : true else return @actual == @expected end end end |
#negative_failure_message ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/gems/rspec-1.1.11/lib/spec/matchers/throw_symbol.rb', line 33 def if @expected "expected #{expected} not to be thrown" else "expected no Symbol, got :#{@actual}" end end |