Sha256: fe87f9331824dab6342904b7ff8025a327ab69d1a91e80a3abae40910f17cbaf

Contents?: true

Size: 1.68 KB

Versions: 11

Compression:

Stored size: 1.68 KB

Contents

require "spec/spec_helper"

module RR
  module TimesCalledMatchers
    describe IntegerMatcher do
      attr_reader :matcher, :times
      before do
        @times = 3
        @matcher = IntegerMatcher.new(times)
      end

      describe "#possible_match?" do
        it "returns true when times called < times" do
          matcher.should be_possible_match(2)
        end

        it "returns true when times called == times" do
          matcher.should be_possible_match(3)
        end

        it "returns false when times called > times" do
          matcher.should_not be_possible_match(4)
        end
      end

      describe "#matches?" do
        it "returns false when times_called less than times" do
          matcher.should_not be_matches(2)
        end

        it "returns true when times_called == times" do
          matcher.should be_matches(3)
        end

        it "returns false when times_called > times" do
          matcher.should_not be_matches(4)
        end
      end

      describe "#attempt?" do
        it "returns true when less than expected times" do
          matcher.should be_attempt(2)
        end

        it "returns false when == expected times" do
          matcher.should_not be_attempt(3)
        end

        it "returns false when > expected times" do
          matcher.should_not be_attempt(4)
        end
      end

      describe AnyTimesMatcher, "#terminal?" do
        it "returns true" do
          matcher.should be_terminal
        end
      end

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

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rr-0.4.8 spec/rr/times_called_matchers/integer_matcher_spec.rb
rr-0.4.3 spec/rr/times_called_matchers/integer_matcher_spec.rb
rr-0.4.6 spec/rr/times_called_matchers/integer_matcher_spec.rb
rr-0.4.4 spec/rr/times_called_matchers/integer_matcher_spec.rb
rr-0.4.1 spec/rr/times_called_matchers/integer_matcher_spec.rb
rr-0.4.5 spec/rr/times_called_matchers/integer_matcher_spec.rb
rr-0.4.7 spec/rr/times_called_matchers/integer_matcher_spec.rb
rr-0.4.9 spec/rr/times_called_matchers/integer_matcher_spec.rb
rr-0.4.0 spec/rr/times_called_matchers/integer_matcher_spec.rb
rr-0.4.10 spec/rr/times_called_matchers/integer_matcher_spec.rb
rr-0.4.2 spec/rr/times_called_matchers/integer_matcher_spec.rb