Sha256: 86915aa39dcc46ae1b16c4766cec67a61726d3b6690be3f7fb8ca082711815cd

Contents?: true

Size: 1.97 KB

Versions: 56

Compression:

Stored size: 1.97 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")

module RR
  module TimesCalledMatchers
    describe RangeMatcher do
      attr_reader :matcher, :times
      before do
        @times = 2..4
        @matcher = RangeMatcher.new(times)
      end
      
      describe "#possible_match?" do
        it "returns true when times called < start of range" do
          matcher.should be_possible_match(1)
        end

        it "returns true when times called in range" do
          matcher.should be_possible_match(2)
          matcher.should be_possible_match(3)
          matcher.should be_possible_match(4)
        end

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

      describe "#matches?" do
        it "returns false when times_called less than start of range" do
          matcher.should_not be_matches(1)
        end

        it "returns true when times_called in range" do
          matcher.should be_matches(2)
          matcher.should be_matches(3)
          matcher.should be_matches(4)
        end

        it "returns false when times_called > end of range" do
          matcher.should_not be_matches(5)
        end
      end

      describe "#attempt?" do
        it "returns true when less than start of range" do
          matcher.should be_attempt(1)
        end

        it "returns true when in range" do
          matcher.should be_attempt(2)
          matcher.should be_attempt(3)
          matcher.should be_attempt(4)
        end

        it "returns false when > end of range" do
          matcher.should_not be_attempt(5)
        end
      end

      describe "#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(1).should == (
          "Called 1 time.\nExpected 2..4 times."
          )
        end
      end
    end

  end
end

Version data entries

56 entries across 52 versions & 9 rubygems

Version Path
adva-0.3.2 test/rr/spec/rr/times_called_matchers/range_matcher_spec.rb
adva-0.3.1 test/rr/spec/rr/times_called_matchers/range_matcher_spec.rb
adva-0.3.0 test/rr/spec/rr/times_called_matchers/range_matcher_spec.rb
adva-0.2.4 test/rr/spec/rr/times_called_matchers/range_matcher_spec.rb
adva-0.2.3 test/rr/spec/rr/times_called_matchers/range_matcher_spec.rb
adva-0.2.2 test/rr/spec/rr/times_called_matchers/range_matcher_spec.rb
adva-0.2.1 test/rr/spec/rr/times_called_matchers/range_matcher_spec.rb
adva-0.2.0 test/rr/spec/rr/times_called_matchers/range_matcher_spec.rb
adva-0.1.4 test/rr/spec/rr/times_called_matchers/range_matcher_spec.rb
adva-0.1.3 test/rr/spec/rr/times_called_matchers/range_matcher_spec.rb
adva-0.1.2 test/rr/spec/rr/times_called_matchers/range_matcher_spec.rb
adva-0.1.1 test/rr/spec/rr/times_called_matchers/range_matcher_spec.rb
adva-0.1.0 test/rr/spec/rr/times_called_matchers/range_matcher_spec.rb
adva-0.0.1 test/rr/spec/rr/times_called_matchers/range_matcher_spec.rb
jferris-rr-0.7.1.0.1239654108 spec/rr/times_called_matchers/range_matcher_spec.rb
redinger-redinger-rr-0.10.3 spec/rr/times_called_matchers/range_matcher_spec.rb
redinger-rr-0.10.4 spec/rr/times_called_matchers/range_matcher_spec.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/times_called_matchers/range_matcher_spec.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/times_called_matchers/range_matcher_spec.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/times_called_matchers/range_matcher_spec.rb