Sha256: 5c051547d17efa92bca110ed149dbdd242863d1bec7680c9e8b28d7c4a58ed0a

Contents?: true

Size: 1.55 KB

Versions: 3

Compression:

Stored size: 1.55 KB

Contents

require 'ostruct'

module TestXml
  class AssertionConfig < OpenStruct
    def assert_name
      "assert_#{name}"
    end

    def assert_not_name
      "assert_not_#{name}"
    end

    def expectation
      "must_#{matcher}"
    end
  end

  ASSERTIONS = [
    AssertionConfig.new(
      :name       => :xml_contain,
      :matcher    => :contain_xml,
      :message_for_should     => lambda { |a,b| "the xml:\n#{a}\nshould contain xml:\n#{b}" },
      :message_for_should_not => lambda { |a,b| "the xml:\n#{a}\nshould not contain xml:\n#{b} but it does" }
    ),
    AssertionConfig.new(
      :name       => :xml_structure_contain,
      :matcher    => :contain_xml_structure,
      :message_for_should     => lambda { |a,b| "the xml:\n#{a}\nshould match xml structure:\n#{b}" },
      :message_for_should_not => lambda { |a,b| "the xml:\n#{a}\nshould not match xml structure:\n#{b} but it does" }
    ),
    AssertionConfig.new(
      :name       => :xml_equal,
      :matcher    => :equal_xml,
      :message_for_should     => lambda { |a,b| "the xml:\n#{a}\nshould exactly match xml:\n#{b}" },
      :message_for_should_not => lambda { |a,b| "the xml:\n#{a}\nshould not exactly match xml:\n#{b} but it does" }
    ),
    AssertionConfig.new(
      :name       => :xml_structure_equal,
      :matcher    => :equal_xml_structure,
      :message_for_should     => lambda { |a,b| "the xml:\n#{a}\nshould exactly match xml structure:\n#{b}" },
      :message_for_should_not => lambda { |a,b| "the xml:\n#{a}\nshould not exactly match xml structure:\n#{b} but it does" }
    )
  ]
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
test_xml-0.1.5 lib/test_xml/assertions.rb
test_xml-0.1.4 lib/test_xml/assertions.rb
test_xml-0.1.3 lib/test_xml/assertions.rb