Sha256: 8c9f339bd1e0ff9c8d5ee068ded57659e3fc272c0aef872c62c776e07539df19

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

require 'action_view/vendor/html-scanner'

module ActionDispatch
  module Assertions
    module DomAssertions
      # \Test two HTML strings for equivalency (e.g., identical up to reordering of attributes)
      #
      #   # assert that the referenced method generates the appropriate HTML string
      #   assert_dom_equal '<a href="http://www.example.com">Apples</a>', link_to("Apples", "http://www.example.com")
      def assert_dom_equal(expected, actual, message = "")
        expected_dom = HTML::Document.new(expected).root
        actual_dom   = HTML::Document.new(actual).root
        assert_equal expected_dom, actual_dom
      end

      # The negated form of +assert_dom_equivalent+.
      #
      #   # assert that the referenced method does not generate the specified HTML string
      #   assert_dom_not_equal '<a href="http://www.example.com">Apples</a>', link_to("Oranges", "http://www.example.com")
      def assert_dom_not_equal(expected, actual, message = "")
        expected_dom = HTML::Document.new(expected).root
        actual_dom   = HTML::Document.new(actual).root
        assert_not_equal expected_dom, actual_dom
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
challah-1.0.0 vendor/bundle/gems/actionpack-4.0.0/lib/action_dispatch/testing/assertions/dom.rb
actionpack-4.0.0 lib/action_dispatch/testing/assertions/dom.rb
actionpack-4.0.0.rc2 lib/action_dispatch/testing/assertions/dom.rb
actionpack-4.0.0.rc1 lib/action_dispatch/testing/assertions/dom.rb
actionpack-4.0.0.beta1 lib/action_dispatch/testing/assertions/dom.rb