micro_mock 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +10 -0
- data/lib/micro_mock/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -20,6 +20,9 @@ MyMock = MicroMock.make
|
|
20
20
|
# add a class attr
|
21
21
|
MyMock.attr(:foo)
|
22
22
|
|
23
|
+
# add a class attr with a default value
|
24
|
+
MyMock.attr(:attr_with_default, "Class value")
|
25
|
+
|
23
26
|
# stub a class method
|
24
27
|
MyMock.stub(:say_foo) { |arg| "#{foo} #{arg}!" }
|
25
28
|
|
@@ -29,13 +32,20 @@ mock = MyMock.new
|
|
29
32
|
# add an instance attr
|
30
33
|
mock.attr(:bar)
|
31
34
|
|
35
|
+
# add an instance attr with a default value
|
36
|
+
mock.attr(:attr_with_default, "Instance value")
|
37
|
+
|
32
38
|
# stub some instance methods
|
33
39
|
mock.stub(:say_bar) { |arg| "#{bar} #{arg}!" }
|
34
40
|
|
35
41
|
# use the mock
|
42
|
+
MyMock.attr_with_default # => "Class value"
|
43
|
+
MyMock.foo # => nil
|
36
44
|
MyMock.foo = :foo
|
37
45
|
MyMock.say_foo :bar # => "foobar!"
|
38
46
|
|
47
|
+
mock.attr_with_default # => "Instance value"
|
48
|
+
mock.bar # => nil
|
39
49
|
mock.bar = :bar
|
40
50
|
mock.say_bar :foo # => "barfoo!"
|
41
51
|
```
|
data/lib/micro_mock/version.rb
CHANGED