Sha256: 29ce76563744e3872643c4baeaa528938c83baa17e2100005d8c14b7c596746f

Contents?: true

Size: 1.52 KB

Versions: 227

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'

describe "should match(expected)" do
  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

227 entries across 126 versions & 15 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/match_spec.rb
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/match_spec.rb
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/match_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/match_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/match_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/match_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/match_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/match_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/match_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/match_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/match_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/match_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/match_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/match_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/match_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/match_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/match_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/match_spec.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rspec-expectations-2.10.0/spec/rspec/matchers/match_spec.rb
classiccms-0.6.9 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/match_spec.rb