|
1 |
| -RSpec.shared_context 'Use stubs for Faraday' do |
2 |
| - let(:connpass_response) do |
3 |
| - [ |
4 |
| - 200, |
5 |
| - { 'Content-Type' => 'application/json' }, |
6 |
| - '{"results_returned": 1, "events": [{"event_url": "https://coderdojo-okutama.connpass.com/event/12345/", "event_type": "participation", "owner_nickname": "nalabjp", "series": {"url": "https://coderdojo-okutama.connpass.com/", "id": 9876, "title": "CoderDojo series"}, "updated_at": "2017-04-29T14:59:30+09:00", "lat": "35.801763000000", "started_at": "2017-05-07T10:00:00+09:00", "hash_tag": "CoderDojo", "title": "CoderDojo title", "event_id": 12345, "lon": "139.087656000000", "waiting": 2, "limit": 10, "owner_id": 2525, "owner_display_name": "nalabjp", "description": "CoderDojo description", "address": "Okutama-cho Tokyo", "catch": "CoderDojo catch", "accepted": 10, "ended_at": "2017-05-07T12:00:00+09:00", "place": "Tokyo"}], "results_start": 200, "results_available": 518}' |
7 |
| - ] |
8 |
| - end |
9 |
| - |
10 |
| - let(:doorkeeper_response) do |
11 |
| - [ |
12 |
| - 200, |
13 |
| - { 'Content-Type' => 'application/json' }, |
14 |
| - '[{"event":{"title":"CoderDojo title","id":1234,"starts_at":"2017-05-28T01:00:00.000Z","ends_at":"2017-05-28T04:00:00.000Z","venue_name":"奥多摩町","address":"奥多摩町","lat":"35.801763000000","long":"139.087656000000","ticket_limit":30,"published_at":"2017-04-22T03:43:04.000Z","updated_at":"2017-05-10T11:31:21.810Z","group":5555,"banner":null,"description":"CoderDojo description","public_url":"https://coderdojo-okutama.doorkeeper.jp/events/8888","participants":12,"waitlisted":0}}]' |
15 |
| - ] |
16 |
| - end |
17 |
| - |
| 1 | +RSpec.shared_context 'Use stub connection of Faraday' do |
18 | 2 | let(:stub_connection) do
|
19 | 3 | Faraday.new do |f|
|
20 | 4 | f.response :json, :content_type => /\bjson$/
|
|
33 | 17 | allow_any_instance_of(Statistics::Client).to receive(:connection_for).and_return(stub_connection)
|
34 | 18 | end
|
35 | 19 | end
|
| 20 | + |
| 21 | +RSpec.shared_context 'Use stubs for Connpass' do |
| 22 | + include_context 'Use stub connection of Faraday' |
| 23 | + |
| 24 | + let(:connpass_response) do |
| 25 | + [ |
| 26 | + 200, |
| 27 | + { 'Content-Type' => 'application/json' }, |
| 28 | + '{"results_returned": 1, "events": [{"event_url": "https://coderdojo-okutama.connpass.com/event/12345/", "event_type": "participation", "owner_nickname": "nalabjp", "series": {"url": "https://coderdojo-okutama.connpass.com/", "id": 9876, "title": "CoderDojo series"}, "updated_at": "2017-04-29T14:59:30+09:00", "lat": "35.801763000000", "started_at": "2017-05-07T10:00:00+09:00", "hash_tag": "CoderDojo", "title": "CoderDojo title", "event_id": 12345, "lon": "139.087656000000", "waiting": 2, "limit": 10, "owner_id": 2525, "owner_display_name": "nalabjp", "description": "CoderDojo description", "address": "Okutama-cho Tokyo", "catch": "CoderDojo catch", "accepted": 10, "ended_at": "2017-05-07T12:00:00+09:00", "place": "Tokyo"}], "results_start": 200, "results_available": 518}' |
| 29 | + ] |
| 30 | + end |
| 31 | +end |
| 32 | + |
| 33 | +RSpec.shared_context 'Use stubs for Doorkeeper' do |
| 34 | + include_context 'Use stub connection of Faraday' |
| 35 | + |
| 36 | + let(:doorkeeper_response) do |
| 37 | + [ |
| 38 | + 200, |
| 39 | + { 'Content-Type' => 'application/json' }, |
| 40 | + '[{"event":{"title":"CoderDojo title","id":1234,"starts_at":"2017-05-28T01:00:00.000Z","ends_at":"2017-05-28T04:00:00.000Z","venue_name":"奥多摩町","address":"奥多摩町","lat":"35.801763000000","long":"139.087656000000","ticket_limit":30,"published_at":"2017-04-22T03:43:04.000Z","updated_at":"2017-05-10T11:31:21.810Z","group":5555,"banner":null,"description":"CoderDojo description","public_url":"https://coderdojo-okutama.doorkeeper.jp/events/8888","participants":12,"waitlisted":0}}]' |
| 41 | + ] |
| 42 | + end |
| 43 | +end |
0 commit comments