Sha256: 9ba5c9c617a892f7001f58bf4bdbfe1ab86cc49a9afd4df5e441ded0a6873839

Contents?: true

Size: 1.42 KB

Versions: 29

Compression:

Stored size: 1.42 KB

Contents

module RR
  module Adapters
    module Rspec
      def self.included(mod)
        patterns = ::Spec::Runner::QuietBacktraceTweaker::IGNORE_PATTERNS
        unless patterns.include?(RR::Errors::BACKTRACE_IDENTIFIER)
          patterns.push(RR::Errors::BACKTRACE_IDENTIFIER)
        end
      end

      include RRMethods
      def setup_mocks_for_rspec
        RR.reset
      end
      def verify_mocks_for_rspec
        RR.verify
      end
      def teardown_mocks_for_rspec
        RR.reset
      end

      def have_received(method = nil)
        InvocationMatcher.new(method)
      end

      class InvocationMatcher < SpyVerificationProxy
        attr_reader :failure_message, :spy_verification_proxy
 
        def initialize(method = nil)
          @verification = nil
          @subject = nil
          method_missing(method) if method
        end

        def matches?(subject)
          @verification.subject = subject
          calls = RR::Space.instance.recorded_calls
          if error = calls.match_error(@verification)
            @failure_message = error.message
            false
          else
            true
          end
        end

        def nil?
          false
        end

        def method_missing(method_name, *args, &block)
          if @verification
            @verification.send(method_name, *args)
          else
            @verification = super
          end
          self
        end
      end
    end
  end
end

Version data entries

29 entries across 25 versions & 5 rubygems

Version Path
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/adapters/rspec.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/adapters/rspec.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/adapters/rspec.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/adapters/rspec.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/adapters/rspec.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/adapters/rspec.rb
bitclust-core-0.5.1 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/adapters/rspec.rb
mcmire-rr-1.0.5.rc1 lib/rr/adapters/rspec.rb
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/rr-1.0.2/lib/rr/adapters/rspec.rb
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/rr-1.0.2/lib/rr/adapters/rspec.rb
rr-1.0.4 lib/rr/adapters/rspec.rb
rr-1.0.3 lib/rr/adapters/rspec.rb
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/adapters/rspec.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/adapters/rspec.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/adapters/rspec.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/adapters/rspec.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/adapters/rspec.rb
vim-jar-0.0.2 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/adapters/rspec.rb
vim-jar-0.0.1 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/adapters/rspec.rb
rr-1.0.2 lib/rr/adapters/rspec.rb