almanack 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.gitignore +12 -17
- data/.rspec +3 -0
- data/.travis.yml +2 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +123 -0
- data/LICENSE.txt +17 -18
- data/README.md +22 -4
- data/Rakefile +16 -0
- data/almanack.gemspec +18 -8
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/test +2 -0
- data/certs/aupajo.pem +25 -0
- data/{bin → exe}/almanack +0 -0
- data/lib/almanack/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +62 -59
- metadata.gz.sig +3 -0
- data/spec/almanack_spec.rb +0 -8
- data/spec/calendar_spec.rb +0 -71
- data/spec/configuration_spec.rb +0 -113
- data/spec/event_source/ical_feed_spec.rb +0 -40
- data/spec/event_source/meetup_group_spec.rb +0 -63
- data/spec/event_source/static_spec.rb +0 -41
- data/spec/event_spec.rb +0 -121
- data/spec/features/api_feature_spec.rb +0 -24
- data/spec/features/calendar_feature_spec.rb +0 -44
- data/spec/features/sass_features_spec.rb +0 -15
- data/spec/features/subscription_feature_spec.rb +0 -60
- data/spec/fixtures/responses/google_calendar.yml +0 -1896
- data/spec/fixtures/responses/meetup-without-location.yml +0 -11880
- data/spec/fixtures/responses/meetup.yml +0 -1437
- data/spec/fixtures/themes/sassy/stylesheets/imported.scss +0 -0
- data/spec/fixtures/themes/sassy/stylesheets/imports.scss +0 -1
- data/spec/representation/json_feed_spec.rb +0 -44
- data/spec/serialized_transformation_spec.rb +0 -45
- data/spec/spec_helper.rb +0 -21
- data/spec/support/event_matchers.rb +0 -54
- data/spec/support/server_support.rb +0 -10
- data/spec/support/time_comparison_matchers.rb +0 -14
metadata
CHANGED
@@ -1,14 +1,40 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: almanack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Nicholls
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
10
|
-
cert_chain:
|
11
|
-
|
9
|
+
bindir: exe
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEMDCCApigAwIBAgIBATANBgkqhkiG9w0BAQsFADAhMR8wHQYDVQQDDBZhdXBh
|
14
|
+
am8vREM9Z21haWwvREM9Y29tMB4XDTE5MDUxMDIzNTU1MFoXDTIwMDUwOTIzNTU1
|
15
|
+
MFowITEfMB0GA1UEAwwWYXVwYWpvL0RDPWdtYWlsL0RDPWNvbTCCAaIwDQYJKoZI
|
16
|
+
hvcNAQEBBQADggGPADCCAYoCggGBALifHcsBTFzJr4CcSnTsc3X2hjTYHi3CEJYY
|
17
|
+
DZmcF4CyWYTzc1yw6D8JmekoZHphceFBaCmWDQdRap4yXuqT3RgW+EotBfkoWSY3
|
18
|
+
fp9KmjpvDK1g0uvt9jAUzAHVtWNOwwwSN6cs/L8/AxuvxMC1VJ798T82eruM39SB
|
19
|
+
Uq24isPXm8RMEZsChgRlksr4ZwbP7cTLTqecG4XTd+4kVXEQ5xIUrGxSSOfasckB
|
20
|
+
I5peEg8PP3DAwMIfh3bM6jyWu5f/WO8lwVOjqQIbsD8llxI2u3vsOwigXkfoe6bd
|
21
|
+
3zAsmrmuoqv5WYhgkzz3Te55/Mp1grdDnHv3wWGdlU+1u5K9l54NnlZvMlRbKp+v
|
22
|
+
Hjta3M1sCnbNGH25Lasd3cxHd2S5Pf7Gx5vqyAUtDDqRS6lPNHqCVHm93kiR9Vs8
|
23
|
+
hI8a33sPpQlAxjpDSdbRyenbZVGDoMh7ckj5Jecl8OWpNtjbiuh8o3wcFMwuq2vg
|
24
|
+
pczlifnwXj/mFQrZ8JOVc7GM6I6D9QIDAQABo3MwcTAJBgNVHRMEAjAAMAsGA1Ud
|
25
|
+
DwQEAwIEsDAdBgNVHQ4EFgQUKjXKGxvH9cq/vGtrslK9I/Ym/GcwGwYDVR0RBBQw
|
26
|
+
EoEQYXVwYWpvQGdtYWlsLmNvbTAbBgNVHRIEFDASgRBhdXBham9AZ21haWwuY29t
|
27
|
+
MA0GCSqGSIb3DQEBCwUAA4IBgQB4zcSM0JA0El9w0T6/DHs0qtqqrzMw8vgde4WF
|
28
|
+
N3lYtLtOt9HHmbOfBuUSdZVcONDJ59S6Q6xkortWZob7LER/KZw2IBL07HrlvMyP
|
29
|
+
2ZivUYvBJqK+osMH2/Efuu/53N1rRRvN7AH4Q+ghFtRESJ3+7yXbvc56dLLnLcxJ
|
30
|
+
1mwWlpcraXFnhCyHZxqJWIqumnqhQ9QLyHL99oXJyxp1fyBBUW2/LqVg1bRZeXW8
|
31
|
+
HM3NveDgfHtxsN7/xokEqx9dJZLNIquuh/Mkf/feIfaIbd5yvMg5jI0uFaiyGBAn
|
32
|
+
5oyawSfYQPqmfb+Kek8nEjX90Ul+HHpwHGCe0OfQ9Bo5lwRW5i9ph9iHwzUCIO7s
|
33
|
+
acolbc/fvwdOW4ly/TKaL/1YW/eS3Oi9Yn4RSYTsxSLfVLt2+M3A8Hk1vQFMW/23
|
34
|
+
dZpUW6Gfv2VtOtiN0Q3PjLK+TRjHtqYBjbxa771Msax3xs40e2cSVU/dO+OY5NmR
|
35
|
+
a61dVmZ1PIJiY+jyzJSb8ohHVx4=
|
36
|
+
-----END CERTIFICATE-----
|
37
|
+
date: 2019-05-11 00:00:00.000000000 Z
|
12
38
|
dependencies:
|
13
39
|
- !ruby/object:Gem::Dependency
|
14
40
|
name: sinatra
|
@@ -150,6 +176,20 @@ dependencies:
|
|
150
176
|
- - ">="
|
151
177
|
- !ruby/object:Gem::Version
|
152
178
|
version: '0'
|
179
|
+
- !ruby/object:Gem::Dependency
|
180
|
+
name: bundler
|
181
|
+
requirement: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - "~>"
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '2.0'
|
186
|
+
type: :development
|
187
|
+
prerelease: false
|
188
|
+
version_requirements: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - "~>"
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '2.0'
|
153
193
|
- !ruby/object:Gem::Dependency
|
154
194
|
name: pry
|
155
195
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,30 +208,30 @@ dependencies:
|
|
168
208
|
name: rake
|
169
209
|
requirement: !ruby/object:Gem::Requirement
|
170
210
|
requirements:
|
171
|
-
- - "
|
211
|
+
- - "~>"
|
172
212
|
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
213
|
+
version: '10.0'
|
174
214
|
type: :development
|
175
215
|
prerelease: false
|
176
216
|
version_requirements: !ruby/object:Gem::Requirement
|
177
217
|
requirements:
|
178
|
-
- - "
|
218
|
+
- - "~>"
|
179
219
|
- !ruby/object:Gem::Version
|
180
|
-
version: '0'
|
220
|
+
version: '10.0'
|
181
221
|
- !ruby/object:Gem::Dependency
|
182
222
|
name: rspec
|
183
223
|
requirement: !ruby/object:Gem::Requirement
|
184
224
|
requirements:
|
185
|
-
- - "
|
225
|
+
- - "~>"
|
186
226
|
- !ruby/object:Gem::Version
|
187
|
-
version: '0'
|
227
|
+
version: '3.0'
|
188
228
|
type: :development
|
189
229
|
prerelease: false
|
190
230
|
version_requirements: !ruby/object:Gem::Requirement
|
191
231
|
requirements:
|
192
|
-
- - "
|
232
|
+
- - "~>"
|
193
233
|
- !ruby/object:Gem::Version
|
194
|
-
version: '0'
|
234
|
+
version: '3.0'
|
195
235
|
- !ruby/object:Gem::Dependency
|
196
236
|
name: rack-test
|
197
237
|
requirement: !ruby/object:Gem::Requirement
|
@@ -264,21 +304,28 @@ dependencies:
|
|
264
304
|
version: '0'
|
265
305
|
description:
|
266
306
|
email:
|
267
|
-
-
|
307
|
+
- aupajo@gmail.com
|
268
308
|
executables:
|
269
309
|
- almanack
|
270
310
|
extensions: []
|
271
311
|
extra_rdoc_files: []
|
272
312
|
files:
|
273
313
|
- ".gitignore"
|
314
|
+
- ".rspec"
|
274
315
|
- ".travis.yml"
|
316
|
+
- CODE_OF_CONDUCT.md
|
275
317
|
- Gemfile
|
318
|
+
- Gemfile.lock
|
276
319
|
- LICENSE.txt
|
277
320
|
- README.md
|
278
321
|
- Rakefile
|
279
322
|
- almanack.gemspec
|
280
|
-
- bin/
|
323
|
+
- bin/console
|
324
|
+
- bin/setup
|
325
|
+
- bin/test
|
326
|
+
- certs/aupajo.pem
|
281
327
|
- example.ru
|
328
|
+
- exe/almanack
|
282
329
|
- lib/almanack.rb
|
283
330
|
- lib/almanack/base.rb
|
284
331
|
- lib/almanack/calendar.rb
|
@@ -304,28 +351,6 @@ files:
|
|
304
351
|
- lib/almanack/themes/starter/views/events.erb
|
305
352
|
- lib/almanack/themes/starter/views/layout.erb
|
306
353
|
- lib/almanack/version.rb
|
307
|
-
- spec/almanack_spec.rb
|
308
|
-
- spec/calendar_spec.rb
|
309
|
-
- spec/configuration_spec.rb
|
310
|
-
- spec/event_source/ical_feed_spec.rb
|
311
|
-
- spec/event_source/meetup_group_spec.rb
|
312
|
-
- spec/event_source/static_spec.rb
|
313
|
-
- spec/event_spec.rb
|
314
|
-
- spec/features/api_feature_spec.rb
|
315
|
-
- spec/features/calendar_feature_spec.rb
|
316
|
-
- spec/features/sass_features_spec.rb
|
317
|
-
- spec/features/subscription_feature_spec.rb
|
318
|
-
- spec/fixtures/responses/google_calendar.yml
|
319
|
-
- spec/fixtures/responses/meetup-without-location.yml
|
320
|
-
- spec/fixtures/responses/meetup.yml
|
321
|
-
- spec/fixtures/themes/sassy/stylesheets/imported.scss
|
322
|
-
- spec/fixtures/themes/sassy/stylesheets/imports.scss
|
323
|
-
- spec/representation/json_feed_spec.rb
|
324
|
-
- spec/serialized_transformation_spec.rb
|
325
|
-
- spec/spec_helper.rb
|
326
|
-
- spec/support/event_matchers.rb
|
327
|
-
- spec/support/server_support.rb
|
328
|
-
- spec/support/time_comparison_matchers.rb
|
329
354
|
- templates/gitignore
|
330
355
|
- templates/new/Gemfile
|
331
356
|
- templates/new/README.md.tt
|
@@ -353,26 +378,4 @@ rubygems_version: 3.0.3
|
|
353
378
|
signing_key:
|
354
379
|
specification_version: 4
|
355
380
|
summary: Combined events calendar for Google Calendar, iCal, Meetup.com and friends.
|
356
|
-
test_files:
|
357
|
-
- spec/almanack_spec.rb
|
358
|
-
- spec/calendar_spec.rb
|
359
|
-
- spec/configuration_spec.rb
|
360
|
-
- spec/event_source/ical_feed_spec.rb
|
361
|
-
- spec/event_source/meetup_group_spec.rb
|
362
|
-
- spec/event_source/static_spec.rb
|
363
|
-
- spec/event_spec.rb
|
364
|
-
- spec/features/api_feature_spec.rb
|
365
|
-
- spec/features/calendar_feature_spec.rb
|
366
|
-
- spec/features/sass_features_spec.rb
|
367
|
-
- spec/features/subscription_feature_spec.rb
|
368
|
-
- spec/fixtures/responses/google_calendar.yml
|
369
|
-
- spec/fixtures/responses/meetup-without-location.yml
|
370
|
-
- spec/fixtures/responses/meetup.yml
|
371
|
-
- spec/fixtures/themes/sassy/stylesheets/imported.scss
|
372
|
-
- spec/fixtures/themes/sassy/stylesheets/imports.scss
|
373
|
-
- spec/representation/json_feed_spec.rb
|
374
|
-
- spec/serialized_transformation_spec.rb
|
375
|
-
- spec/spec_helper.rb
|
376
|
-
- spec/support/event_matchers.rb
|
377
|
-
- spec/support/server_support.rb
|
378
|
-
- spec/support/time_comparison_matchers.rb
|
381
|
+
test_files: []
|
metadata.gz.sig
ADDED
data/spec/almanack_spec.rb
DELETED
data/spec/calendar_spec.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Almanack
|
4
|
-
describe Calendar do
|
5
|
-
|
6
|
-
describe "#title" do
|
7
|
-
it "delegates to the config's title" do
|
8
|
-
config = Configuration.new
|
9
|
-
config.title = "Discworld Holidays"
|
10
|
-
calendar = Calendar.new(config)
|
11
|
-
expect(calendar.title).to eq("Discworld Holidays")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#events" do
|
16
|
-
it "calls events_between with now and the days lookahead" do
|
17
|
-
config = Configuration.new
|
18
|
-
calendar = Calendar.new(config)
|
19
|
-
|
20
|
-
now = Time.now
|
21
|
-
lookahead = 42
|
22
|
-
future = now + lookahead * 24 * 60 * 60
|
23
|
-
|
24
|
-
Timecop.freeze(now) do
|
25
|
-
expect(calendar).to receive(:days_lookahead) { lookahead }
|
26
|
-
expect(calendar).to receive(:events_between) do |date_range|
|
27
|
-
expect(date_range.min).to eq_time(now)
|
28
|
-
expect(date_range.max).to eq_time(future)
|
29
|
-
:results
|
30
|
-
end
|
31
|
-
|
32
|
-
expect(calendar.events).to eq(:results)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "#events_between" do
|
38
|
-
it "collects the event sources' events between two dates" do
|
39
|
-
today = Time.now
|
40
|
-
yesterday = today - 1
|
41
|
-
tomorrow = today + 1
|
42
|
-
|
43
|
-
config = Configuration.new
|
44
|
-
config.add_events [
|
45
|
-
{ title: 'Today', start_time: today },
|
46
|
-
{ title: 'Yesterday', start_time: yesterday },
|
47
|
-
{ title: 'Tomorrow', start_time: tomorrow },
|
48
|
-
]
|
49
|
-
|
50
|
-
calendar = Calendar.new(config)
|
51
|
-
|
52
|
-
expect(calendar.events_between(today..tomorrow).map(&:title)).to eq(%w( Today Tomorrow ))
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "#days_lookahead" do
|
57
|
-
it "delegates to the configuration's days_lookahead" do
|
58
|
-
config = double(days_lookahead: :delegated)
|
59
|
-
expect(Calendar.new(config).days_lookahead).to eq(:delegated)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "#feed_lookahead" do
|
64
|
-
it "delegates to the configuration's feed_lookahead" do
|
65
|
-
config = double(feed_lookahead: :delegated)
|
66
|
-
expect(Calendar.new(config).feed_lookahead).to eq(:delegated)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
end
|
data/spec/configuration_spec.rb
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Almanack
|
4
|
-
describe Configuration do
|
5
|
-
|
6
|
-
describe "#title" do
|
7
|
-
it "can be set and accessed" do
|
8
|
-
config = Configuration.new
|
9
|
-
config.title = "Discworld Holidays"
|
10
|
-
expect(config.title).to eq("Discworld Holidays")
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "#theme" do
|
15
|
-
it "can be set and accessed" do
|
16
|
-
config = Configuration.new
|
17
|
-
config.theme = "custom"
|
18
|
-
expect(config.theme).to eq("custom")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "#theme_root" do
|
23
|
-
specify "it raises an error if no theme can be found" do
|
24
|
-
config = Configuration.new
|
25
|
-
config.theme = "nonexistent"
|
26
|
-
expect { config.theme_root }.to raise_error(Configuration::ThemeNotFound)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#days_lookahead" do
|
31
|
-
specify { expect(Configuration.new.days_lookahead).to eq(30) }
|
32
|
-
|
33
|
-
specify "it can be set" do
|
34
|
-
config = Configuration.new
|
35
|
-
config.days_lookahead = 365
|
36
|
-
expect(config.days_lookahead).to eq(365)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "#feed_lookahead" do
|
41
|
-
specify { expect(Configuration.new.feed_lookahead).to eq(365) }
|
42
|
-
|
43
|
-
specify "it can be set" do
|
44
|
-
config = Configuration.new
|
45
|
-
config.feed_lookahead = 30
|
46
|
-
expect(config.feed_lookahead).to eq(30)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "#add_events" do
|
51
|
-
it "adds a simple event collection event source" do
|
52
|
-
config = Configuration.new
|
53
|
-
expect(config.event_sources.size).to eq(0)
|
54
|
-
|
55
|
-
config.add_events [
|
56
|
-
{ title: "Hogswatch" }
|
57
|
-
]
|
58
|
-
|
59
|
-
expect(config.event_sources.size).to eq(1)
|
60
|
-
expect(config.event_sources.first).to be_an_instance_of(EventSource::Static)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "#ical_feed" do
|
65
|
-
it "adds an iCal feed event source" do
|
66
|
-
config = Configuration.new
|
67
|
-
expect(config.event_sources.size).to eq(0)
|
68
|
-
|
69
|
-
config.add_ical_feed "https://www.google.com/calendar/ical/61s2re9bfk01abmla4d17tojuo%40group.calendar.google.com/public/basic.ics"
|
70
|
-
|
71
|
-
expect(config.event_sources.size).to eq(1)
|
72
|
-
expect(config.event_sources.first).to be_an_instance_of(EventSource::IcalFeed)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe "#meetup_group" do
|
77
|
-
it "adds a Meetup group event source" do
|
78
|
-
config = Configuration.new
|
79
|
-
expect(config.event_sources.size).to eq(0)
|
80
|
-
|
81
|
-
config.add_meetup_group(group_urlname: "CHC-JS", key: "secrettoken")
|
82
|
-
|
83
|
-
expect(config.event_sources.size).to eq(1)
|
84
|
-
expect(config.event_sources.first).to be_an_instance_of(EventSource::MeetupGroup)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "#cache_expiry" do
|
89
|
-
it "is 15 minutes by default" do
|
90
|
-
expect(Configuration.new.cache_expiry).to eq(900)
|
91
|
-
end
|
92
|
-
|
93
|
-
it "can be set" do
|
94
|
-
config = Configuration.new
|
95
|
-
config.cache_expiry = 3600
|
96
|
-
expect(config.cache_expiry).to eq(3600)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe "#cache_responses" do
|
101
|
-
it "is enabled by default" do
|
102
|
-
expect(Configuration.new.cache_responses).to be(false)
|
103
|
-
end
|
104
|
-
|
105
|
-
it "can be disabled" do
|
106
|
-
config = Configuration.new
|
107
|
-
config.cache_responses = true
|
108
|
-
expect(config.cache_responses).to be(true)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Almanack::EventSource
|
4
|
-
describe IcalFeed do
|
5
|
-
describe "#events_between" do
|
6
|
-
it "returns a list of events" do
|
7
|
-
feed = IcalFeed.new('https://www.google.com/calendar/ical/61s2re9bfk01abmla4d17tojuo%40group.calendar.google.com/public/basic.ics',
|
8
|
-
connection: Faraday.new)
|
9
|
-
events = nil
|
10
|
-
|
11
|
-
Timecop.freeze(2014, 4, 3) do
|
12
|
-
VCR.use_cassette('google_calendar') do
|
13
|
-
from = Time.now
|
14
|
-
to = from + 30 * 24 * 60 * 60
|
15
|
-
events = feed.events_between(from..to)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
start_times = events.map(&:start_time)
|
20
|
-
|
21
|
-
expect(events.length).to eq(15)
|
22
|
-
expect(events).to all_have_properties(:title, :start_time, :end_time, :description, :location)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#serialized_between" do
|
27
|
-
it "returns a hash containing attributes" do
|
28
|
-
source = IcalFeed.new 'url'
|
29
|
-
|
30
|
-
events = [double(serialized: :serialized_event)]
|
31
|
-
expect(source).to receive(:events_between).with(:date_range) { events }
|
32
|
-
|
33
|
-
expect(source.serialized_between(:date_range)).to eq({
|
34
|
-
events: [:serialized_event]
|
35
|
-
})
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Almanack::EventSource
|
4
|
-
describe MeetupGroup do
|
5
|
-
describe "#events_between" do
|
6
|
-
it "returns a list of events" do
|
7
|
-
feed = MeetupGroup.new(group_urlname: 'The-Foundation-Christchurch',
|
8
|
-
key: 'secrettoken',
|
9
|
-
connection: Faraday.new)
|
10
|
-
events = nil
|
11
|
-
|
12
|
-
Timecop.freeze(2014, 5, 24) do
|
13
|
-
VCR.use_cassette('meetup') do
|
14
|
-
from = Time.now
|
15
|
-
to = from + 30 * 24 * 60 * 60
|
16
|
-
events = feed.events_between(from..to)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
start_times = events.map(&:start_time)
|
21
|
-
|
22
|
-
expect(events.length).to eq(5)
|
23
|
-
expect(events).to all_have_properties(:title, :start_time, :end_time, :description, :location)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "handles a missing location" do
|
27
|
-
feed = MeetupGroup.new(group_urlname: 'adventurewellington',
|
28
|
-
key: 'secrettoken',
|
29
|
-
connection: Faraday.new)
|
30
|
-
|
31
|
-
Timecop.freeze(2014, 7, 23) do
|
32
|
-
VCR.use_cassette('meetup-without-location') do
|
33
|
-
from = Time.now
|
34
|
-
to = from + 30 * 24 * 60 * 60
|
35
|
-
expect { feed.events_between(from..to) }.not_to raise_error
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "#serialized_between" do
|
42
|
-
it "returns a hash containing attributes" do
|
43
|
-
feed = MeetupGroup.new(group_urlname: 'The-Foundation-Christchurch',
|
44
|
-
key: 'secrettoken',
|
45
|
-
connection: Faraday.new)
|
46
|
-
serialized = nil
|
47
|
-
|
48
|
-
Timecop.freeze(2014, 5, 24) do
|
49
|
-
VCR.use_cassette('meetup') do
|
50
|
-
from = Time.now
|
51
|
-
to = from + 30 * 24 * 60 * 60
|
52
|
-
serialized = feed.serialized_between(from..to)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
expect(serialized[:events].length).to eq 5
|
57
|
-
expect(serialized[:name]).to eq("The Foundation")
|
58
|
-
expect(serialized[:url]).to eq("http://www.meetup.com/The-Foundation-Christchurch")
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Almanack::EventSource
|
4
|
-
describe Static do
|
5
|
-
let(:yesterday) { now - 1 }
|
6
|
-
let(:now) { Time.now }
|
7
|
-
let(:tomorrow) { now + 1 }
|
8
|
-
|
9
|
-
around do |test|
|
10
|
-
Timecop.freeze(now, &test)
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#events_between" do
|
14
|
-
it "returns events between two dates" do
|
15
|
-
source = Static.new [
|
16
|
-
{ title: 'Yesterday', start_time: yesterday },
|
17
|
-
{ title: 'Today', start_time: now },
|
18
|
-
{ title: 'Tomorrow', start_time: tomorrow }
|
19
|
-
]
|
20
|
-
|
21
|
-
expect(source.events_between(yesterday..tomorrow).map(&:title)).to eq(%w( Yesterday Today Tomorrow ))
|
22
|
-
expect(source.events_between(now..tomorrow).map(&:title)).to eq(%w( Today Tomorrow ))
|
23
|
-
expect(source.events_between(yesterday..now).map(&:title)).to eq(%w( Yesterday Today ))
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "#serialized_between" do
|
28
|
-
it "returns a hash containing attributes" do
|
29
|
-
source = Static.new []
|
30
|
-
date_range = yesterday..tomorrow
|
31
|
-
|
32
|
-
events = [double(serialized: :serialized_event)]
|
33
|
-
expect(source).to receive(:events_between).with(date_range) { events }
|
34
|
-
|
35
|
-
expect(source.serialized_between(date_range)).to eq({
|
36
|
-
events: [:serialized_event]
|
37
|
-
})
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/spec/event_spec.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Almanack
|
4
|
-
describe Event do
|
5
|
-
|
6
|
-
it "has a title" do
|
7
|
-
event = Event.new(title: "Music with rocks in")
|
8
|
-
expect(event.title).to eq("Music with rocks in")
|
9
|
-
end
|
10
|
-
|
11
|
-
it "has a start time" do
|
12
|
-
event = Event.new(start_time: Time.new(2014, 01, 01))
|
13
|
-
expect(event.start_time).to eq_time(Time.new(2014, 01, 01))
|
14
|
-
end
|
15
|
-
|
16
|
-
it "has a end time" do
|
17
|
-
event = Event.new(end_time: Time.new(2014, 01, 02))
|
18
|
-
expect(event.end_time).to eq_time(Time.new(2014, 01, 02))
|
19
|
-
end
|
20
|
-
|
21
|
-
it "has a location" do
|
22
|
-
event = Event.new(location: "Street of Cunning Artificers")
|
23
|
-
expect(event.location).to eq("Street of Cunning Artificers")
|
24
|
-
end
|
25
|
-
|
26
|
-
it "has a description" do
|
27
|
-
event = Event.new(description: "Be there or be a rectangular thynge.")
|
28
|
-
expect(event.description).to eq("Be there or be a rectangular thynge.")
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#formatted_date" do
|
32
|
-
it "handles events without an end date" do
|
33
|
-
event = Event.new(start_time: Time.parse("2014-07-06 06:24:00 UTC"))
|
34
|
-
expect(event.formatted_date).to eq("July 6 2014 at 6:24am")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "handles events with an end date on the same day" do
|
38
|
-
event = Event.new(start_time: Time.parse("2014-07-06 06:24:00 UTC"),
|
39
|
-
end_time: Time.parse("2014-07-06 13:20:00 UTC"))
|
40
|
-
expect(event.formatted_date).to eq("July 6 2014 at 6:24am to 1:20pm")
|
41
|
-
end
|
42
|
-
|
43
|
-
it "handles events with an end date on a different day" do
|
44
|
-
event = Event.new(start_time: Time.parse("2014-07-06 06:00:00 UTC"),
|
45
|
-
end_time: Time.parse("2014-08-07 10:00:00 UTC"))
|
46
|
-
expect(event.formatted_date).to eq("July 6 2014 at 6:00am to August 7 2014 at 10:00am")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "#start_date" do
|
51
|
-
it "returns start_time for legacy reasons" do
|
52
|
-
event = Event.new(start_time: Time.new(2014, 01, 01))
|
53
|
-
result = nil
|
54
|
-
expect { result = event.start_date }.to output(/deprecated/i).to_stderr
|
55
|
-
expect(result).to eq_time(Time.new(2014, 01, 01))
|
56
|
-
end
|
57
|
-
|
58
|
-
it "can be set via start_date for legacy reasons" do
|
59
|
-
event = Event.new(start_date: Time.new(2014, 01, 01))
|
60
|
-
result = nil
|
61
|
-
expect { result = event.start_time }.to output(/deprecated/i).to_stderr
|
62
|
-
expect(result).to eq_time(Time.new(2014, 01, 01))
|
63
|
-
end
|
64
|
-
|
65
|
-
it "raises an error when both start_date and start_time are given" do
|
66
|
-
event = Event.new(start_date: Time.new(2014, 01, 01),
|
67
|
-
start_time: Time.new(2014, 01, 02))
|
68
|
-
expect { event.start_date }.to raise_error
|
69
|
-
expect { event.start_time }.to raise_error
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "#end_date" do
|
74
|
-
it "returns end_time for legacy reasons" do
|
75
|
-
event = Event.new(end_time: Time.new(2014, 01, 01))
|
76
|
-
result = nil
|
77
|
-
expect { result = event.end_date }.to output(/deprecated/i).to_stderr
|
78
|
-
expect(result).to eq_time(Time.new(2014, 01, 01))
|
79
|
-
end
|
80
|
-
|
81
|
-
it "can be set via end_date for legacy reasons" do
|
82
|
-
event = Event.new(end_date: Time.new(2014, 01, 01))
|
83
|
-
result = nil
|
84
|
-
expect { result = event.end_time }.to output(/deprecated/i).to_stderr
|
85
|
-
expect(result).to eq_time(Time.new(2014, 01, 01))
|
86
|
-
end
|
87
|
-
|
88
|
-
it "raises an error when both end_date and end_time are given" do
|
89
|
-
event = Event.new(end_date: Time.new(2014, 01, 01),
|
90
|
-
end_time: Time.new(2014, 01, 02))
|
91
|
-
expect { event.end_date }.to raise_error
|
92
|
-
expect { event.end_time }.to raise_error
|
93
|
-
end
|
94
|
-
|
95
|
-
it "does not output a deprecation warning when using end_time if neither end_date or end_time is set" do
|
96
|
-
event = Event.new
|
97
|
-
expect { event.end_time }.not_to output.to_stderr
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe "#serialized" do
|
102
|
-
it "returns attributes as a hash" do
|
103
|
-
wed = Time.new(2014, 01, 01)
|
104
|
-
thu = Time.new(2014, 01, 02)
|
105
|
-
|
106
|
-
event = Event.new(title: "Hogswatch",
|
107
|
-
start_time: wed,
|
108
|
-
end_time: thu,
|
109
|
-
arbitrary: true)
|
110
|
-
|
111
|
-
expect(event.serialized).to eq({
|
112
|
-
title: "Hogswatch",
|
113
|
-
start_time: wed.iso8601,
|
114
|
-
end_time: thu.iso8601,
|
115
|
-
arbitrary: true
|
116
|
-
})
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
end
|
121
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "API", :feature do
|
4
|
-
before { Almanack.reset! }
|
5
|
-
|
6
|
-
describe "/feed.json" do
|
7
|
-
it "has a JSON content-type" do
|
8
|
-
get '/feed.json'
|
9
|
-
expect(last_response['Content-Type']).to eq 'application/json'
|
10
|
-
end
|
11
|
-
|
12
|
-
it "returns the JSON feed" do
|
13
|
-
allow(Almanack.calendar).to receive(:json_feed) { "feed" }
|
14
|
-
get '/feed.json'
|
15
|
-
expect(last_response.body).to eq("feed")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "supports JSONP" do
|
19
|
-
allow(Almanack.calendar).to receive(:json_feed) { "feed" }
|
20
|
-
get '/feed.json?callback=custom'
|
21
|
-
expect(last_response.body).to include("custom(feed)")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|