Sha256: 72f27c640611c6d1248cffce4cc8ac851513bd2c800e0077c75c0690b6691e4a
Contents?: true
Size: 893 Bytes
Versions: 1
Compression:
Stored size: 893 Bytes
Contents
require 'capybara' module HaveTextMatcher def have_text(text) HaveText.new(text) end class HaveText def initialize(text) @text = text end def in(css) @css = css self end def matches?(subject) @subject = Capybara.string(subject) @subject.has_css?(@css || "*", :text => @text) end def failure_message_for_should "expected to find #{@text.inspect} #{within}" end def failure_message_for_should_not "expected not to find #{@text.inspect} #{within}" end private def within if @css && @subject.has_css?(@css) "within\n#{@subject.find(@css).native}" else "#{inside} within\n#{@subject.native}" end end def inside @css ? "inside #{@css.inspect}" : "anywhere" end end end RSpec.configure do |config| config.include HaveTextMatcher end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
locale_setter-0.4.0 | spec/support/matchers/have_text.rb |