Sha256: 1b7012fe0b28eaecf3f4362965412f6611cce362d220ab363a98ccd8bc6f8dcf

Contents?: true

Size: 1.88 KB

Versions: 32

Compression:

Stored size: 1.88 KB

Contents

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

module RR
  module Expectations
    describe TimesCalledExpectation do
      context "when using an AtLeastMatcher" do
        it_should_behave_like "RR::Expectations::TimesCalledExpectation"
        attr_reader :times, :at_least, :expectation

        before do
          @times = 3
          double.definition.at_least(times)
          @at_least = double.definition.times_matcher
          @expectation = TimesCalledExpectation.new(double)
        end

        describe "#verify!" do
          it "passes when times called > times" do
            4.times {expectation.attempt}
            expectation.verify!
          end

          it "passes when times called == times" do
            3.times {expectation.attempt}
            expectation.verify!
          end

          it "raises error when times called < times" do
            expectation.attempt
            lambda do
              expectation.verify!
            end.should raise_error(
            RR::Errors::TimesCalledError,
            "foobar()\nCalled 1 time.\nExpected at least 3 times."
            )
          end
        end

        describe "#attempt?" do
          it "always returns true" do
            expectation.should be_attempt
            10.times {expectation.attempt}
            expectation.should be_attempt
          end
        end

        describe "#attempt!" do
          it "passes when times called more than times" do
            4.times {expectation.attempt}
          end

          it "passes when times called == times" do
            3.times {expectation.attempt}
          end

          it "passes when times called < times" do
            expectation.attempt
          end
        end

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

Version data entries

32 entries across 32 versions & 5 rubygems

Version Path
adva-0.3.2 test/rr/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
adva-0.3.1 test/rr/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
adva-0.3.0 test/rr/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
adva-0.2.4 test/rr/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
adva-0.2.3 test/rr/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
adva-0.2.2 test/rr/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
adva-0.2.1 test/rr/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
adva-0.2.0 test/rr/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
adva-0.1.4 test/rr/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
adva-0.1.3 test/rr/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
adva-0.1.2 test/rr/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
adva-0.1.1 test/rr/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
adva-0.1.0 test/rr/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
adva-0.0.1 test/rr/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
jferris-rr-0.7.1.0.1239654108 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
redinger-redinger-rr-0.10.3 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
redinger-rr-0.10.4 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
rr-0.10.10 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
rr-0.10.9 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
rr-0.10.8 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb