Sha256: 88beb273bcd539ab06382caa619f519ab3fed9bb4d49bc872e7445764385c266

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

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

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_for_should.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.failure_message_for_should_not.should == ["expected \"string\" not to match /tri/", /tri/, "string"]
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
dchelimsky-rspec-1.1.99.13 spec/spec/matchers/match_spec.rb
rspec-1.2.0 spec/spec/matchers/match_spec.rb
rspec-1.2.1 spec/spec/matchers/match_spec.rb
rspec-1.2.2 spec/spec/matchers/match_spec.rb