Sha256: b39ca0d7048d5dc16875581b40b8dcc6a7946e023737ef587e54e1ab88530995

Contents?: true

Size: 658 Bytes

Versions: 2

Compression:

Stored size: 658 Bytes

Contents

= Quarry's Mocking Facility

Require mock.rb library.

  require 'quarry/mock'

== Delegation Approach

  obj = "hello"

  @mck = Quarry::Mock.new

  @mck.upcase == "HeLLo"

  alt = obj.mock(@mck)

  expect(Assertion){ alt.upcase }

  obj.upcase.assert == "HELLO"

== Singleton Approach

  obj = "hi"

  obj.extend(@mck)

  @mck.upcase == "hI"

  expect(Assertion){ obj.upcase }

  obj.remove_mock(@mck)

  obj.upcase.assert == "HI"

== Quick Extend Mocks

  obj = "hey"

  # implict obj.extend(obj.mock) here
  obj.mock.upcase == "HeY"

  expect(Assertion){ obj.upcase }

  obj.remove_mock  # imples obj.remove_stub(obj.mock)

  obj.upcase.assert == "HEY"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quarry-0.5.0 spec/mock.rd
quarry-0.5.2 spec/04_mock.rd