Sha256: b468de0bb3f0a080f73c50fe71b0b94f050ada73e64935fa11897bacafafc25c

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

require 'teststrap'

# Using == to verify the test because this is the test for :equals itself. Look at assertion_test_passes
# and assertion_test_fails for testing other macros.

context "An equivalent_to assertion macro" do
  setup do
    Riot::Assertion.new("red") { "what" }
  end

  asserts("String is equivalent to 'what'") do
    topic.equivalent_to(String).run(Riot::Situation.new) == [:pass, %Q{is equivalent to String}]
  end

  asserts("an array is not equivalent to 'what'") do
    topic.equivalent_to([]).run(Riot::Situation.new)[0..1] == [:fail, %Q{expected "what" to be equivalent to []}]
  end

  context "with numeric topic" do
    setup do
      Riot::Assertion.new("blue") { 31413 }
    end

    asserts(":pass when in expected range") do
      topic.equivalent_to(30000..32000).run(Riot::Situation.new) == [:pass, "is equivalent to 30000..32000"]
    end

    context "when not in expected range" do
      setup { topic.equivalent_to(32000..33000).run(Riot::Situation.new) }

      asserts(":fail") { topic.first == :fail }
      asserts("message") { topic[1] == %Q{expected 31413 to be equivalent to 32000..33000} }
    end
  end # with numeric topic

end # An equivalent_to assertion macro

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
riot-0.11.4 test/core/assertion_macros/equivalent_to_test.rb
riot-0.11.4.pre test/core/assertion_macros/equivalent_to_test.rb
riot-0.11.3 test/core/assertion_macros/equivalent_to_test.rb
riot-0.11.2 test/core/assertion_macros/equivalent_to_test.rb
riot-0.11.1 test/core/assertion_macros/equivalent_to_test.rb
riot-0.11.0 test/core/assertion_macros/equivalent_to_test.rb
riot-0.10.13 test/core/assertion_macros/equivalent_to_test.rb
riot-0.10.13.pre test/core/assertion_macros/equivalent_to_test.rb
riot-0.10.12 test/core/assertion_macros/equivalent_to_test.rb