Sha256: a17c83d0dde5a3de6eff8e6dc62df04539e32d4ea86ff828c594db86f2dc47e1

Contents?: true

Size: 1.42 KB

Versions: 25

Compression:

Stored size: 1.42 KB

Contents

require "examples/example_helper"

module RR
module TimesCalledMatchers
  describe TimesCalledMatcher, ".create when passed a TimesCalledMatcher" do
    it "returns the passed in argument" do
      matcher = TimesCalledMatcher.new(5)
      TimesCalledMatcher.create(matcher).should === matcher
    end
  end

  describe TimesCalledMatcher, ".create when passed an unsupported type" do
    it "raises an ArgumentError" do
      matcher = Object.new
      proc do
        TimesCalledMatcher.create(matcher)
      end.should raise_error(ArgumentError, "There is no TimesCalledMatcher for #{matcher.inspect}.")
    end
  end

  describe TimesCalledMatcher, "#error_message" do
    before do
      @times = 3
      @matcher = TimesCalledMatcher.new(@times)
    end

    it "has an error message" do
      @matcher.error_message(5).should == (
        "Called 5 times.\nExpected 3 times."
      )
    end
  end

  describe TimesCalledMatcher, "#==" do
    before do
      @times = 3
      @matcher = TimesCalledMatcher.new(@times)
    end

    it "returns true when other is the same class and times are ==" do
      @matcher.should == TimesCalledMatcher.new(@times)
    end

    it "returns false when other is a different class and times are ==" do
      @matcher.should_not == IntegerMatcher.new(@times)
    end

    it "returns false when is the same class and times are not ==" do
      @matcher.should_not == TimesCalledMatcher.new(1)
    end
  end
end
end

Version data entries

25 entries across 25 versions & 1 rubygems

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