Sha256: 7be81912badc3d2a8a6077fd313546b0783efc8dd0811cb5655fb6b5499f9de0

Contents?: true

Size: 1.11 KB

Versions: 77

Compression:

Stored size: 1.11 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.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.negative_failure_message.should == ["expected \"string\" not to match /tri/", /tri/, "string"]
  end
end

Version data entries

77 entries across 77 versions & 12 rubygems

Version Path
jnstq-acts_as_sms-0.1.1 test/vendor/plugins/rspec/spec/spec/matchers/match_spec.rb
jnstq-acts_as_sms-0.1.3 test/vendor/plugins/rspec/spec/spec/matchers/match_spec.rb
jnstq-acts_as_sms-0.1.4 test/vendor/plugins/rspec/spec/spec/matchers/match_spec.rb
newbamboo-evented-rspec-1.1.12 spec/spec/matchers/match_spec.rb
newbamboo-rspec-1.1.12 spec/spec/matchers/match_spec.rb
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/match_spec.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/match_spec.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/match_spec.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/match_spec.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/match_spec.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/match_spec.rb
mack-0.8.2 lib/gems/rspec-1.1.11/spec/spec/matchers/match_spec.rb
picolena-0.0.99 app_generators/picolena/templates/vendor/plugins/rspec/spec/spec/matchers/match_spec.rb
picolena-0.1.1 rails_plugins/rspec/spec/spec/matchers/match_spec.rb
picolena-0.1.0 rails_plugins/rspec/spec/spec/matchers/match_spec.rb
picolena-0.1.4 rails_plugins/rspec/spec/spec/matchers/match_spec.rb
picolena-0.1.2 rails_plugins/rspec/spec/spec/matchers/match_spec.rb
picolena-0.1.3 rails_plugins/rspec/spec/spec/matchers/match_spec.rb
picolena-0.1.5 rails_plugins/rspec/spec/spec/matchers/match_spec.rb
pictrails-0.5.0 vendor/plugins/rspec/spec/spec/matchers/match_spec.rb