README.md in much-stub-0.1.7 vs README.md in much-stub-0.1.8

- old
+ new

@@ -14,19 +14,20 @@ ## Usage ```ruby # Given this object/API -my_class = Class.new do - def my_method - "my-method" - end +my_class = + Class.new do + def my_method + "my-method" + end - def my_value(value) - value + def my_value(value) + value + end end -end my_object = my_class.new my_object.my_method # => "my-method" my_object.my_value(123) @@ -93,19 +94,20 @@ ### Stubs for spying ```ruby # Given this object/API -my_class = Class.new do - def basic_method(value) - value - end +my_class = + Class.new do + def basic_method(value) + value + end - def iterator_method(items, &block) - items.each(&block) + def iterator_method(items, &block) + items.each(&block) + end end -end my_object = my_class.new # Store method call arguments/blocks for spying. basic_method_called_with = nil @@ -187,15 +189,16 @@ ### Stubs for test doubles. ```ruby # Given this object/API ... -my_class = Class.new do - def build_thing(thing_value); - Thing.new(value) +my_class = + Class.new do + def build_thing(thing_value); + Thing.new(value) + end end -end my_object = my_class.new # ... and this Test Double. class FakeThing attr_reader :built_with @@ -221,15 +224,16 @@ Use the `.tap` method to spy on method calls while preserving the original method return value and behavior. ```ruby # Given this object/API -my_class = Class.new do - def basic_method(value) - value.to_s +my_class = + Class.new do + def basic_method(value) + value.to_s + end end -end my_object = my_class.new # Normal stubs override the original behavior and return value... basic_method_called_with = nil MuchStub.(my_object, :basic_method) { |*args| @@ -273,15 +277,16 @@ def initialize(value) @value = value end end -my_class = Class.new do - def thing(value) - Thing.new(value) +my_class = + Class.new do + def thing(value) + Thing.new(value) + end end -end my_object = my_class.new # Use `MuchStub.tap` to stub any thing instances created by `my_object.thing` # (and also spy on the call arguments) @@ -304,19 +309,19 @@ Use the `.spy` method to spy on method calls. This is especially helpful for spying on _chained_ method calls. ```ruby # Given this object/API -myclass = Class.new do - def one; self; end - def two(val); self; end - def three; self; end - def ready?; false; end -end +myclass = + Class.new do + def one; self; end + def two(val); self; end + def three; self; end + def ready?; false; end + end myobj = myclass.new -spy = - MuchStub.spy(myobj :one, :two, :three, ready?: true) +spy = MuchStub.spy(myobj :one, :two, :three, ready?: true) assert_equal spy, myobj.one assert_equal spy, myobj.two("a") assert_equal spy, myobj.three