Sha256: 3b0978d847a01830b5525543e86e97f2b99e4a7f5972b09644bece682a725bf1

Contents?: true

Size: 1.57 KB

Versions: 59

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'

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

  it "should pass when target (String) matches expected (String)" 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 fail when target (String) does not match expected (String)" 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/"
  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 pass when target (String) matches does not match (String)" 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 fail when target (String) matches expected (String)" 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/"
  end
end

Version data entries

59 entries across 59 versions & 12 rubygems

Version Path
rspec-instructure-1.3.3 spec/spec/matchers/match_spec.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rspec-1.3.2/spec/spec/matchers/match_spec.rb
rspec-1.3.2 spec/spec/matchers/match_spec.rb
rspec-1.3.1 spec/spec/matchers/match_spec.rb
rspec-1.3.1.rc spec/spec/matchers/match_spec.rb
rspec-expectations-2.0.0.beta.19 spec/rspec/matchers/match_spec.rb
rspec-expectations-2.0.0.beta.18 spec/rspec/matchers/match_spec.rb
rspec-expectations-2.0.0.beta.17 spec/rspec/matchers/match_spec.rb
rspec-expectations-2.0.0.beta.16 spec/rspec/matchers/match_spec.rb
rspec-expectations-2.0.0.beta.15 spec/rspec/matchers/match_spec.rb
rspec-expectations-2.0.0.beta.14 spec/rspec/matchers/match_spec.rb
rspec-expectations-2.0.0.beta.13 spec/rspec/matchers/match_spec.rb
rspec-expectations-2.0.0.beta.12 spec/rspec/matchers/match_spec.rb
rspec-expectations-2.0.0.beta.11 spec/rspec/matchers/match_spec.rb
rspec-expectations-2.0.0.beta.10 spec/rspec/matchers/match_spec.rb
rspec-expectations-2.0.0.beta.9 spec/rspec/matchers/match_spec.rb
rspec-expectations-2.0.0.beta.8 spec/rspec/matchers/match_spec.rb
rspec-expectations-2.0.0.beta.7 spec/rspec/matchers/match_spec.rb
rspec-expectations-2.0.0.beta.6 spec/rspec/matchers/match_spec.rb
rspec-expectations-2.0.0.beta.5 spec/rspec/matchers/match_spec.rb