Sha256: 7d7ed9e99d3a3a8c343dc1d3ca760d366fbb564efb85801113661d557b9522c5
Contents?: true
Size: 862 Bytes
Versions: 2
Compression:
Stored size: 862 Bytes
Contents
= Quarry's Stubbing Facility Require stub.rb library. require 'quarry/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" Apply 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_stub(@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_stub # imples obj.remove_stub(obj.stub) obj.upcase.assert == "HEY"
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
quarry-0.5.0 | spec/stub.rd |
quarry-0.5.2 | spec/03_stub.rd |