nala 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1de5be775b1e14835cc70a4e7a8b0068f13caa9d
4
- data.tar.gz: 555a05e4158913607cc7b5ff1a8c54b734c89cf4
3
+ metadata.gz: cdba579249251211672cfe2194920064d8c347a5
4
+ data.tar.gz: def872611eadb7bfc924939c4a51792562b50eed
5
5
  SHA512:
6
- metadata.gz: 061bf9c1b1ca1b18f16dc5d08753261929365028bca2d84210a4d711f0297e5e659e4396daf352123777a96dcba81c4e15232f0348dc8a14db9b5b5dbd376a9d
7
- data.tar.gz: c9ec24f01a7055c227afde5bdbf325b6e590f64e1a659363f08781e6ea985fc91f5a54c212f14d7e5668585303be15d8ca4b2612f8706b6175a96145986c0e82
6
+ metadata.gz: 25eca85f93b3b66134ee9ec135eb0842424c349cc6e67bd961564bc16237fc8aad3c08d709d959a933c5ede12f872eb38d1af2046a2715c2220e976a36264484
7
+ data.tar.gz: 0052b8685f00185a3ca665aa945c060e9e2aafb9cf3d4a9f68a5f182f3b6ad059205de47b285372611005147ff57de99b880613948d8ef4d78bee2c1d454baf5
data/lib/nala/rspec.rb CHANGED
@@ -21,6 +21,10 @@ module Nala
21
21
  def called?
22
22
  @called
23
23
  end
24
+
25
+ def spy
26
+ proc { |*args| called_with!(args) }
27
+ end
24
28
  end
25
29
  end
26
30
 
data/lib/nala/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nala
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/readme.md CHANGED
@@ -18,11 +18,13 @@ gem "nala"
18
18
 
19
19
  ## Usage
20
20
 
21
- Nala is intended to be used with use case style classes where the class performs a
22
- single action. These classes typically have verb names such as `PlaceOrder` etc.
21
+ Nala is intended to be used with use case style classes where the class performs
22
+ a single action. These classes typically have verb names such as `PlaceOrder`
23
+ etc.
23
24
 
24
25
  To use, add the `Nala::Publisher` module to your class and expose a `call`
25
- instance method. If your class requires data, it can be passed to it via the constructor.
26
+ instance method. If your class requires data, it can be passed to it via the
27
+ constructor.
26
28
 
27
29
  For example:
28
30
 
@@ -46,9 +48,9 @@ class PlaceOrder
46
48
  end
47
49
  ```
48
50
 
49
- Usage of these use case style classes gives a home to your business logic, removes
50
- conditionals from your Rails controllers and helps prevent your models getting too
51
- big.
51
+ Usage of these use case style classes gives a home to your business logic,
52
+ removes conditionals from your Rails controllers and helps prevent your models
53
+ getting too big.
52
54
 
53
55
  ```ruby
54
56
  class OrderController < ApplicationController
@@ -83,13 +85,15 @@ end
83
85
 
84
86
  ## Testing with RSpec
85
87
 
86
- If you are using RSpec then you can use the supplied matcher by adding the following line to your `spec_helper.rb` file:
88
+ If you are using RSpec then you can use the supplied matcher by adding the
89
+ following line to your `spec_helper.rb` file:
87
90
 
88
91
  ```ruby
89
92
  require "nala/rspec"
90
93
  ```
91
94
 
92
- Then within your specs, you can confirm that a handler is called with the following:
95
+ Then within your specs, you can confirm that a handler is called with the
96
+ following:
93
97
 
94
98
  ```ruby
95
99
  let(:block) { Nala::BlockSpy.new }
@@ -101,36 +105,56 @@ it "invokes a handler for a published event" do
101
105
  end
102
106
  ```
103
107
 
104
- If you want to check the arguments that are passed to the block you can use the following:
108
+ If you want to check the arguments that are passed to the block you can use the
109
+ following:
105
110
 
106
111
  ```ruby
107
112
  let(:block) { Nala::BlockSpy.new }
108
113
 
109
114
  it "passes multiple arguments to handlers" do
110
115
  PublishArgsClass.call
111
- .on(:multiple) { |*x| block.called_with!(x) }
116
+ .on(:multiple) { |*args| block.called_with!(args) }
112
117
 
113
118
  expect(block).to be_called_with(:a, :b, :c)
114
119
  end
115
120
  ```
116
121
 
117
- If you need check the arguments attributes in more detail you can do the following:
122
+ If you need check the arguments attributes in more detail you can do the
123
+ following:
118
124
 
119
125
  ```ruby
120
126
  let(:block) { Nala::BlockSpy.new }
121
127
 
122
128
  it "passes a user with the correct name" do
123
129
  RegisterUser.call
124
- .on(:success) { |*x| block.called_with!(x) }
130
+ .on(:success) { |*args| block.called_with!(args) }
125
131
 
126
132
  user = block.args.first
127
133
  expect(user.name).to eq("Andy")
128
134
  end
129
135
  ```
130
136
 
131
- ## Building a publishing gem updates
137
+ You can make the tracking of block arguments less verbose by using the `spy`
138
+ method of `Nala::BlockSpy` and passing it as an explicit block to the `on`
139
+ method:
132
140
 
133
- Bump the version number in `lib/nala/version.rb` and use the same number in the command below:
141
+ ```ruby
142
+ let(:block) { Nala::BlockSpy.new }
143
+
144
+ it "passes multiple arguments to handlers" do
145
+ PublishArgsClass.call
146
+ .on(:multiple, &block.spy)
147
+
148
+ expect(block).to be_called_with(:a, :b, :c)
149
+ end
150
+ ```
151
+
152
+ ## Notes for maintainers
153
+
154
+ **Building a publishing gem updates**
155
+
156
+ Bump the version number in `lib/nala/version.rb` and use the same number in the
157
+ command below:
134
158
 
135
159
  ```
136
160
  gem build nala.gemspec
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.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Pike