grasshopper 0.3.0 → 0.4.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.
Files changed (3) hide show
  1. data/README.md +10 -1
  2. data/lib/grasshopper.rb +8 -0
  3. metadata +2 -2
data/README.md CHANGED
@@ -8,7 +8,7 @@ For more examples, see the [unit tests](https://github.com/mattraibert/grasshopp
8
8
 
9
9
  ### Mock
10
10
 
11
- Mock is a person who listens carefully but never says anything. You say anything to Mock, but you'll only get crickets back.
11
+ Mock is a person who listens carefully but never says anything. You can say anything to Mock, but you'll only get crickets back.
12
12
 
13
13
  ```ruby
14
14
  mock = Mock.new
@@ -31,6 +31,15 @@ stub.money("gimmie") #=> 5
31
31
  stub.monkey #=> nil
32
32
  ```
33
33
 
34
+ or you can use this shorter syntax if you prefer:
35
+
36
+ ```ruby
37
+ Stub.like(:keys => [:door_key, :mail_key], :money => 5)
38
+ stub.keys #=> [:door_key, :mail_key]
39
+ stub.money("gimmie") #=> 5
40
+ stub.monkey #=> nil
41
+ ```
42
+
34
43
  ## Naming
35
44
 
36
45
  Grasshopper is named for a [restaurant](http://grasshoppervegan.com/) in Allston, MA that serves up all sorts of great mocks.
data/lib/grasshopper.rb CHANGED
@@ -53,4 +53,12 @@ class Stub
53
53
  @@message = [sym, args]
54
54
  @stubs[[sym, args]]
55
55
  end
56
+
57
+ def self.like(stubs)
58
+ stub = Stub.new
59
+ stubs.each do |method, retval|
60
+ Stub.when(stub.send(method)).then_return(retval)
61
+ end
62
+ stub
63
+ end
56
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grasshopper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -101,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  segments:
103
103
  - 0
104
- hash: 504949561135609211
104
+ hash: -2097041632477700683
105
105
  required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements: