Module: Hermes::Assertions
- Included in:
- IntegrationCase
- Defined in:
- lib/hermes/assertions.rb
Overview
A few assertions built on top of Capybara.
Instance Method Summary collapse
- #assert_content(content) ⇒ Object
- #assert_current_path(expected) ⇒ Object
- #assert_difference_on_click_button(button, *args) ⇒ Object
- #assert_difference_on_click_link(link, *args) ⇒ Object
- #assert_link_to(url, options) ⇒ Object
- #assert_mail_deliveries(many = 1) ⇒ Object
- #assert_no_content(content) ⇒ Object
- #within(scope, prefix = nil) ⇒ Object
Instance Method Details
#assert_content(content) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/hermes/assertions.rb', line 20 def assert_content(content) boolean = has_content?(content) if boolean assert_block("assert_content") { true } else assert_block("#{body_inner_text}\nExpected to have #{content}"){ false } end end |
#assert_current_path(expected) ⇒ Object
4 5 6 |
# File 'lib/hermes/assertions.rb', line 4 def assert_current_path(expected) assert_equal expected, current_path end |
#assert_difference_on_click_button(button, *args) ⇒ Object
8 9 10 11 12 |
# File 'lib/hermes/assertions.rb', line 8 def (, *args) assert_difference *args do end end |
#assert_difference_on_click_link(link, *args) ⇒ Object
14 15 16 17 18 |
# File 'lib/hermes/assertions.rb', line 14 def assert_difference_on_click_link(link, *args) assert_difference *args do click_link link end end |
#assert_link_to(url, options) ⇒ Object
64 65 66 |
# File 'lib/hermes/assertions.rb', line 64 def assert_link_to(url, ) assert_css "a[href='%s']" % url, end |
#assert_mail_deliveries(many = 1) ⇒ Object
60 61 62 |
# File 'lib/hermes/assertions.rb', line 60 def assert_mail_deliveries(many=1) assert_difference("ActionMailer::Base.deliveries.size", many){ yield } end |
#assert_no_content(content) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/hermes/assertions.rb', line 29 def assert_no_content(content) boolean = has_content?(content) if boolean assert_block("#{body_inner_text}\nDid not expect to have content #{content}"){ false } else assert_block("assert_no_content") { true } end end |
#within(scope, prefix = nil) ⇒ Object
68 69 70 71 |
# File 'lib/hermes/assertions.rb', line 68 def within(scope, prefix=nil) scope = '#' << ActionController::RecordIdentifier.dom_id(scope, prefix) if scope.is_a?(ActiveRecord::Base) super(scope) end |