Sha256: 15933b3685e2cd873c422f4653d490f65c30d9d29847d362c54bc3bffd8317b8
Contents?: true
Size: 854 Bytes
Versions: 1
Compression:
Stored size: 854 Bytes
Contents
= Quarry's Stubbing Facility Require stub.rb library. require 'quarry/stub/stub' == Delegation Approach We will stub-out a simple string. obj = "hello" We can create a reusable stub module. @stb = Quarry::Stub.new @stb.upcase == "HeLLo" Appy the stub module to the object we want to stub. alt = obj.stub(@stb) And get teh newly stubbed output. alt.upcase.assert == "HeLLo" Teh original is still intact. obj.upcase.assert == "HELLO" == Singleton Approach obj = "hi" obj.extend(@stb) @stb.upcase == "hI" obj.upcase.assert == "hI" obj.remove(@stb) obj.upcase.assert == "HI" == Quick Extend Stubs obj = "hey" # implict obj.extend(obj.stub) here obj.stub.upcase == "HeY" obj.upcase.assert == "HeY" obj.remove # imples obj.remove(obj.stub) obj.upcase.assert == "HEY" QED.
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quarry-0.4.0 | spec/stub.rd |