Sha256: b7c9ef3257b7561fdcb6c2f59ce97f87a2b9efaee78fdf4c9f49af8506534d48

Contents?: true

Size: 1.94 KB

Versions: 25

Compression:

Stored size: 1.94 KB

Contents

require "examples/example_helper"

module RR
module Expectations
  describe ArgumentEqualityExpectation, "#exact_match? with regexp argument" do
    before do
      @expectation = ArgumentEqualityExpectation.new(/abc/)
    end
    
    it "returns true when passed in an Regexp matcher with the same argument list" do
      @expectation.should be_exact_match(/abc/)
    end

    it "returns false when passed in an Regexp matcher with a different argument list" do
      @expectation.should_not be_exact_match(/def/)
    end

    it "returns false otherwise" do
      @expectation.should_not be_exact_match("abc")
      @expectation.should_not be_exact_match(:hello)
      @expectation.should_not be_exact_match(1)
      @expectation.should_not be_exact_match(nil)
      @expectation.should_not be_exact_match(true)
      @expectation.should_not be_exact_match()
    end
  end

  describe ArgumentEqualityExpectation, "#wildcard_match? with Regexp argument" do
    before do
      @matching_object = Object.new
      def @matching_object.quack
      end
      def @matching_object.waddle
      end

      @partial_matching_object = Object.new
      def @partial_matching_object.quack
      end

      @not_match_object = Object.new

      @expectation = ArgumentEqualityExpectation.new(/abc/)
    end

    it "returns true when string matches the regexp" do
      @expectation.should be_wildcard_match("Tabcola")
    end

    it "returns false when string does not match the regexp" do
      @expectation.should_not be_wildcard_match("no match here")
    end

    it "returns true when an exact match" do
      @expectation.should be_wildcard_match(/abc/)
    end

    it "returns false when not an exact match" do
      @expectation.should_not be_wildcard_match(/def/)
    end

    it "returns false when not passed correct number of arguments" do
      @expectation.should_not be_wildcard_match()
      @expectation.should_not be_wildcard_match('abc', 'abc')
    end
  end
end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
rr-0.1.11 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.1.10 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.1.8 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.1.15 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.1.12 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.1.13 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.1.14 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.3.11 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.3.2 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.3.10 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.2.3 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.3.1 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.3.3 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.3.4 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.1.9 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.2.1 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.2.2 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.3.0 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.2.5 examples/rr/expectations/regexp_argument_equality_expectation_example.rb
rr-0.2.4 examples/rr/expectations/regexp_argument_equality_expectation_example.rb