Sha256: 785bb5f58c316bc07eb57637f8855bb71828cfb8cc9435c0de1d72c9ec94871a

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper.rb'

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

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

  specify "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

context "should_not match(expected)" do
  specify "should pass when target (String) matches expected (Regexp)" do
    "string".should_not match(/rings/)
  end

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

  specify "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

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
riess-0.0.8 vendor/rspec-0.8.2/spec/spec/matchers/match_spec.rb
rspec-0.8.0 spec/spec/matchers/match_spec.rb
rspec-0.8.1 spec/spec/matchers/match_spec.rb
rspec-0.8.2 spec/spec/matchers/match_spec.rb