|
| 1 | +require 'rails_helper' |
| 2 | +require 'statistics' |
| 3 | + |
| 4 | +RSpec.describe Statistics::Client do |
| 5 | + include_context 'Use stubs for Faraday' |
| 6 | + |
| 7 | + context 'Connpass' do |
| 8 | + describe '#search' do |
| 9 | + subject { Statistics::Client::Connpass.new.search(keyword: 'coderdojo') } |
| 10 | + |
| 11 | + it do |
| 12 | + expect(subject).to be_instance_of(Hash) |
| 13 | + expect(subject['results_returned']).to eq 1 |
| 14 | + expect(subject['events'].size).to eq 1 |
| 15 | + expect(subject['events'].first['event_id']).to eq 12345 |
| 16 | + expect(subject['events'].first['series']['url']).to eq 'https://coderdojo-okutama.connpass.com/' |
| 17 | + expect(subject['events'].first['series']['id']).to eq 9876 |
| 18 | + end |
| 19 | + end |
| 20 | + |
| 21 | + describe '#fetch_events' do |
| 22 | + subject { Statistics::Client::Connpass.new.fetch_events(series_id: 9876) } |
| 23 | + |
| 24 | + it do |
| 25 | + expect(subject).to be_instance_of(Array) |
| 26 | + expect(subject.size).to eq 1 |
| 27 | + expect(subject.first['event_id']).to eq 12345 |
| 28 | + expect(subject.first['series']['url']).to eq 'https://coderdojo-okutama.connpass.com/' |
| 29 | + expect(subject.first['series']['id']).to eq 9876 |
| 30 | + end |
| 31 | + end |
| 32 | + end |
| 33 | + |
| 34 | + context 'Doorkeeper' do |
| 35 | + describe '#search' do |
| 36 | + subject { Statistics::Client::Doorkeeper.new.search(keyword: 'coderdojo') } |
| 37 | + |
| 38 | + it do |
| 39 | + expect(subject).to be_instance_of(Array) |
| 40 | + expect(subject.size).to eq 1 |
| 41 | + expect(subject.first['event']['id']).to eq 1234 |
| 42 | + expect(subject.first['event']['group']).to eq 5555 |
| 43 | + end |
| 44 | + end |
| 45 | + |
| 46 | + describe '#fetch_events' do |
| 47 | + subject { Statistics::Client::Doorkeeper.new.fetch_events(group_id: 5555) } |
| 48 | + |
| 49 | + it do |
| 50 | + expect(subject).to be_instance_of(Array) |
| 51 | + expect(subject.size).to eq 1 |
| 52 | + expect(subject.first['id']).to eq 1234 |
| 53 | + expect(subject.first['group']).to eq 5555 |
| 54 | + end |
| 55 | + end |
| 56 | + end |
| 57 | +end |
0 commit comments