Sha256: bee9d840cd13f5f995cbf2f5b07a85e049c5b4e94666a0903a1ea4bd8d6348af

Contents?: true

Size: 1.38 KB

Versions: 56

Compression:

Stored size: 1.38 KB

Contents

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

module RR
  module TimesCalledMatchers
    describe ProcMatcher do
      attr_reader :matcher, :times
      before do
        @times = lambda {|other| other == 3}
        @matcher = ProcMatcher.new(times)
      end
      
      describe "#possible_match?" do
        it "always returns true" do
          matcher.should be_possible_match(2)
          matcher.should be_possible_match(3)
          matcher.should be_possible_match(10)
        end
      end

      describe "#matches?" do
        it "returns false when lambda returns false" do
          times.call(2).should be_false
          matcher.should_not be_matches(2)
        end

        it "returns true when lambda returns true" do
          times.call(3).should be_true
          matcher.should be_matches(3)
        end
      end

      describe "#attempt?" do
        it "always returns true" do
          matcher.should be_attempt(2)
          matcher.should be_attempt(3)
          matcher.should be_attempt(10)
        end
      end

      describe "#terminal?" do
        it "returns false" do
          matcher.should_not be_terminal
        end
      end

      describe "#error_message" do
        it "has an error message" do
          matcher.error_message(1).should =~
          /Called 1 time.\nExpected #<Proc.*> times./
        end
      end
    end

  end
end

Version data entries

56 entries across 52 versions & 9 rubygems

Version Path
rr-0.10.10 spec/rr/times_called_matchers/proc_matcher_spec.rb
rr-0.10.9 spec/rr/times_called_matchers/proc_matcher_spec.rb
rr-0.10.8 spec/rr/times_called_matchers/proc_matcher_spec.rb
rr-0.10.7 spec/rr/times_called_matchers/proc_matcher_spec.rb
rr-0.10.6 spec/rr/times_called_matchers/proc_matcher_spec.rb
rr-0.10.5 spec/rr/times_called_matchers/proc_matcher_spec.rb
rr-0.10.4 spec/rr/times_called_matchers/proc_matcher_spec.rb
rr-0.10.2 spec/rr/times_called_matchers/proc_matcher_spec.rb
redinger-rr-0.10.3 spec/rr/times_called_matchers/proc_matcher_spec.rb
rr-0.10.0 spec/rr/times_called_matchers/proc_matcher_spec.rb
rr-0.8.0 spec/rr/times_called_matchers/proc_matcher_spec.rb
rr-0.9.0 spec/rr/times_called_matchers/proc_matcher_spec.rb
rr-0.8.1 spec/rr/times_called_matchers/proc_matcher_spec.rb
rr-0.7.1 spec/rr/times_called_matchers/proc_matcher_spec.rb
rr-0.6.0 spec/rr/times_called_matchers/proc_matcher_spec.rb
rr-0.7.0 spec/rr/times_called_matchers/proc_matcher_spec.rb