|
138 | 138 | end |
139 | 139 |
|
140 | 140 | describe 'can fetch a task' do |
141 | | - let(:expected_body) { |
142 | | - { 'guid': 'foo' }.to_json |
143 | | - } |
144 | | - |
145 | | - before(:each) do |
146 | | - stub_request(:get, "#{opi_url}/tasks/some-task-guid"). |
147 | | - to_return(status: 200, body: expected_body) |
148 | | - end |
149 | | - |
150 | | - it 'should return a parsed task' do |
151 | | - task = client.fetch_task('some-task-guid') |
152 | | - |
153 | | - expect(WebMock).to have_requested(:get, "#{opi_url}/tasks/some-task-guid") |
154 | | - |
155 | | - expect(task).to eq(OpenStruct.new(task_guid: 'foo')) |
156 | | - end |
157 | | - |
158 | | - context 'when the task is not found' do |
159 | | - before(:each) do |
160 | | - stub_request(:get, "#{opi_url}/tasks/some-task-guid"). |
161 | | - to_return(status: 404) |
162 | | - end |
163 | | - |
164 | | - it 'should return nil' do |
165 | | - expect(client.fetch_task('some-task-guid')).to be_nil |
166 | | - end |
| 141 | + it 'should return a empty dummy task' do |
| 142 | + task = client.fetch_task('some-guid') |
| 143 | + expect(task).to eq(Diego::Bbs::Models::Task.new) |
167 | 144 | end |
168 | 145 |
|
169 | | - context 'when fetching the task fails' do |
170 | | - before(:each) do |
171 | | - stub_request(:get, "#{opi_url}/tasks/some-task-guid"). |
172 | | - to_return(status: 500) |
173 | | - end |
174 | | - |
175 | | - it 'should raise an ApiError' do |
176 | | - expect { client.fetch_task('some-task-guid') }.to raise_error(CloudController::Errors::ApiError, /response status code: 500/) do |e| |
177 | | - expect(e.name).to eq('TaskError') |
178 | | - end |
179 | | - end |
| 146 | + it 'should not send any request to opi' do |
| 147 | + expect(a_request(:any, opi_url)).not_to have_been_made |
180 | 148 | end |
181 | 149 | end |
182 | 150 |
|
183 | 151 | describe 'can fetch all tasks' do |
184 | | - let(:expected_body) { |
185 | | - [{ 'guid': 'foo' }, { 'guid': 'bar' }].to_json |
186 | | - } |
187 | | - |
188 | | - before(:each) do |
189 | | - stub_request(:get, "#{opi_url}/tasks"). |
190 | | - to_return(status: 200, body: expected_body) |
191 | | - end |
192 | | - |
193 | | - it 'should return a parsed list of tasks' do |
| 152 | + it 'should return an empty list' do |
194 | 153 | tasks = client.fetch_tasks |
195 | | - |
196 | | - expect(WebMock).to have_requested(:get, "#{opi_url}/tasks") |
197 | | - |
198 | | - expect(tasks).to match_array([ |
199 | | - OpenStruct.new(task_guid: 'foo'), |
200 | | - OpenStruct.new(task_guid: 'bar'), |
201 | | - ]) |
| 154 | + expect(tasks).to be_empty |
202 | 155 | end |
203 | 156 |
|
204 | | - context 'when fetching the tasks fails' do |
205 | | - before(:each) do |
206 | | - stub_request(:get, "#{opi_url}/tasks"). |
207 | | - to_return(status: 500) |
208 | | - end |
209 | | - |
210 | | - it 'should raise an ApiError' do |
211 | | - expect { client.fetch_tasks }.to raise_error(CloudController::Errors::ApiError, /response status code: 500/) do |e| |
212 | | - expect(e.name).to eq('TaskError') |
213 | | - end |
214 | | - end |
| 157 | + it 'should not send any request to opi' do |
| 158 | + expect(a_request(:any, opi_url)).not_to have_been_made |
215 | 159 | end |
216 | 160 | end |
217 | 161 |
|
|
0 commit comments