Class: PermalinkFu::Spec::Matchers::PermalinkTo
- Inherits:
-
Object
- Object
- PermalinkFu::Spec::Matchers::PermalinkTo
- Defined in:
- lib/permalink_fu/spec/matchers.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(permalink, to_param = nil) ⇒ PermalinkTo
constructor
A new instance of PermalinkTo.
- #matches?(target) ⇒ Boolean
Constructor Details
#initialize(permalink, to_param = nil) ⇒ PermalinkTo
Returns a new instance of PermalinkTo.
5 6 7 8 |
# File 'lib/permalink_fu/spec/matchers.rb', line 5 def initialize(permalink, to_param = nil) @expected_permalink = permalink @expected_to_param = to_param end |
Instance Method Details
#failure_message ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/permalink_fu/spec/matchers.rb', line 16 def = [] << "to permalink to #{@expected_permalink.inspect} (got #{@permalink.inspect})" if @permalink != @expected_permalink << "to generate a URL like #{expected_to_param.inspect} (got #{@to_param.inspect})" if @to_param != expected_to_param "expected #{.join(' and ')}" end |
#matches?(target) ⇒ Boolean
10 11 12 13 14 |
# File 'lib/permalink_fu/spec/matchers.rb', line 10 def matches?(target) @target = target @permalink, @to_param = target.permalink, target.to_param @permalink == @expected_permalink && @to_param == expected_to_param end |