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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a623fe290d3bf0e2ecaeda8f7891272261115576
4
- data.tar.gz: 5408759d91670c24cd7e3660f60ea83ac7fd9b5f
3
+ metadata.gz: b40c2156219f3cfc8999af245f2ae622f440d667
4
+ data.tar.gz: cd0617ab6631d769609f1bd191d07402ba69c1ec
5
5
  SHA512:
6
- metadata.gz: ec7f5e5796be2ec05e37b94138d8e9cf66712e9fe989727dedb4da04688d7d2cc8477c35b3321216c71ba2c71fd7671c478db406bdd822f844ee783680d95e96
7
- data.tar.gz: 85e762fa6f101ae45d7fbcf540cb3ed0ea7f08a8d4bcc2f305ac36bb68b73a39e9bf2bab705c89d7ca3d6e8f0944d2fd73c0317aed6b2e3153f431df2bd89f3f
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
@@ -6,6 +6,7 @@ module TzuMock
6
6
 
7
7
  def mock
8
8
  @rspec_context.instance_eval(&mock_proc(@klass, mock_methods, success?, @result, error_type))
9
+ self
9
10
  end
10
11
 
11
12
  def returns(result)
@@ -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.0.0
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-07-12 00:00:00.000000000 Z
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.2.2
103
+ rubygems_version: 2.4.3
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: TDD with Tzu!