Sha256: 5d7c432dfcf13d8e2f00f85dc95a9eba9bf13c93a84b7e97aefde5cfcdced851

Contents?: true

Size: 1.6 KB

Versions: 14

Compression:

Stored size: 1.6 KB

Contents

require File.expand_path('../base', __FILE__)
require File.expand_path('../../matchers/be_a_subset_of_matcher', __FILE__)

module AdapterTests
  module RSpec
    include Base

    def self.included(base)
      base.class_eval do
        specify 'stubs work' do
          assert_stubs_work
        end

        specify 'mocks work' do
          assert_mocks_work
        end

        specify 'stub proxies work' do
          assert_stub_proxies_work
        end

        specify 'mock proxies work' do
          assert_mock_proxies_work
        end

        specify 'times-called verifications work' do
          assert_times_called_verifications_work
        end

        specify 'have_received works' do
          subject = Object.new
          stub(subject).foobar(1, 2)
          subject.foobar(1, 2)
          subject.should have_received.foobar(1, 2)

          expect {
            subject.should have_received.foobar(1, 2, 3)
          }.to raise_error(
            expectation_not_met_error,
            /Expected foobar\(1, 2, 3\).+to be called 1 time/m
          )
        end
      end
    end

    def expectation_not_met_error
      if defined?(::RSpec)
        ::RSpec::Expectations::ExpectationNotMetError
      else
        Spec::Expectations::ExpectationNotMetError
      end
    end

    def assert_equal(expected, actual)
      expected.should be == actual
    end

    def assert_subset(subset, set)
      subset.should be_a_subset_of(set)
    end

    def assert_raises(error, &block)
      expect(&block).to raise_error(error)
    end

    def be_a_subset_of(set)
      BeASubsetOfMatcher.new(set)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rr-3.1.1 spec/support/adapter_tests/rspec.rb
rr-3.1.0 spec/support/adapter_tests/rspec.rb
rr-3.0.9 spec/support/adapter_tests/rspec.rb
rr-3.0.8 spec/support/adapter_tests/rspec.rb
rr-3.0.7 spec/support/adapter_tests/rspec.rb
rr-3.0.6 spec/support/adapter_tests/rspec.rb
rr-3.0.5 spec/support/adapter_tests/rspec.rb
rr-3.0.4 spec/support/adapter_tests/rspec.rb
rr-3.0.3 spec/support/adapter_tests/rspec.rb
rr-3.0.2 spec/support/adapter_tests/rspec.rb
rr-3.0.1 spec/support/adapter_tests/rspec.rb
rr-3.0.0 spec/support/adapter_tests/rspec.rb
rr-1.2.1 spec/support/adapter_tests/rspec.rb
rr-1.2.0 spec/support/adapter_tests/rspec.rb