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
rr-0.10.7 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
rr-0.10.6 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
rr-0.10.5 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
rr-0.10.4 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
rr-0.10.2 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
redinger-rr-0.10.3 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
rr-0.10.0 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
rr-0.8.0 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
rr-0.7.1 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
rr-0.9.0 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
rr-0.7.0 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb
rr-0.8.1 spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb