Class: MerbExt::SpecCustomMatchers::HaveList
- Inherits:
-
Object
- Object
- MerbExt::SpecCustomMatchers::HaveList
- Defined in:
- lib/merb-ext/spec_custom_matchers.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(list) ⇒ HaveList
constructor
A new instance of HaveList.
- #matches?(target) ⇒ Boolean
Constructor Details
#initialize(list) ⇒ HaveList
Returns a new instance of HaveList.
56 57 58 59 |
# File 'lib/merb-ext/spec_custom_matchers.rb', line 56 def initialize(list) @lsit = list @list_items = list.split("\n").map {|e| e.strip} end |
Instance Method Details
#failure_message ⇒ Object
70 71 72 |
# File 'lib/merb-ext/spec_custom_matchers.rb', line 70 def "expected #{@target.body} to look like: #{@list}" end |
#matches?(target) ⇒ Boolean
61 62 63 64 65 66 67 68 |
# File 'lib/merb-ext/spec_custom_matchers.rb', line 61 def matches?(target) @target = target @list_items.each_with_index do |item, index| matcher = ::Webrat::Matchers::HaveXpath.new("//ul//li[#{index+1}][contains(. ,'#{item}')]") return false unless matcher.matches?(target) end end |