Sha256: 174fc1b0eb65a7ca9607e5e4561421362d1d11068ce3548bb33a66ce65af4652

Contents?: true

Size: 1.23 KB

Versions: 8

Compression:

Stored size: 1.23 KB

Contents

require 'bundler/setup'
require 'html/pipeline'
require 'test/unit'

require 'active_support/core_ext/string'
require 'active_support/core_ext/object/try'

module TestHelpers
  # Asserts that `needle` is not a member of `haystack`, where
  # `haystack` is any object that responds to `include?`.
  def assert_doesnt_include(needle, haystack, message = nil)
    error = '<?> included in <?>'
    message = build_message(message, error, needle.to_s, Array(haystack).map(&:to_s))

    assert_block message do
      !haystack.include?(needle)
    end
  end

  # Asserts that `needle` is a member of `haystack`, where
  # `haystack` is any object that responds to `include?`.
  def assert_includes(needle, haystack, message = nil)
    error = '<?> not included in <?>'
    message = build_message(message, error, needle.to_s, Array(haystack).map(&:to_s))

    assert_block message do
      haystack.include?(needle)
    end
  end

  # Asserts that two html fragments are equivalent. Attribute order
  # will be ignored.
  def assert_equal_html(expected, actual)
    assert_equal Nokogiri::HTML::DocumentFragment.parse(expected).to_hash,
                 Nokogiri::HTML::DocumentFragment.parse(actual).to_hash
  end
end

Test::Unit::TestCase.send(:include, TestHelpers)

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
html-pipeline-1.8.0 test/test_helper.rb
html-pipeline-1.7.0 test/test_helper.rb
html-pipeline-1.6.0 test/test_helper.rb
html-pipeline-1.5.0 test/test_helper.rb
html-pipeline-1.4.0 test/test_helper.rb
html-pipeline-1.3.0 test/test_helper.rb
html-pipeline-1.1.0 test/test_helper.rb
html-pipeline-1.0.0 test/test_helper.rb