tzu_mock 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tzu_mock/class_methods.rb +1 -1
- data/lib/tzu_mock/mocker.rb +1 -0
- data/spec/tzu_mock_spec.rb +38 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b40c2156219f3cfc8999af245f2ae622f440d667
|
4
|
+
data.tar.gz: cd0617ab6631d769609f1bd191d07402ba69c1ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2be08f3868d3d17d1a596a551e446e83bf0f65ce48191534855306dfde0b4ae888ab1112bdcaa84e815ecc7433ed409a572f9b0d4efc4b2dcdd5076519200f5b
|
7
|
+
data.tar.gz: 153168acbfa9f3e9c9ebd9ca8bef116d5d9392b282bd761e2ced532fbafb250f290a0a73376b442bfb26fd7ae70380391d581cf4994e1944d696fdf90530adce
|
@@ -10,7 +10,7 @@ module TzuMock
|
|
10
10
|
# Call TzuMock#success, TzuMock#invalid, or TzuMock#failure instead
|
11
11
|
rspec_context = binding.of_caller(2).eval('self')
|
12
12
|
|
13
|
-
Mocker.new(type, klass, rspec_context, method)
|
13
|
+
Mocker.new(type, klass, rspec_context, method).mock
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/lib/tzu_mock/mocker.rb
CHANGED
data/spec/tzu_mock_spec.rb
CHANGED
@@ -132,4 +132,42 @@ describe TzuMock do
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
end
|
135
|
+
|
136
|
+
context 'TzuMock receive no return result' do
|
137
|
+
context 'success' do
|
138
|
+
before { TzuMock.success(UpdateUser) }
|
139
|
+
|
140
|
+
let(:outcome) { UpdateUser.run!(params) }
|
141
|
+
|
142
|
+
it 'mocks a successful outcome and allows parameters to be verified' do
|
143
|
+
expect(outcome.success?).to be true
|
144
|
+
expect(outcome.type).to be nil
|
145
|
+
expect(UpdateUser).to have_received(:run!).with(params)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context 'invalid' do
|
150
|
+
before { TzuMock.invalid(UpdateUser) }
|
151
|
+
|
152
|
+
let(:outcome) { UpdateUser.run!(params) }
|
153
|
+
|
154
|
+
it 'mocks an invalid outcome and allows parameters to be verified' do
|
155
|
+
expect(outcome.success?).to be false
|
156
|
+
expect(outcome.type).to eq :validation
|
157
|
+
expect(UpdateUser).to have_received(:run!).with(params)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
context 'failure' do
|
162
|
+
before { TzuMock.failure(UpdateUser) }
|
163
|
+
|
164
|
+
let(:outcome) { UpdateUser.run(params) }
|
165
|
+
|
166
|
+
it 'mocks a failed outcome and allows parameters to be verified' do
|
167
|
+
expect(outcome.success?).to be false
|
168
|
+
expect(outcome.type).to eq :execution
|
169
|
+
expect(UpdateUser).to have_received(:run).with(params)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
135
173
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tzu_mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Turner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: binding_of_caller
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
103
|
+
rubygems_version: 2.4.3
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: TDD with Tzu!
|