Module: OpenGraphPlus::Minitest
- Defined in:
- lib/opengraphplus/minitest.rb
Instance Method Summary collapse
-
#assert_og_tag(html, property, content = nil, message = nil) ⇒ Object
Assert that a specific OpenGraph/Twitter tag is present.
-
#assert_open_graph_tags(html, message = nil) ⇒ Object
Assert that all required OpenGraph tags are present.
-
#refute_og_tag(html, property, message = nil) ⇒ Object
Assert that a specific OpenGraph/Twitter tag is NOT present.
Instance Method Details
#assert_og_tag(html, property, content = nil, message = nil) ⇒ Object
Assert that a specific OpenGraph/Twitter tag is present
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/opengraphplus/minitest.rb', line 32 def assert_og_tag(html, property, content = nil, = nil) parser = OpenGraphPlus::Parser.new(html) actual_content = parser[property] if content.nil? ||= "Expected HTML to have #{property} tag, but it was not found" assert !actual_content.nil?, else ||= "Expected #{property} to have content #{content.inspect}, but got #{actual_content.inspect}" assert_equal content, actual_content, end end |
#assert_open_graph_tags(html, message = nil) ⇒ Object
Assert that all required OpenGraph tags are present
15 16 17 18 19 |
# File 'lib/opengraphplus/minitest.rb', line 15 def (html, = nil) parser = OpenGraphPlus::Parser.new(html) ||= "Expected HTML to have all required OpenGraph tags, but missing: #{parser.errors.join(', ')}" assert parser.valid?, end |
#refute_og_tag(html, property, message = nil) ⇒ Object
Assert that a specific OpenGraph/Twitter tag is NOT present
54 55 56 57 58 59 |
# File 'lib/opengraphplus/minitest.rb', line 54 def refute_og_tag(html, property, = nil) parser = OpenGraphPlus::Parser.new(html) actual_content = parser[property] ||= "Expected HTML not to have #{property} tag, but it was found with content #{actual_content.inspect}" assert actual_content.nil?, end |