meetupinator 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -8
- data/lib/meetupinator/app.rb +25 -0
- data/lib/meetupinator/cli.rb +45 -0
- data/lib/meetupinator/event_finder.rb +10 -0
- data/lib/meetupinator/event_list_file_writer.rb +50 -0
- data/lib/meetupinator/input_file_reader.rb +12 -0
- data/lib/meetupinator/meetup_api.rb +73 -0
- data/lib/meetupinator/version.rb +4 -0
- data/lib/meetupinator.rb +7 -0
- data/spec/fixtures/functional.csv +22 -0
- data/spec/functional/cli_spec.rb +38 -0
- data/spec/lib/meetupinator/app_spec.rb +35 -0
- data/spec/lib/meetupinator/event_finder_spec.rb +29 -0
- data/spec/lib/meetupinator/event_list_file_writer_spec.rb +77 -0
- data/spec/lib/meetupinator/functional_spec.rb +116 -0
- data/spec/lib/meetupinator/input_file_reader_spec.rb +23 -0
- data/spec/lib/meetupinator/meetup_api_spec.rb +78 -0
- data/spec/test_helpers/match_stdout.rb +32 -0
- data/spec/vcr_cassettes/events_multiple_groups.yml +2059 -0
- data/spec/vcr_cassettes/events_next_week.yml +111 -0
- data/spec/vcr_cassettes/events_single_group.yml +305 -0
- data/spec/vcr_cassettes/functional.yml +989 -0
- data/spec/vcr_cassettes/getevents_functional_test.yml +532 -0
- data/spec/vcr_cassettes/groups.yml +112 -0
- metadata +40 -2
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vcr_setup'
|
3
|
+
require 'meetupinator/meetup_api'
|
4
|
+
|
5
|
+
describe Meetupinator::MeetupAPI do
|
6
|
+
let(:group_id) { 980_007_2 }
|
7
|
+
|
8
|
+
describe '#new' do
|
9
|
+
context 'when there is no Meetup API key in the environment' do
|
10
|
+
before { ENV['MEETUP_API_KEY'] = nil }
|
11
|
+
|
12
|
+
it 'raises a no API key error if no API key is explicitly given' do
|
13
|
+
expect { subject }.to raise_exception('no MEETUP_API_KEY provided')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'uses the API key given in the constructor' do
|
17
|
+
key = 'My super-secret API key'
|
18
|
+
subject = Meetupinator::MeetupAPI.new key
|
19
|
+
expect(subject.api_key).to eq(key)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when there is a Meetup API key in the environment' do
|
24
|
+
let(:env_api_key) { '1234' }
|
25
|
+
|
26
|
+
before { ENV['MEETUP_API_KEY'] = env_api_key }
|
27
|
+
|
28
|
+
it 'uses the API given in the env if no API key is explicitly given' do
|
29
|
+
expect(subject.api_key).to eq(env_api_key)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'uses the API key given in the constructor if one is given' do
|
33
|
+
key = 'My super-secret API key'
|
34
|
+
subject = Meetupinator::MeetupAPI.new key
|
35
|
+
expect(subject.api_key).to eq(key)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#get_meetup_id' do
|
41
|
+
let(:group_url_name) { 'Ruby-On-Rails-Oceania-Melbourne' }
|
42
|
+
|
43
|
+
it 'returns the id of the meetup' do
|
44
|
+
VCR.use_cassette('groups') do
|
45
|
+
expect(subject.get_meetup_id(group_url_name)).to eq(group_id)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#get_upcoming_events' do
|
51
|
+
context 'single group' do
|
52
|
+
let(:expected_number_of_events) { 6 }
|
53
|
+
|
54
|
+
it 'returns all the upcoming events' do
|
55
|
+
VCR.use_cassette('events_single_group') do
|
56
|
+
expect(subject.get_upcoming_events([group_id], nil).size).to eq(expected_number_of_events)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'returns all the upcoming events for the next week' do
|
61
|
+
VCR.use_cassette('events_next_week') do
|
62
|
+
expect(subject.get_upcoming_events([group_id], true).size).to eq(1)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'multiple groups' do
|
68
|
+
let(:meetup_ids) { [group_id, 183_050_22] }
|
69
|
+
let(:expected_number_of_events) { 73 }
|
70
|
+
|
71
|
+
it 'returns all the upcoming events' do
|
72
|
+
VCR.use_cassette('events_multiple_groups') do
|
73
|
+
expect(subject.get_upcoming_events([meetup_ids], nil).size).to eq(expected_number_of_events)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# From http://stackoverflow.com/a/20583518/1668119
|
2
|
+
# modified to work with RSpec 3.0
|
3
|
+
RSpec::Matchers.define :match_stdout do |check|
|
4
|
+
@capture = nil
|
5
|
+
|
6
|
+
match do |block|
|
7
|
+
begin
|
8
|
+
stdout_saved = $stdout
|
9
|
+
$stdout = StringIO.new
|
10
|
+
block.call
|
11
|
+
ensure
|
12
|
+
@capture = $stdout
|
13
|
+
$stdout = stdout_saved
|
14
|
+
end
|
15
|
+
|
16
|
+
@capture.string.match check
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message do
|
20
|
+
"expected to #{description}"
|
21
|
+
end
|
22
|
+
failure_message_when_negated do
|
23
|
+
"expected not to #{description}"
|
24
|
+
end
|
25
|
+
description do
|
26
|
+
"match [#{check}] on stdout [#{@capture.string}]"
|
27
|
+
end
|
28
|
+
|
29
|
+
def supports_block_expectations?
|
30
|
+
true
|
31
|
+
end
|
32
|
+
end
|