Sha256: 2dc8d4896cce80483293f0e8252a830708aa7b90e807b8d6b0bba571535346d5

Contents?: true

Size: 1.45 KB

Versions: 3

Compression:

Stored size: 1.45 KB

Contents

require 'teststrap'

context "A matching assertion macro" do
  setup { Riot::Assertion.new("foo") { "abc" } }

  assertion_test_passes("when expression matches actual", %Q{matches /abc/}) { topic.matches(/abc/) }

  assertion_test_fails("when expression fails to match", "expected /abcd/ to match \"abc\"") do
    topic.matches(/abcd/)
  end

  context "with integer based topic" do
    setup { Riot::Assertion.new("foo") { 42 } }

    assertion_test_passes("actual value converted to string", %Q{matches /^42$/}) do
      topic.matches(/^42$/)
    end

    assertion_test_fails("actual value converted to string", %Q{expected /^52$/ to match 42}) do
      topic.matches(/^52$/)
    end
  end

end # A matching assertion macro

context "A negative matching assertion macro" do
  setup { Riot::Assertion.new("foo", true) { "abc" } }

  assertion_test_fails("when expression matches actual", 'expected /abc/ not to match "abc"') do
    topic.matches(/abc/)
  end

  assertion_test_passes("when expression does not match", 'does not match /abcd/') do
    topic.matches(/abcd/)
  end

  context "with integer based topic" do
    setup { Riot::Assertion.new("foo", true) { 42 } }

    assertion_test_fails("actual value converted to string", 'expected /^42$/ not to match 42') do
      topic.matches(/^42$/)
    end

    assertion_test_passes("actual value converted to string", 'does not match /^52$/') do
      topic.matches(/^52$/)
    end
  end

end # A negative matching assertion macro

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
riot-0.12.1 test/core/assertion_macros/matches_test.rb
riot-0.12.0 test/core/assertion_macros/matches_test.rb
riot-0.12.0.pre test/core/assertion_macros/matches_test.rb