nala 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/lib/nala/rspec.rb +6 -3
- data/lib/nala/version.rb +1 -1
- data/readme.md +20 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d87e064fd811730de41a3619632242a9059d5c3c
|
4
|
+
data.tar.gz: 69c65044ee82f3b3844faaafefff09d773a80f9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1c78d8c10c6a0e5fc2099eefc65ddbc138a8b729c68d17c6c44e03561143e0e47e5edd7e1f51742a1041fb037e609df03184f067b4496aa4cd9fb287ef795bf
|
7
|
+
data.tar.gz: ae16065d973d70d209fb9aa1b874d0b0572e9dec94513660fa15d36c977c07d9e5960f0f8449520567511c203862bfe066f627813037cea6c6fae80b9523e8c4
|
data/lib/nala/rspec.rb
CHANGED
@@ -6,7 +6,7 @@ module Nala
|
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
@called = false
|
9
|
-
@args
|
9
|
+
@args = []
|
10
10
|
end
|
11
11
|
|
12
12
|
def called!
|
@@ -19,7 +19,7 @@ module Nala
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def called?
|
22
|
-
|
22
|
+
called
|
23
23
|
end
|
24
24
|
|
25
25
|
def spy
|
@@ -36,6 +36,9 @@ RSpec::Matchers.define :be_called_with do |*expected_args|
|
|
36
36
|
failure_message do |block|
|
37
37
|
return "expected the block to be called but it was not" unless block.called?
|
38
38
|
|
39
|
-
|
39
|
+
%(
|
40
|
+
expected the block to be called with the arguments
|
41
|
+
#{expected_args.inspect} but it was called with #{block.args.inspect}
|
42
|
+
).strip.squeeze(" ").delete("\n")
|
40
43
|
end
|
41
44
|
end
|
data/lib/nala/version.rb
CHANGED
data/readme.md
CHANGED
@@ -66,7 +66,7 @@ class OrderController < ApplicationController
|
|
66
66
|
end
|
67
67
|
```
|
68
68
|
|
69
|
-
This comes in handy when there are more than two
|
69
|
+
This comes in handy when there are more than two outcomes to a use case:
|
70
70
|
|
71
71
|
```ruby
|
72
72
|
class RegistrationController < ApplicationController
|
@@ -142,13 +142,30 @@ method:
|
|
142
142
|
let(:block) { Nala::BlockSpy.new }
|
143
143
|
|
144
144
|
it "passes multiple arguments to handlers" do
|
145
|
-
PublishArgsClass.call
|
146
|
-
.on(:multiple, &block.spy)
|
145
|
+
PublishArgsClass.call.on(:multiple, &block.spy)
|
147
146
|
|
148
147
|
expect(block).to be_called_with(:a, :b, :c)
|
149
148
|
end
|
150
149
|
```
|
151
150
|
|
151
|
+
You can of course spy on multiple blocks in a single spec if you need to. We
|
152
|
+
recommend naming your block after the event it will be called by (rather than
|
153
|
+
just `block`):
|
154
|
+
|
155
|
+
```ruby
|
156
|
+
let(:success) { Nala::BlockSpy.new }
|
157
|
+
let(:notified) { Nala::BlockSpy.new }
|
158
|
+
|
159
|
+
it "passes multiple arguments to handlers" do
|
160
|
+
PlaceOrder.call
|
161
|
+
.on(:success, &success.spy)
|
162
|
+
.on(:notified, ¬ified.spy)
|
163
|
+
|
164
|
+
expect(success).to be_called_with(order)
|
165
|
+
expect(notified).to be_called_with(:email)
|
166
|
+
end
|
167
|
+
```
|
168
|
+
|
152
169
|
## Notes for maintainers
|
153
170
|
|
154
171
|
**Building a publishing gem updates**
|