eventify 1.5.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -0
- data/.ruby-version +1 -1
- data/.travis.yml +0 -1
- data/Gemfile +14 -14
- data/Guardfile +0 -0
- data/LICENSE +1 -1
- data/README.md +2 -2
- data/Rakefile +0 -0
- data/eventify.gemspec +2 -2
- data/lib/eventify.rb +4 -4
- data/lib/eventify/configuration.rb +0 -0
- data/lib/eventify/database.rb +0 -0
- data/lib/eventify/mail.rb +0 -0
- data/lib/eventify/provider/apollo_kino.rb +21 -0
- data/lib/eventify/provider/base.rb +55 -55
- data/lib/eventify/provider/livenation.rb +21 -0
- data/lib/eventify/provider/piletilevi.rb +1 -1
- data/lib/eventify/version.rb +1 -1
- data/spec/eventify/configuration_spec.rb +51 -51
- data/spec/eventify/database_spec.rb +9 -9
- data/spec/eventify/mail_spec.rb +33 -33
- data/spec/eventify/provider/apollo_kino_spec.rb +25 -0
- data/spec/eventify/provider/base_spec.rb +145 -145
- data/spec/eventify/provider/livenation_spec.rb +25 -0
- data/spec/eventify/provider/piletilevi_spec.rb +46 -46
- data/spec/eventify_spec.rb +155 -155
- data/spec/spec_helper.rb +7 -0
- data/spec/support/apollo_kino.html +1021 -0
- data/spec/support/livenation.html +1444 -0
- data/spec/support/piletilevi.json +0 -0
- metadata +21 -23
- data/lib/eventify/provider/fbi.rb +0 -17
- data/lib/eventify/provider/solaris_kino.rb +0 -30
- data/spec/eventify/provider/fbi_spec.rb +0 -25
- data/spec/eventify/provider/solaris_kino_spec.rb +0 -31
- data/spec/support/fbi.html +0 -802
- data/spec/support/solaris_kino.html +0 -542
data/spec/eventify/mail_spec.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Eventify::Mail do
|
4
|
-
context ".deliver" do
|
5
|
-
it "sends e-mail to all subscribers" do
|
6
|
-
::Mail.
|
7
|
-
|
8
|
-
Eventify::Mail.deliver([], Eventify::Configuration.new(subscribers: ["foo@example.org", "bar@example.org"]))
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
it ".format" do
|
13
|
-
new_events = [
|
14
|
-
Eventify::Provider::Base.new(id: "123", title: "foo", link: "http://example.org/1", date: Time.now),
|
15
|
-
Eventify::Provider::Piletilevi.new(id: "456", title: "bar", link: "http://example.org/2", date: Time.now),
|
16
|
-
Eventify::Provider::Base.new(id: "456", title: "bar3", link: "http://example.org/3", date: Time.now)
|
17
|
-
]
|
18
|
-
|
19
|
-
Eventify::Mail.format(new_events).
|
20
|
-
|
21
|
-
* bar
|
22
|
-
http://example.org/2
|
23
|
-
|
24
|
-
* bar3
|
25
|
-
http://example.org/3
|
26
|
-
|
27
|
-
* foo
|
28
|
-
http://example.org/1
|
29
|
-
|
30
|
-
Your Humble Servant,
|
31
|
-
Eventify"
|
32
|
-
end
|
33
|
-
end
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Eventify::Mail do
|
4
|
+
context ".deliver" do
|
5
|
+
it "sends e-mail to all subscribers" do
|
6
|
+
expect(::Mail).to receive(:deliver).twice
|
7
|
+
|
8
|
+
Eventify::Mail.deliver([], Eventify::Configuration.new(subscribers: ["foo@example.org", "bar@example.org"]))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it ".format" do
|
13
|
+
new_events = [
|
14
|
+
Eventify::Provider::Base.new(id: "123", title: "foo", link: "http://example.org/1", date: Time.now),
|
15
|
+
Eventify::Provider::Piletilevi.new(id: "456", title: "bar", link: "http://example.org/2", date: Time.now),
|
16
|
+
Eventify::Provider::Base.new(id: "456", title: "bar3", link: "http://example.org/3", date: Time.now)
|
17
|
+
]
|
18
|
+
|
19
|
+
expect(Eventify::Mail.format(new_events)).to eq("There are some rumours going on about 3 possible awesome events:
|
20
|
+
|
21
|
+
* bar
|
22
|
+
http://example.org/2
|
23
|
+
|
24
|
+
* bar3
|
25
|
+
http://example.org/3
|
26
|
+
|
27
|
+
* foo
|
28
|
+
http://example.org/1
|
29
|
+
|
30
|
+
Your Humble Servant,
|
31
|
+
Eventify")
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Eventify::Provider::ApolloKino do
|
4
|
+
context "#fetch" do
|
5
|
+
it "fetches events" do
|
6
|
+
stub_request(:get, URI.join(Eventify::Provider::ApolloKino::URL, "eng/soon").to_s).to_return(body: File.read(File.expand_path("../../support/apollo_kino.html", __dir__)))
|
7
|
+
|
8
|
+
events = Eventify::Provider::ApolloKino.fetch
|
9
|
+
expect(events).to eq([
|
10
|
+
Eventify::Provider::ApolloKino.new(
|
11
|
+
title: "Võimlemisklubi Janika TALVEKONTSERT",
|
12
|
+
link: "https://www.apollokino.ee/eng/event/4127/title/v%C3%B5imlemisklubi_janika_talvekontsert/",
|
13
|
+
date: Time.parse("2021-01-31"),
|
14
|
+
id: "https://www.apollokino.ee/eng/event/4127/title/v%C3%B5imlemisklubi_janika_talvekontsert/"
|
15
|
+
),
|
16
|
+
Eventify::Provider::ApolloKino.new(
|
17
|
+
title: "Jurassic World: Dominion",
|
18
|
+
link: "https://www.apollokino.ee/eng/event/4064/title/jurassic_world_dominion/",
|
19
|
+
date: Time.parse("2022-06-10"),
|
20
|
+
id: "https://www.apollokino.ee/eng/event/4064/title/jurassic_world_dominion/",
|
21
|
+
),
|
22
|
+
])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,145 +1,145 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Eventify::Provider::Base do
|
4
|
-
context ".fetch" do
|
5
|
-
it "needs to be implemented" do
|
6
|
-
class Eventify::Provider::CustomEvent < Eventify::Provider::Base; end
|
7
|
-
|
8
|
-
expect {
|
9
|
-
Eventify::Provider::CustomEvent.fetch
|
10
|
-
}.to raise_error(NotImplementedError)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
context "#initialize" do
|
15
|
-
it "parses raw event" do
|
16
|
-
event = {
|
17
|
-
id: "86362",
|
18
|
-
title: "Koit Toome ja Karl-Erik Taukar 17.01.2014 - 21:00 - Rock Cafe, Tallinn, Eesti",
|
19
|
-
link: "http://www.piletilevi.ee/est/piletid/muusika/rock_ja_pop/?concert=138090",
|
20
|
-
date: Time.parse("2013-12-27 12:30:11"),
|
21
|
-
}
|
22
|
-
|
23
|
-
parsed_event = Eventify::Provider::Base.new(event)
|
24
|
-
parsed_event.id.
|
25
|
-
parsed_event.provider.
|
26
|
-
parsed_event.title.
|
27
|
-
parsed_event.link.
|
28
|
-
parsed_event.date.
|
29
|
-
end
|
30
|
-
|
31
|
-
it "raises an error when id is missing" do
|
32
|
-
event = {
|
33
|
-
title: "Koit Toome ja Karl-Erik Taukar 17.01.2014 - 21:00 - Rock Cafe, Tallinn, Eesti",
|
34
|
-
link: "http://www.piletilevi.ee/est/piletid/muusika/rock_ja_pop/?concert=138090",
|
35
|
-
date: Time.parse("2013-12-27 12:30:11"),
|
36
|
-
}
|
37
|
-
|
38
|
-
expect {
|
39
|
-
Eventify::Provider::Base.new(event)
|
40
|
-
}.to raise_error(Eventify::Provider::Base::MissingAttributeError)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "raises an error when title is missing" do
|
44
|
-
event = {
|
45
|
-
id: "86362",
|
46
|
-
link: "http://www.piletilevi.ee/est/piletid/muusika/rock_ja_pop/?concert=138090",
|
47
|
-
date: Time.parse("2013-12-27 12:30:11"),
|
48
|
-
}
|
49
|
-
|
50
|
-
expect {
|
51
|
-
Eventify::Provider::Base.new(event)
|
52
|
-
}.to raise_error(Eventify::Provider::Base::MissingAttributeError)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "raises an error when link is missing" do
|
56
|
-
event = {
|
57
|
-
id: "86362",
|
58
|
-
title: "Koit Toome ja Karl-Erik Taukar 17.01.2014 - 21:00 - Rock Cafe, Tallinn, Eesti",
|
59
|
-
date: Time.parse("2013-12-27 12:30:11"),
|
60
|
-
}
|
61
|
-
|
62
|
-
expect {
|
63
|
-
Eventify::Provider::Base.new(event)
|
64
|
-
}.to raise_error(Eventify::Provider::Base::MissingAttributeError)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context "#provider" do
|
69
|
-
it "uses class name" do
|
70
|
-
class Eventify::Provider::CustomEvent < Eventify::Provider::Base; end
|
71
|
-
Eventify::Provider::CustomEvent.new(id: "123", title: "foo", link: "http://example.org").provider.
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context "#==" do
|
76
|
-
it "true when id and provider match" do
|
77
|
-
Eventify::Provider::Base.new(id: "123", title: "foo", link: "http://example.org").
|
78
|
-
end
|
79
|
-
|
80
|
-
it "false when id does not match" do
|
81
|
-
Eventify::Provider::Base.new(id: "123", title: "foo", link: "http://example.org").
|
82
|
-
end
|
83
|
-
|
84
|
-
it "false when class does not match" do
|
85
|
-
class Eventify::Provider::CustomEvent < Eventify::Provider::Base; end
|
86
|
-
Eventify::Provider::CustomEvent.new(id: "123", title: "foo", link: "http://example.org").
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
context "#save" do
|
91
|
-
it "saves event into database" do
|
92
|
-
event = {
|
93
|
-
id: "86362",
|
94
|
-
title: "Koit Toome ja Karl-Erik Taukar 17.01.2014 - 21:00 - Rock Cafe, Tallinn, Eesti",
|
95
|
-
link: "http://www.piletilevi.ee/est/piletid/muusika/rock_ja_pop/?concert=138090",
|
96
|
-
date: Time.parse("2013-12-27 12:30:11"),
|
97
|
-
}
|
98
|
-
Eventify::Provider::Base.new(event).save
|
99
|
-
|
100
|
-
Eventify::Database.events.size.
|
101
|
-
end
|
102
|
-
|
103
|
-
it "returns self" do
|
104
|
-
event = {
|
105
|
-
id: "86362",
|
106
|
-
title: "Koit Toome ja Karl-Erik Taukar 17.01.2014 - 21:00 - Rock Cafe, Tallinn, Eesti",
|
107
|
-
link: "http://www.piletilevi.ee/est/piletid/muusika/rock_ja_pop/?concert=138090",
|
108
|
-
date: Time.parse("2013-12-27 12:30:11"),
|
109
|
-
}
|
110
|
-
event_instance = Eventify::Provider::Base.new(event)
|
111
|
-
event_instance.save.
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
context "#exists?" do
|
116
|
-
it "true for existing event" do
|
117
|
-
event = {
|
118
|
-
id: "86362",
|
119
|
-
title: "Koit Toome ja Karl-Erik Taukar 17.01.2014 - 21:00 - Rock Cafe, Tallinn, Eesti",
|
120
|
-
link: "http://www.piletilevi.ee/est/piletid/muusika/rock_ja_pop/?concert=138090",
|
121
|
-
date: Time.parse("2013-12-27 12:30:11"),
|
122
|
-
}
|
123
|
-
Eventify::Provider::Base.new(event).save
|
124
|
-
|
125
|
-
Eventify::Provider::Base.new(event).
|
126
|
-
end
|
127
|
-
|
128
|
-
it "false for not existing event" do
|
129
|
-
event = {
|
130
|
-
id: "86362",
|
131
|
-
title: "Koit Toome ja Karl-Erik Taukar 17.01.2014 - 21:00 - Rock Cafe, Tallinn, Eesti",
|
132
|
-
link: "http://www.piletilevi.ee/est/piletid/muusika/rock_ja_pop/?concert=138090",
|
133
|
-
date: Time.parse("2013-12-27 12:30:11"),
|
134
|
-
}
|
135
|
-
|
136
|
-
Eventify::Provider::Base.new(event).
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
it "sorts by title" do
|
141
|
-
event1 = Eventify::Provider::Base.new(id: "123", title: "foo", link: "http://example.org")
|
142
|
-
event2 = Eventify::Provider::Piletilevi.new(id: "123", title: "bar", link: "http://example.org")
|
143
|
-
[event1, event2].sort.
|
144
|
-
end
|
145
|
-
end
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Eventify::Provider::Base do
|
4
|
+
context ".fetch" do
|
5
|
+
it "needs to be implemented" do
|
6
|
+
class Eventify::Provider::CustomEvent < Eventify::Provider::Base; end
|
7
|
+
|
8
|
+
expect {
|
9
|
+
Eventify::Provider::CustomEvent.fetch
|
10
|
+
}.to raise_error(NotImplementedError)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "#initialize" do
|
15
|
+
it "parses raw event" do
|
16
|
+
event = {
|
17
|
+
id: "86362",
|
18
|
+
title: "Koit Toome ja Karl-Erik Taukar 17.01.2014 - 21:00 - Rock Cafe, Tallinn, Eesti",
|
19
|
+
link: "http://www.piletilevi.ee/est/piletid/muusika/rock_ja_pop/?concert=138090",
|
20
|
+
date: Time.parse("2013-12-27 12:30:11"),
|
21
|
+
}
|
22
|
+
|
23
|
+
parsed_event = Eventify::Provider::Base.new(event)
|
24
|
+
expect(parsed_event.id).to eq("86362")
|
25
|
+
expect(parsed_event.provider).to eq("Eventify::Provider::Base")
|
26
|
+
expect(parsed_event.title).to eq(event[:title])
|
27
|
+
expect(parsed_event.link).to eq(event[:link])
|
28
|
+
expect(parsed_event.date).to eq(event[:date])
|
29
|
+
end
|
30
|
+
|
31
|
+
it "raises an error when id is missing" do
|
32
|
+
event = {
|
33
|
+
title: "Koit Toome ja Karl-Erik Taukar 17.01.2014 - 21:00 - Rock Cafe, Tallinn, Eesti",
|
34
|
+
link: "http://www.piletilevi.ee/est/piletid/muusika/rock_ja_pop/?concert=138090",
|
35
|
+
date: Time.parse("2013-12-27 12:30:11"),
|
36
|
+
}
|
37
|
+
|
38
|
+
expect {
|
39
|
+
Eventify::Provider::Base.new(event)
|
40
|
+
}.to raise_error(Eventify::Provider::Base::MissingAttributeError)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "raises an error when title is missing" do
|
44
|
+
event = {
|
45
|
+
id: "86362",
|
46
|
+
link: "http://www.piletilevi.ee/est/piletid/muusika/rock_ja_pop/?concert=138090",
|
47
|
+
date: Time.parse("2013-12-27 12:30:11"),
|
48
|
+
}
|
49
|
+
|
50
|
+
expect {
|
51
|
+
Eventify::Provider::Base.new(event)
|
52
|
+
}.to raise_error(Eventify::Provider::Base::MissingAttributeError)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "raises an error when link is missing" do
|
56
|
+
event = {
|
57
|
+
id: "86362",
|
58
|
+
title: "Koit Toome ja Karl-Erik Taukar 17.01.2014 - 21:00 - Rock Cafe, Tallinn, Eesti",
|
59
|
+
date: Time.parse("2013-12-27 12:30:11"),
|
60
|
+
}
|
61
|
+
|
62
|
+
expect {
|
63
|
+
Eventify::Provider::Base.new(event)
|
64
|
+
}.to raise_error(Eventify::Provider::Base::MissingAttributeError)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context "#provider" do
|
69
|
+
it "uses class name" do
|
70
|
+
class Eventify::Provider::CustomEvent < Eventify::Provider::Base; end
|
71
|
+
expect(Eventify::Provider::CustomEvent.new(id: "123", title: "foo", link: "http://example.org").provider).to eq("Eventify::Provider::CustomEvent")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "#==" do
|
76
|
+
it "true when id and provider match" do
|
77
|
+
expect(Eventify::Provider::Base.new(id: "123", title: "foo", link: "http://example.org")).to eq(Eventify::Provider::Base.new(id: "123", title: "foo", link: "http://example.org"))
|
78
|
+
end
|
79
|
+
|
80
|
+
it "false when id does not match" do
|
81
|
+
expect(Eventify::Provider::Base.new(id: "123", title: "foo", link: "http://example.org")).not_to eq(Eventify::Provider::Base.new(id: "321", title: "foo", link: "http://example.org"))
|
82
|
+
end
|
83
|
+
|
84
|
+
it "false when class does not match" do
|
85
|
+
class Eventify::Provider::CustomEvent < Eventify::Provider::Base; end
|
86
|
+
expect(Eventify::Provider::CustomEvent.new(id: "123", title: "foo", link: "http://example.org")).not_to eq(Eventify::Provider::Base.new(id: "123", title: "foo", link: "http://example.org"))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "#save" do
|
91
|
+
it "saves event into database" do
|
92
|
+
event = {
|
93
|
+
id: "86362",
|
94
|
+
title: "Koit Toome ja Karl-Erik Taukar 17.01.2014 - 21:00 - Rock Cafe, Tallinn, Eesti",
|
95
|
+
link: "http://www.piletilevi.ee/est/piletid/muusika/rock_ja_pop/?concert=138090",
|
96
|
+
date: Time.parse("2013-12-27 12:30:11"),
|
97
|
+
}
|
98
|
+
Eventify::Provider::Base.new(event).save
|
99
|
+
|
100
|
+
expect(Eventify::Database.events.size).to eq(1)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "returns self" do
|
104
|
+
event = {
|
105
|
+
id: "86362",
|
106
|
+
title: "Koit Toome ja Karl-Erik Taukar 17.01.2014 - 21:00 - Rock Cafe, Tallinn, Eesti",
|
107
|
+
link: "http://www.piletilevi.ee/est/piletid/muusika/rock_ja_pop/?concert=138090",
|
108
|
+
date: Time.parse("2013-12-27 12:30:11"),
|
109
|
+
}
|
110
|
+
event_instance = Eventify::Provider::Base.new(event)
|
111
|
+
expect(event_instance.save).to eq(event_instance)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context "#exists?" do
|
116
|
+
it "true for existing event" do
|
117
|
+
event = {
|
118
|
+
id: "86362",
|
119
|
+
title: "Koit Toome ja Karl-Erik Taukar 17.01.2014 - 21:00 - Rock Cafe, Tallinn, Eesti",
|
120
|
+
link: "http://www.piletilevi.ee/est/piletid/muusika/rock_ja_pop/?concert=138090",
|
121
|
+
date: Time.parse("2013-12-27 12:30:11"),
|
122
|
+
}
|
123
|
+
Eventify::Provider::Base.new(event).save
|
124
|
+
|
125
|
+
expect(Eventify::Provider::Base.new(event)).to exist
|
126
|
+
end
|
127
|
+
|
128
|
+
it "false for not existing event" do
|
129
|
+
event = {
|
130
|
+
id: "86362",
|
131
|
+
title: "Koit Toome ja Karl-Erik Taukar 17.01.2014 - 21:00 - Rock Cafe, Tallinn, Eesti",
|
132
|
+
link: "http://www.piletilevi.ee/est/piletid/muusika/rock_ja_pop/?concert=138090",
|
133
|
+
date: Time.parse("2013-12-27 12:30:11"),
|
134
|
+
}
|
135
|
+
|
136
|
+
expect(Eventify::Provider::Base.new(event)).not_to exist
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
it "sorts by title" do
|
141
|
+
event1 = Eventify::Provider::Base.new(id: "123", title: "foo", link: "http://example.org")
|
142
|
+
event2 = Eventify::Provider::Piletilevi.new(id: "123", title: "bar", link: "http://example.org")
|
143
|
+
expect([event1, event2].sort).to eq([event2, event1])
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Eventify::Provider::Livenation do
|
4
|
+
context "#fetch" do
|
5
|
+
it "fetches events" do
|
6
|
+
stub_request(:get, Eventify::Provider::Livenation::URL).to_return(body: File.read(File.expand_path("../../support/livenation.html", __dir__)))
|
7
|
+
|
8
|
+
events = Eventify::Provider::Livenation.fetch
|
9
|
+
expect(events).to eq([
|
10
|
+
Eventify::Provider::Livenation.new(
|
11
|
+
title: "CLANNAD - In A Lifetime Farewell Tour",
|
12
|
+
link: "https://www.livenation.ee/show/1310067/clannad-in-a-lifetime-farewell-tour/tallinn/2021-03-30/ee",
|
13
|
+
date: Time.parse("2021-3-30"),
|
14
|
+
id: "https://www.livenation.ee/show/1310067/clannad-in-a-lifetime-farewell-tour/tallinn/2021-03-30/ee"
|
15
|
+
),
|
16
|
+
Eventify::Provider::Livenation.new(
|
17
|
+
title: "JAMES BLUNT - Once Upon A Mind Tour",
|
18
|
+
link: "https://www.livenation.ee/show/1310003/james-blunt-once-upon-a-mind-tour/tallinn/2021-06-03/ee",
|
19
|
+
date: Time.parse("2021-6-03"),
|
20
|
+
id: "https://www.livenation.ee/show/1310003/james-blunt-once-upon-a-mind-tour/tallinn/2021-06-03/ee"
|
21
|
+
)
|
22
|
+
])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,46 +1,46 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Eventify::Provider::Piletilevi do
|
4
|
-
context "#fetch" do
|
5
|
-
it "fetches events" do
|
6
|
-
stub_request(:get, Eventify::Provider::Piletilevi::URL.to_s).to_return(body: File.read(File.expand_path("../../support/piletilevi.json", __dir__)))
|
7
|
-
|
8
|
-
events = Eventify::Provider::Piletilevi.fetch
|
9
|
-
events.
|
10
|
-
Eventify::Provider::Piletilevi.new(
|
11
|
-
title:"Jelena Vaenga \/ \u0415\u043b\u0435\u043d\u0430 \u0412\u0430\u0435\u043d\u0433\u0430",
|
12
|
-
link:"http:/\/www.piletilevi.ee\/est\/piletid\/muusika\/rock-ja-pop\/jelena-vaenga-elena-vaenga-190326\/",
|
13
|
-
date: Time.at(1484326800),
|
14
|
-
id: "190326"
|
15
|
-
),
|
16
|
-
Eventify::Provider::Piletilevi.new(
|
17
|
-
title:"Head t\u00fc\u00fcbid",
|
18
|
-
link:"http:\/\/www.piletilevi.ee\/est\/piletid\/film\/krimifilm\/head-tuubid-190410\/",
|
19
|
-
date: Time.at(1465405200),
|
20
|
-
id: "190410"
|
21
|
-
),
|
22
|
-
Eventify::Provider::Piletilevi.new(
|
23
|
-
title:"Teismelised ninjakilpkonnad: Varjust v\u00e4lja (3D)",
|
24
|
-
link:"http:\/\/www.piletilevi.ee\/est\/piletid\/film\/marul\/teismelised-ninjakilpkonnad-varjust-valja-3d-190405\/",
|
25
|
-
date: Time.at(1465491600),
|
26
|
-
id: "190405"
|
27
|
-
)
|
28
|
-
]
|
29
|
-
end
|
30
|
-
|
31
|
-
it "works without concerts" do
|
32
|
-
stub_request(:get, Eventify::Provider::Piletilevi::URL.to_s).to_return(body: %q|{"responseData": {}}|)
|
33
|
-
Eventify::Provider::Piletilevi.fetch.
|
34
|
-
end
|
35
|
-
|
36
|
-
it "works without response data" do
|
37
|
-
stub_request(:get, Eventify::Provider::Piletilevi::URL.to_s).to_return(body: %q|{"foo": {}}|)
|
38
|
-
Eventify::Provider::Piletilevi.fetch.
|
39
|
-
end
|
40
|
-
|
41
|
-
it "works without json response" do
|
42
|
-
stub_request(:get, Eventify::Provider::Piletilevi::URL.to_s).to_return(body: %q|foo|)
|
43
|
-
Eventify::Provider::Piletilevi.fetch.
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Eventify::Provider::Piletilevi do
|
4
|
+
context "#fetch" do
|
5
|
+
it "fetches events" do
|
6
|
+
stub_request(:get, Eventify::Provider::Piletilevi::URL.to_s).to_return(body: File.read(File.expand_path("../../support/piletilevi.json", __dir__)))
|
7
|
+
|
8
|
+
events = Eventify::Provider::Piletilevi.fetch
|
9
|
+
expect(events).to eq([
|
10
|
+
Eventify::Provider::Piletilevi.new(
|
11
|
+
title:"Jelena Vaenga \/ \u0415\u043b\u0435\u043d\u0430 \u0412\u0430\u0435\u043d\u0433\u0430",
|
12
|
+
link:"http:/\/www.piletilevi.ee\/est\/piletid\/muusika\/rock-ja-pop\/jelena-vaenga-elena-vaenga-190326\/",
|
13
|
+
date: Time.at(1484326800),
|
14
|
+
id: "190326"
|
15
|
+
),
|
16
|
+
Eventify::Provider::Piletilevi.new(
|
17
|
+
title:"Head t\u00fc\u00fcbid",
|
18
|
+
link:"http:\/\/www.piletilevi.ee\/est\/piletid\/film\/krimifilm\/head-tuubid-190410\/",
|
19
|
+
date: Time.at(1465405200),
|
20
|
+
id: "190410"
|
21
|
+
),
|
22
|
+
Eventify::Provider::Piletilevi.new(
|
23
|
+
title:"Teismelised ninjakilpkonnad: Varjust v\u00e4lja (3D)",
|
24
|
+
link:"http:\/\/www.piletilevi.ee\/est\/piletid\/film\/marul\/teismelised-ninjakilpkonnad-varjust-valja-3d-190405\/",
|
25
|
+
date: Time.at(1465491600),
|
26
|
+
id: "190405"
|
27
|
+
)
|
28
|
+
])
|
29
|
+
end
|
30
|
+
|
31
|
+
it "works without concerts" do
|
32
|
+
stub_request(:get, Eventify::Provider::Piletilevi::URL.to_s).to_return(body: %q|{"responseData": {}}|)
|
33
|
+
expect(Eventify::Provider::Piletilevi.fetch).to eq([])
|
34
|
+
end
|
35
|
+
|
36
|
+
it "works without response data" do
|
37
|
+
stub_request(:get, Eventify::Provider::Piletilevi::URL.to_s).to_return(body: %q|{"foo": {}}|)
|
38
|
+
expect(Eventify::Provider::Piletilevi.fetch).to eq([])
|
39
|
+
end
|
40
|
+
|
41
|
+
it "works without json response" do
|
42
|
+
stub_request(:get, Eventify::Provider::Piletilevi::URL.to_s).to_return(body: %q|foo|)
|
43
|
+
expect(Eventify::Provider::Piletilevi.fetch).to eq([])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|