Sha256: 1981794143e5a9fcfc6801addc569974fac945042b1852b6902887176251590a

Contents?: true

Size: 1.64 KB

Versions: 10

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

describe "should match(expected)" do
  it_behaves_like "an RSpec matcher", :valid_value => 'ab', :invalid_value => 'bc' do
    let(:matcher) { match(/a/) }
  end

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

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

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

  it "fails when target (String) does not match expected (String)" do
    lambda {
      "string".should match("rings")
    }.should fail
  end
  
  it "provides message, expected and actual on failure" do
    matcher = match(/rings/)
    matcher.matches?("string")
    matcher.failure_message_for_should.should == "expected \"string\" to match /rings/"
  end
end

describe "should_not match(expected)" do
  it "passes when target (String) matches does not match (Regexp)" do
    "string".should_not match(/rings/)
  end

  it "passes when target (String) matches does not match (String)" do
    "string".should_not match("rings")
  end

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

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

  it "provides 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/"
  end
end

Version data entries

10 entries across 10 versions & 5 rubygems

Version Path
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/rspec-expectations-2.11.3/spec/rspec/matchers/match_spec.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/rspec-expectations-2.11.3/spec/rspec/matchers/match_spec.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/rspec-expectations-2.12.1/spec/rspec/matchers/match_spec.rb
remq-0.0.4 vendor/bundle/gems/rspec-expectations-2.12.1/spec/rspec/matchers/match_spec.rb
remq-0.0.3 vendor/bundle/gems/rspec-expectations-2.12.1/spec/rspec/matchers/match_spec.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/rspec-expectations-2.12.1/spec/rspec/matchers/match_spec.rb
rspec-expectations-2.12.1 spec/rspec/matchers/match_spec.rb
rspec-expectations-2.12.0 spec/rspec/matchers/match_spec.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/rspec-expectations-2.11.3/spec/rspec/matchers/match_spec.rb
rspec-expectations-2.11.3 spec/rspec/matchers/match_spec.rb