Sha256: 5b08be27348dba8fdd8c1aecfd00aec46d2d64ed931498d6469694c3990824ee

Contents?: true

Size: 481 Bytes

Versions: 4

Compression:

Stored size: 481 Bytes

Contents

module RSpecCandy
  module Helpers
    module StubAnyInstance

      def stub_any_instance(stubs)
        case Switcher.rspec_version
        when 1
          unstubbed_new = method(:new)
          stub(:new).and_return do |*args|
            unstubbed_new.call(*args).tap do |obj|
              obj.stub stubs
            end
          end
          stubs
        else
          any_instance.stub(stubs)
        end
      end

      Class.send(:include, self)

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec_candy-0.5.1 lib/rspec_candy/helpers/stub_any_instance.rb
rspec_candy-0.5.0 lib/rspec_candy/helpers/stub_any_instance.rb
rspec_candy-0.4.1 lib/rspec_candy/helpers/stub_any_instance.rb
rspec_candy-0.4.0 lib/rspec_candy/helpers/stub_any_instance.rb