nala 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e24b33814fd472cb82c0a1df0245dd50bca407cc
4
- data.tar.gz: 7acae49d029d2c69fb61777de30f37384f0b3bb5
3
+ metadata.gz: 10e423acb67e8578fc4b9c652b138b9b1979dce6
4
+ data.tar.gz: 85e858c8451d9ef09346981ccee760dbc804e140
5
5
  SHA512:
6
- metadata.gz: 1c9e49b94f37ac4f107781016db0b19851c3e02e7aaad1dc71b99fba3f490a8e45e28eb7de98641d63f3a380c12369a908e63d3cf68e1d1c38e77168c831aa0b
7
- data.tar.gz: ea4cf4ed1e5a030634c77847b93fbd214c66a072f6d26ebf7c25acad960e828972ceea4018414620eb5f4f1c157726dbca8633c486f345c446f5678f6b502897
6
+ metadata.gz: 35dcef02bab31d9ca81df1a6ef999731ec10f58cf388f1b27d10fbd7a5cfc912e2788f17656ee54cbd8cc158dcc3e4c871dc66913bf9a9c1d2e0c7eb00df8690
7
+ data.tar.gz: ba908b8cd78c9d0d3f14d04a8bc698c9b8dff44128250c8fde68a4387cf6c20f86bfc60c7f0d40d7c6440f38e38a846e8a904aae338691db3f80e09d04c54647
@@ -26,6 +26,22 @@ module Nala
26
26
  proc { |*args| called_with!(args) }
27
27
  end
28
28
  end
29
+
30
+ module RSpecHelpers
31
+ def emit(event, *args)
32
+ Nala::EventEmitter.new.tap do |emitter|
33
+ emitter.store_result(event, args)
34
+ end
35
+ end
36
+
37
+ def block_spy
38
+ Nala::BlockSpy.new
39
+ end
40
+ end
41
+ end
42
+
43
+ RSpec.configure do |config|
44
+ config.include Nala::RSpecHelpers
29
45
  end
30
46
 
31
47
  RSpec::Matchers.define :be_called_with do |*expected_args|
@@ -1,3 +1,3 @@
1
1
  module Nala
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/readme.md CHANGED
@@ -106,7 +106,7 @@ Then within your specs, you can confirm that a handler is called with the
106
106
  following:
107
107
 
108
108
  ```ruby
109
- let(:block) { Nala::BlockSpy.new }
109
+ let(:block) { block_spy }
110
110
 
111
111
  it "invokes a handler for a published event" do
112
112
  SuccessClass.call.on(:success) { block.called! }
@@ -119,7 +119,7 @@ If you want to check the arguments that are passed to the block you can use the
119
119
  following:
120
120
 
121
121
  ```ruby
122
- let(:block) { Nala::BlockSpy.new }
122
+ let(:block) { block_spy }
123
123
 
124
124
  it "passes multiple arguments to handlers" do
125
125
  PublishArgsClass.call
@@ -133,7 +133,7 @@ If you need check the arguments attributes in more detail you can do the
133
133
  following:
134
134
 
135
135
  ```ruby
136
- let(:block) { Nala::BlockSpy.new }
136
+ let(:block) { block_spy }
137
137
 
138
138
  it "passes a user with the correct name" do
139
139
  RegisterUser.call
@@ -145,11 +145,10 @@ end
145
145
  ```
146
146
 
147
147
  You can make the tracking of block arguments less verbose by using the `spy`
148
- method of `Nala::BlockSpy` and passing it as an explicit block to the `on`
149
- method:
148
+ method of `Nala::BlockSpy` (which `block_spy` returns) and passing it as an explicit block to the `on` method:
150
149
 
151
150
  ```ruby
152
- let(:block) { Nala::BlockSpy.new }
151
+ let(:block) { block_spy }
153
152
 
154
153
  it "passes multiple arguments to handlers" do
155
154
  PublishArgsClass.call.on(:multiple, &block.spy)
@@ -163,8 +162,8 @@ recommend naming your block after the event it will be called by (rather than
163
162
  just `block`):
164
163
 
165
164
  ```ruby
166
- let(:success) { Nala::BlockSpy.new }
167
- let(:notified) { Nala::BlockSpy.new }
165
+ let(:success) { block_spy }
166
+ let(:notified) { block_spy }
168
167
 
169
168
  it "calls multiple handlers" do
170
169
  PlaceOrder.call
@@ -176,6 +175,18 @@ it "calls multiple handlers" do
176
175
  end
177
176
  ```
178
177
 
178
+ If you would like to stub calls to the `.call` method of your use case class but want to make sure handlers are called, you can use the supplied `emit` helper method like so:
179
+
180
+ ```
181
+ allow(SuccessClass).to receive(:call) { emit(:success) }
182
+ ```
183
+
184
+ or you can supply arguments to the block:
185
+
186
+ ```
187
+ allow(SuccessClass).to receive(:call) { emit(:success, "My Argument") }
188
+ ```
189
+
179
190
  ## Notes for maintainers
180
191
 
181
192
  **Building a publishing gem updates**
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nala
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Pike