Sha256: 054eb46a5bbe81cb26ceb50c1db9a0c6d7ea8f19bf720075f5a29789a22f8f37

Contents?: true

Size: 1.12 KB

Versions: 21

Compression:

Stored size: 1.12 KB

Contents

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

module RR
  module Expectations
    describe TimesCalledExpectation do
      context "when using an AtMostMatcher" do
        include_examples "RR::Expectations::TimesCalledExpectation"

        before do
          stub(subject).foobar.at_most(3)
        end

        describe "#verify!" do
          it "passes when times called == times" do
            3.times {subject.foobar}
            RR.verify
          end

          it "passes when times called < times" do
            2.times {subject.foobar}
            RR.verify
          end

          it "raises error when times called > times" do
            expect {
              4.times {subject.foobar}
            }.to raise_error(
              RR::Errors::TimesCalledError,
              "foobar()\nCalled 4 times.\nExpected at most 3 times."
            )

            expect {
              RR.verify
            }.to raise_error(
              RR::Errors::TimesCalledError,
              "foobar()\nCalled 4 times.\nExpected at most 3 times."
            )
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rr-3.1.1 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-3.1.0 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-3.0.9 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-3.0.8 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-3.0.7 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-3.0.6 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-3.0.5 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-3.0.4 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-3.0.3 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-3.0.2 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-3.0.1 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-3.0.0 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-1.2.1 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-1.2.0 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-1.1.2 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-1.1.2.rc1 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-1.1.1.rc1 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-1.1.0 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-1.1.0.rc3 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb
rr-1.1.0.rc2 spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb