Class: Spec::Rails::Matchers::OptionsMatcher
- Inherits:
-
Object
- Object
- Spec::Rails::Matchers::OptionsMatcher
- Defined in:
- lib/matchers/options_matcher.rb
Instance Method Summary collapse
- #extract_html_content(html) ⇒ Object
- #failure_message ⇒ Object
-
#initialize(expected) ⇒ OptionsMatcher
constructor
A new instance of OptionsMatcher.
- #matches?(response) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(expected) ⇒ OptionsMatcher
Returns a new instance of OptionsMatcher.
5 6 7 |
# File 'lib/matchers/options_matcher.rb', line 5 def initialize expected @expected = expected end |
Instance Method Details
#extract_html_content(html) ⇒ Object
22 23 24 25 |
# File 'lib/matchers/options_matcher.rb', line 22 def extract_html_content html doc = Hpricot.XML(html) doc.search("/option").map{|n| n.inner_text.strip} end |
#failure_message ⇒ Object
14 15 16 |
# File 'lib/matchers/options_matcher.rb', line 14 def "\nWrong option contents.\nexpected: #{@expected.inspect}\n found: #{@actual.inspect}\n\n" end |
#matches?(response) ⇒ Boolean
9 10 11 12 |
# File 'lib/matchers/options_matcher.rb', line 9 def matches? response @actual = extract_html_content response.body @actual == @expected end |
#negative_failure_message ⇒ Object
18 19 20 |
# File 'lib/matchers/options_matcher.rb', line 18 def "\nShould not have matched contents: #{@expected.inspect}\n\n" end |