poms 1.2.2 → 2.0.0.a
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +17 -0
- data/.rubocop.yml +24 -0
- data/.ruby-version +1 -0
- data/.todo.reek +50 -0
- data/CHANGELOG.md +1 -0
- data/Gemfile +4 -0
- data/README.md +54 -6
- data/bin/ci-run +57 -0
- data/bin/ci-setup +46 -0
- data/bin/reek +16 -0
- data/bin/rspec +16 -0
- data/bin/rubocop +16 -0
- data/examples/fetch.rb +16 -0
- data/examples/search.rb +17 -0
- data/lib/poms.rb +84 -156
- data/lib/poms/api/auth.rb +42 -22
- data/lib/poms/api/client.rb +58 -0
- data/lib/poms/api/drivers/net_http.rb +69 -0
- data/lib/poms/api/json_client.rb +35 -0
- data/lib/poms/api/pagination_client.rb +67 -0
- data/lib/poms/api/request.rb +29 -31
- data/lib/poms/api/response.rb +31 -0
- data/lib/poms/api/search.rb +38 -0
- data/lib/poms/api/uris.rb +10 -0
- data/lib/poms/api/uris/media.rb +41 -0
- data/lib/poms/api/uris/schedule.rb +28 -0
- data/lib/poms/configuration.rb +59 -0
- data/lib/poms/errors.rb +26 -0
- data/lib/poms/fields.rb +26 -3
- data/lib/poms/timestamp.rb +10 -3
- data/lib/poms/version.rb +1 -1
- data/poms.gemspec +10 -11
- metadata +59 -128
- data/Gemfile.lock +0 -120
- data/lib/poms/base.rb +0 -8
- data/lib/poms/broadcast.rb +0 -55
- data/lib/poms/builder.rb +0 -92
- data/lib/poms/builderless/broadcast.rb +0 -37
- data/lib/poms/builderless/clip.rb +0 -36
- data/lib/poms/connect.rb +0 -11
- data/lib/poms/has_ancestors.rb +0 -54
- data/lib/poms/has_base_attributes.rb +0 -29
- data/lib/poms/merged_series.rb +0 -28
- data/lib/poms/poms_error.rb +0 -5
- data/lib/poms/schedule_event.rb +0 -34
- data/lib/poms/season.rb +0 -13
- data/lib/poms/series.rb +0 -12
- data/lib/poms/views.rb +0 -52
- data/spec/fabricators/poms_fabricator.rb +0 -44
- data/spec/fixtures/poms_broadcast.json +0 -318
- data/spec/fixtures/poms_broadcast_multiple_schedule_events.json +0 -354
- data/spec/fixtures/poms_broadcast_pippi.json +0 -180
- data/spec/fixtures/poms_group.json +0 -1087
- data/spec/fixtures/poms_series.json +0 -49
- data/spec/fixtures/poms_single_broadcast_by_channel.json +0 -136
- data/spec/fixtures/poms_zapp.json +0 -47363
- data/spec/fixtures/vcr_cassettes/poms/builderless/broadcast_starts_at/returns_a_datetime.yml +0 -53
- data/spec/fixtures/vcr_cassettes/poms/builderless/clip/has_a_position.yml +0 -43
- data/spec/fixtures/vcr_cassettes/poms/builderless/clip/has_a_title.yml +0 -43
- data/spec/fixtures/vcr_cassettes/poms/builderless/clip/has_a_video_url.yml +0 -43
- data/spec/fixtures/vcr_cassettes/poms/builderless/clip/has_an_image_id.yml +0 -43
- data/spec/fixtures/vcr_cassettes/poms/fetch_broadcasts_fetch_current_broadcast_fetches_the_current_broadcast.yml +0 -60
- data/spec/fixtures/vcr_cassettes/poms/fetch_broadcasts_fetch_next_broadcast_and_key_fetches_the_current_broadcast.yml +0 -68
- data/spec/fixtures/vcr_cassettes/poms/fetch_broadcasts_fetch_next_broadcast_and_key_returns_the_key.yml +0 -68
- data/spec/fixtures/vcr_cassettes/poms/merged_series/turns_the_json_into_a_hash.yml +0 -46
- data/spec/fixtures/vcr_cassettes/poms_fetch/a_broadcast_has_scheduled_events_with_last_with_starts_at.yml +0 -43
- data/spec/fixtures/vcr_cassettes/poms_fetch/a_clip_has_a_title.yml +0 -43
- data/spec/fixtures/vcr_cassettes/poms_fetch/an_aankeiler_has_images.yml +0 -43
- data/spec/fixtures/vcr_cassettes/poms_fetch_broadcasts_for_serie/returns_nil_when_a_broadcast_does_not_exist.yml +0 -42
- data/spec/fixtures/vcr_cassettes/poms_fetch_current_broadcast/has_a_mid.yml +0 -51
- data/spec/fixtures/vcr_cassettes/poms_fetch_current_broadcast/has_a_title.yml +0 -51
- data/spec/fixtures/vcr_cassettes/poms_fetch_current_broadcast/has_scheduled_events_with_last_with_starts_at.yml +0 -51
- data/spec/fixtures/vcr_cassettes/poms_fetch_current_broadcast_and_key/has_a_broadcast_with_a_mid.yml +0 -51
- data/spec/fixtures/vcr_cassettes/poms_fetch_current_broadcast_and_key/has_a_key.yml +0 -51
- data/spec/fixtures/vcr_cassettes/poms_fetch_descendant_mids/returns_a_list_of_mids.yml +0 -42
- data/spec/fixtures/vcr_cassettes/poms_fetch_descendants_for_serie/builds_a_list_of_broadcasts.yml +0 -102755
- data/spec/fixtures/vcr_cassettes/poms_fetch_group/has_a_child_with_a_media_type.yml +0 -448
- data/spec/fixtures/vcr_cassettes/poms_fetch_group/has_a_child_with_a_title.yml +0 -448
- data/spec/fixtures/vcr_cassettes/poms_fetch_playlist_clips/creates_an_array_of_clips.yml +0 -1051
- data/spec/integration/poms_spec.rb +0 -87
- data/spec/lib/poms/api/auth_spec.rb +0 -34
- data/spec/lib/poms/api/request_spec.rb +0 -30
- data/spec/lib/poms/broadcast_spec.rb +0 -49
- data/spec/lib/poms/builder_spec.rb +0 -53
- data/spec/lib/poms/builderless/broadcast_spec.rb +0 -11
- data/spec/lib/poms/builderless/clip_spec.rb +0 -20
- data/spec/lib/poms/fields_spec.rb +0 -63
- data/spec/lib/poms/merged_series_spec.rb +0 -26
- data/spec/lib/poms/schedule_event_spec.rb +0 -15
- data/spec/lib/poms/timestamp_spec.rb +0 -13
- data/spec/lib/poms/views_spec.rb +0 -38
- data/spec/lib/poms_spec.rb +0 -137
- data/spec/spec_helper.rb +0 -32
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Poms do
|
4
|
-
describe '#fetch_current_broadcast' do
|
5
|
-
let(:current_broadcast) { Poms.fetch_current_broadcast('NED3') }
|
6
|
-
|
7
|
-
it 'has a title' do
|
8
|
-
expect(current_broadcast.title).to be_present
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'has a mid' do
|
12
|
-
expect(current_broadcast.mid).to be_present
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'has scheduled events with last with starts_at' do
|
16
|
-
expect(current_broadcast.schedule_events.last.starts_at).to be_present
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#fetch_current_broadcast_and_key' do
|
21
|
-
let(:current_broadcast) { Poms.fetch_current_broadcast_and_key('NED3') }
|
22
|
-
|
23
|
-
it 'has a key' do
|
24
|
-
expect(current_broadcast[:key]).to be_present
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'has a broadcast with a mid' do
|
28
|
-
expect(current_broadcast[:broadcast].mid).to be_present
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '#fetch an aankeiler' do
|
33
|
-
let(:result) { Poms.fetch('WO_NPO_698651') }
|
34
|
-
|
35
|
-
it 'has images' do
|
36
|
-
expect(result.images.first.image_uri).to be_present
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#fetch a broadcast' do
|
41
|
-
let(:result) { Poms.fetch('POW_00182680') }
|
42
|
-
|
43
|
-
it 'has scheduled events with last with starts_at' do
|
44
|
-
expect(result.schedule_events.last.starts_at).to be_present
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '#fetch a clip' do
|
49
|
-
let(:clip) { Poms.fetch('POMS_EO_622912') }
|
50
|
-
|
51
|
-
it 'has a title' do
|
52
|
-
expect(clip['titles']).to be_present
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe '#fetch_group' do
|
57
|
-
let(:clip) { Poms.fetch_group('POMS_S_NPO_823012')['rows'].first['doc'] }
|
58
|
-
|
59
|
-
it 'has a child with a title' do
|
60
|
-
expect(clip['titles']).to be_present
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'has a child with a media type' do
|
64
|
-
expect(clip['avType']).to be_present
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'has a child with a media type' do
|
68
|
-
expect(clip['mid']).to be_present
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe '#upcoming_broadcasts'
|
73
|
-
|
74
|
-
describe '#fetch_descendant_mids' do
|
75
|
-
let(:result) { Poms.fetch_descendant_mids('POMS_S_KRO_059861') }
|
76
|
-
it 'returns a list of mids' do
|
77
|
-
expect(result.first).to eq('KN_1655665')
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe '#fetch_descendants_for_serie' do
|
82
|
-
let(:result) { Poms.fetch_descendants_for_serie('POMS_S_KRO_059861') }
|
83
|
-
it 'builds a list of broadcasts' do
|
84
|
-
expect(result.first.mid).to eq('KN_1655665')
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'poms/api/auth'
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
RSpec.describe Poms::Api::Auth do
|
5
|
-
describe '.encode' do
|
6
|
-
it 'encodes the message with the secret' do
|
7
|
-
expect(described_class.encode('secret', 'message'))
|
8
|
-
.to eq("i19IcCmVwVmMVz2x4hhmqbgl1KeU0WnXBgoDYFeWNgs=\n")
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '.message' do
|
13
|
-
it 'creates a message' do
|
14
|
-
message = described_class.message(
|
15
|
-
'/v1/api/media/redirects/',
|
16
|
-
'http://zapp.nl',
|
17
|
-
Date.parse('2015-01-01').rfc822)
|
18
|
-
expect(message).to eq(
|
19
|
-
'origin:http://zapp.nl,x-npo-date:Thu, 1 Jan 2015 00:00:00 '\
|
20
|
-
'+0000,uri:/v1/api/media/redirects/')
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'sorts the params' do
|
24
|
-
message = described_class.message(
|
25
|
-
'/v1/api/media/redirects/',
|
26
|
-
'http://zapp.nl',
|
27
|
-
Date.parse('2015-01-01').rfc822,
|
28
|
-
b: 1, a: 2)
|
29
|
-
expect(message).to eq(
|
30
|
-
'origin:http://zapp.nl,x-npo-date:Thu, 1 Jan 2015 00:00:00 '\
|
31
|
-
'+0000,uri:/v1/api/media/redirects/,a:2,b:1')
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'poms/api/request'
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
RSpec.describe Poms::Api::Request do
|
5
|
-
let(:subject) do
|
6
|
-
described_class.new(
|
7
|
-
'https://rs.poms.omroep.nl/v1/api/media/redirects/',
|
8
|
-
'key',
|
9
|
-
'secret',
|
10
|
-
'http://zapp.nl')
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '#call' do
|
14
|
-
it 'makes the request' do
|
15
|
-
stub = stub_request(:get, 'https://rs.poms.omroep.nl/v1/api/media/redirects/')
|
16
|
-
subject.call
|
17
|
-
expect(stub).to have_been_requested
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'sets the headers' do
|
21
|
-
headers = { 'Test' => 'Header' }
|
22
|
-
stub = stub_request(:get,
|
23
|
-
'https://rs.poms.omroep.nl/v1/api/media/redirects/')
|
24
|
-
.with(headers: headers)
|
25
|
-
allow(subject).to receive(:headers).and_return(headers)
|
26
|
-
subject.call
|
27
|
-
expect(stub).to have_been_requested
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Poms::Broadcast do
|
4
|
-
let(:poms_broadcast) { Fabricate(:poms_broadcast) }
|
5
|
-
# pippi langkous is a peculiar case, as it has no series, just a season
|
6
|
-
let(:poms_pippi_langkous) { Fabricate(:poms_broadcast_pippi_langkous) }
|
7
|
-
|
8
|
-
it 'correctly sets the series' do
|
9
|
-
expect(poms_broadcast.serie_mid).to eq('POMS_S_KRO_059857')
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'correctly sets the title' do
|
13
|
-
expect(poms_broadcast.title).to eq('VRijland afl.64 & 65 (herhaling)')
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'correctly sets the description' do
|
17
|
-
description = 'Li biedt Barry een baantje aan bij de uitdragerij en ' \
|
18
|
-
'vraagt zich meteen af of dat wel zo slim was. Timon en Joep zien de ' \
|
19
|
-
'criminele organisatie de Rijland Angels. Timon wil naar hun loods, maar ' \
|
20
|
-
'is dat wel een goed idee?'
|
21
|
-
expect(poms_broadcast.description).to eq(description)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'converts schedule events to Poms::ScheduleEvent' do
|
25
|
-
poms_broadcast.schedule_events.each do |e|
|
26
|
-
expect(e.class).to eq(Poms::ScheduleEvent)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'correctly sets available until' do
|
31
|
-
expect(poms_broadcast.available_until)
|
32
|
-
.to eq(Time.at(1_435_381_968).to_datetime)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'sets the serie correctly when a broadcast only has a season, no series' do
|
36
|
-
expect(poms_pippi_langkous.serie_mid).to eq('POW_00107959')
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'returns the available streams' do
|
40
|
-
expect(poms_broadcast.odi_streams)
|
41
|
-
.to eq(%w(adaptive h264_sb h264_bb h264_std wvc1_std wmv_sb wmv_bb))
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'return the ancestors of the broadcast' do
|
45
|
-
# I use to_set as the order does not matter
|
46
|
-
expect(poms_broadcast.ancestor_mids.to_set)
|
47
|
-
.to eq(%w(POMS_S_KRO_059857 KRO_1521173).to_set)
|
48
|
-
end
|
49
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Poms::Builder do
|
4
|
-
let(:poms_broadcast) { Fabricate(:poms_broadcast) }
|
5
|
-
|
6
|
-
it 'correctly sets the class of a POMS broadcast hash' do
|
7
|
-
expect(poms_broadcast.class).to eq(Poms::Broadcast)
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'correctly renames and parses the broadcast\'s schedule_events' do
|
11
|
-
expect(poms_broadcast.schedule_events.length).to eq(1)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'correctly converts start times to Time-object' do
|
15
|
-
expect(poms_broadcast.schedule_events.first.start)
|
16
|
-
.to eq(Time.parse '2013-05-28 18:08:55 +0200')
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '.pomsify_class_name' do
|
20
|
-
it 'returns "Typeless" for nothing' do
|
21
|
-
expect(described_class.pomsify_class_name(''))
|
22
|
-
.to eq('Typeless')
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'returns a supported class' do
|
26
|
-
expect(described_class.pomsify_class_name('Broadcast'))
|
27
|
-
.to eq('Broadcast')
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'preprends Poms to an unsupported class' do
|
31
|
-
expect(described_class.pomsify_class_name('Other'))
|
32
|
-
.to eq('PomsOther')
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'capitalizes' do
|
36
|
-
expect(described_class.pomsify_class_name('broadcast'))
|
37
|
-
.to eq('Broadcast')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '.poms_class' do
|
42
|
-
it 'gets the Poms class if it exists' do
|
43
|
-
expect(described_class.poms_class('Broadcast'))
|
44
|
-
.to eq(Poms::Broadcast)
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'sets a NestedOpenStruct if it does not exist' do
|
48
|
-
poms_other = described_class.poms_class('PomsOther')
|
49
|
-
expect(poms_other).to eq(Poms::PomsOther)
|
50
|
-
expect(poms_other.ancestors).to include(Poms::Builder::NestedOpenStruct)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Poms::Builderless::Broadcast do
|
4
|
-
let(:subject) { Poms.fetch_current_broadcast('OPVO') }
|
5
|
-
|
6
|
-
describe '#starts_at' do
|
7
|
-
it 'returns a datetime' do
|
8
|
-
expect(subject.schedule_events.first.starts_at).to be_a DateTime
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Poms::Builderless::Clip do
|
4
|
-
let(:clip) { Poms.fetch_clip('WO_NPO_1950962') }
|
5
|
-
|
6
|
-
it 'has a title' do
|
7
|
-
expect(clip.title).to eq 'De wielen van de bus'
|
8
|
-
end
|
9
|
-
it 'has a video url' do
|
10
|
-
expect(clip.video_url).to eq 'http://download.omroep.nl/npo/zappelin/DWVZ_AFL_86_De_wielen_van_de_bus.mp4'
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'has an image id' do
|
14
|
-
expect(clip.image_id).to eq '653515'
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'has a position' do
|
18
|
-
expect(clip.position).to eq 2
|
19
|
-
end
|
20
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Poms::Fields do
|
4
|
-
let(:poms_data) { JSON.parse File.read('spec/fixtures/poms_broadcast.json') }
|
5
|
-
|
6
|
-
describe '#title' do
|
7
|
-
it 'returns the first MAIN title' do
|
8
|
-
expect(described_class.title(poms_data)).to eq('VRijland')
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'returns nil if no title can be found' do
|
12
|
-
expect(described_class.title(poms_data, 'NONEXISTANTTYPE')).to be_nil
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#description' do
|
17
|
-
it 'returns the first MAIN description' do
|
18
|
-
expect(described_class.description(poms_data)).to eq("Li biedt Barry \
|
19
|
-
een baantje aan bij de uitdragerij en vraagt zich meteen af of dat wel zo slim \
|
20
|
-
was. Timon en Joep zien de criminele organisatie de Rijland Angels. Timon wil \
|
21
|
-
naar hun loods, maar is dat wel een goed idee?")
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'returns nil if no description can be found' do
|
25
|
-
expect(described_class.description(poms_data, 'NONEXISTANTTYPE'))
|
26
|
-
.to be_nil
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#first_image_id' do
|
31
|
-
it 'returns the id of the first image' do
|
32
|
-
expect(described_class.first_image_id(poms_data)).to eq('184169')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#rev' do
|
37
|
-
it 'returns the current Poms revision' do
|
38
|
-
expect(described_class.rev(poms_data)).to eq(60)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '#odi_streams' do
|
43
|
-
it 'returns an array of stream types' do
|
44
|
-
expect(described_class.odi_streams(poms_data)).to match_array(
|
45
|
-
%w(adaptive h264_sb h264_bb h264_std wvc1_std wmv_sb wmv_bb))
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#available_until' do
|
50
|
-
it 'returns the enddate of the INTERNETVOD prediction' do
|
51
|
-
expect(described_class.available_until(poms_data))
|
52
|
-
.to eq('Sat, 27 Jun 2015 07:12:48 +0200')
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'returns nil if the INTERNETVOD has no publishStop' do
|
56
|
-
expect(
|
57
|
-
described_class.available_until(
|
58
|
-
'predictions' => [
|
59
|
-
{ 'state' => 'REALIZED', 'platform' => 'INTERNETVOD' }]))
|
60
|
-
.to be_nil
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Poms::MergedSeries do
|
4
|
-
let(:url) { described_class::TEST_URL }
|
5
|
-
|
6
|
-
it 'turns the json into a hash' do
|
7
|
-
mids = subject.serie_mids(url)
|
8
|
-
expect(mids.keys).to include('POMS_S_EO_097367')
|
9
|
-
expect(mids.values).to include('VPWON_1257896')
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'throws an error on a network error' do
|
13
|
-
stub_request(:any, url).to_return(body: '{}', status: 500)
|
14
|
-
expect { subject.serie_mids(url) }.to raise_error(Poms::PomsError)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'throws an error on invalid json' do
|
18
|
-
stub_request(:any, url).to_return(body: 'Test')
|
19
|
-
expect { subject.serie_mids(url) }.to raise_error(Poms::PomsError)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'throws an error on timeout' do
|
23
|
-
stub_request(:any, url).to_timeout
|
24
|
-
expect { subject.serie_mids(url) }.to raise_error(Poms::PomsError)
|
25
|
-
end
|
26
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Poms::ScheduleEvent do
|
4
|
-
let(:poms_broadcast) { Fabricate(:poms_broadcast) }
|
5
|
-
let(:schedule_event) { poms_broadcast.schedule_events.first }
|
6
|
-
|
7
|
-
it 'sets the start time' do
|
8
|
-
expect(schedule_event.starts_at)
|
9
|
-
.to eq(Time.parse '2013-05-28 18:08:55 +0200')
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'knows the end time' do
|
13
|
-
expect(schedule_event.ends_at).to eq(Time.parse '2013-05-28 18:26:24 +0200')
|
14
|
-
end
|
15
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Poms::Timestamp do
|
4
|
-
it 'converts Poms timestamps to DateTime' do
|
5
|
-
expect(Poms::Timestamp.convert(1_453_217_700_000))
|
6
|
-
.to eq(Time.parse '2016-01-19 16:35:00 +0100')
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'returns nil if the argument is falsey' do
|
10
|
-
expect(Poms::Timestamp.convert(nil))
|
11
|
-
.to be_nil
|
12
|
-
end
|
13
|
-
end
|
data/spec/lib/poms/views_spec.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Poms::Views do
|
4
|
-
describe '#get' do
|
5
|
-
let(:response) { File.read 'spec/fixtures/poms_broadcast.json' }
|
6
|
-
|
7
|
-
it 'returns a metadata object' do
|
8
|
-
stub_request(:any, 'http://docs.poms.omroep.nl/media/KRO_1614405')
|
9
|
-
.to_return(body: response)
|
10
|
-
expect(subject.get('KRO_1614405')).to eq(JSON.parse response)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#by_group' do
|
15
|
-
it 'returns the correct group url' do
|
16
|
-
expect(subject.by_group('POMS_S_NPO_823012')).to eq('http://docs.poms.omroep.nl/media/_design/media/_view/by-group?include_docs=true&key=%22POMS_S_NPO_823012%22&reduce=false')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#descendants_by_type' do
|
21
|
-
it 'builds a url' do
|
22
|
-
expect(subject.descendants_by_type('POMS_S_NPO_823012'))
|
23
|
-
.to eq(
|
24
|
-
'http://docs.poms.omroep.nl/media/_design/media/_view/by-ancestor-and-type?include_docs=true&key=%5B%22POMS_S_NPO_823012%22%2C+%22BROADCAST%22%5D&reduce=false'
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'can switch to not include docs' do
|
29
|
-
expect(
|
30
|
-
subject.descendants_by_type('POMS_S_NPO_823012',
|
31
|
-
'BROADCAST',
|
32
|
-
include_docs: false))
|
33
|
-
.to eq(
|
34
|
-
'http://docs.poms.omroep.nl/media/_design/media/_view/by-ancestor-and-type?include_docs=false&key=%5B%22POMS_S_NPO_823012%22%2C+%22BROADCAST%22%5D&reduce=false'
|
35
|
-
)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|