Sha256: 80b37d2a3ff4a9c3c62407e7596056c8f6e462cd95204c4e086156eab0ed6cf3

Contents?: true

Size: 1.22 KB

Versions: 49

Compression:

Stored size: 1.22 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")

describe Micronaut::Matchers do

  describe "should match(expected)" do

    it "should pass when target (String) matches expected (Regexp)" do
      "string".should match(/tri/)
    end

    it "should fail when target (String) does not match expected (Regexp)" do
      lambda { "string".should match(/rings/) }.should fail
    end

    it "should provide message, expected and actual on failure" do
      matcher = match(/rings/)
      matcher.matches?("string")
      matcher.failure_message.should == ["expected \"string\" to match /rings/", /rings/, "string"]
    end

  end

  describe "should_not match(expected)" do

    it "should pass when target (String) matches does not match (Regexp)" do
      "string".should_not match(/rings/)
    end

    it "should fail when target (String) matches expected (Regexp)" do
      lambda {
        "string".should_not match(/tri/)
      }.should fail
    end

    it "should provide message, expected and actual on failure" do
      matcher = match(/tri/)
      matcher.matches?("string")
      matcher.negative_failure_message.should == ["expected \"string\" not to match /tri/", /tri/, "string"]
    end

  end

end

Version data entries

49 entries across 49 versions & 3 rubygems

Version Path
spicycode-micronaut-0.1.7.2 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.1.7.3 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.1.7.4 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.1.7 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.1.8.0 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.1.8.1 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.1.8.2 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.1.8.3 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.1.8.5 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.1.9.0 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.2.0.0 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.2.1.0 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.2.1.1 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.2.1.2 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.2.1.3 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.2.1.4 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.2.1.5 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.2.1.6 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.2.10 examples/lib/micronaut/matchers/match_example.rb
spicycode-micronaut-0.2.2 examples/lib/micronaut/matchers/match_example.rb