npr 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -4
- data/CHANGELOG.md +27 -1
- data/README.md +5 -10
- data/lib/npr/api/client.rb +6 -6
- data/lib/npr/api/message.rb +5 -5
- data/lib/npr/api/query_builder.rb +22 -23
- data/lib/npr/api/response.rb +7 -7
- data/lib/npr/concern/attr_typecast.rb +11 -13
- data/lib/npr/concern/links_association.rb +26 -0
- data/lib/npr/concern/relation.rb +17 -17
- data/lib/npr/concern/shallow_attributes.rb +12 -12
- data/lib/npr/configuration.rb +27 -27
- data/lib/npr/entity/audio.rb +3 -4
- data/lib/npr/entity/author.rb +3 -3
- data/lib/npr/entity/base.rb +1 -1
- data/lib/npr/entity/book.rb +2 -2
- data/lib/npr/entity/book_edition.rb +5 -5
- data/lib/npr/entity/byline.rb +4 -3
- data/lib/npr/entity/crop.rb +2 -2
- data/lib/npr/entity/enlargement.rb +2 -2
- data/lib/npr/entity/external_asset.rb +27 -0
- data/lib/npr/entity/formats.rb +2 -2
- data/lib/npr/entity/image.rb +4 -4
- data/lib/npr/entity/intro_text.rb +4 -4
- data/lib/npr/entity/link.rb +3 -3
- data/lib/npr/entity/list.rb +2 -4
- data/lib/npr/entity/list_text.rb +2 -2
- data/lib/npr/entity/member.rb +1 -1
- data/lib/npr/entity/member_byline.rb +2 -2
- data/lib/npr/entity/member_promo_art.rb +2 -2
- data/lib/npr/entity/mp3.rb +4 -4
- data/lib/npr/entity/name.rb +4 -4
- data/lib/npr/entity/organization.rb +2 -2
- data/lib/npr/entity/paragraph.rb +2 -2
- data/lib/npr/entity/parent.rb +23 -0
- data/lib/npr/entity/permissions.rb +14 -1
- data/lib/npr/entity/program.rb +7 -5
- data/lib/npr/entity/promo_art.rb +2 -2
- data/lib/npr/entity/promo_art_book_edition.rb +2 -3
- data/lib/npr/entity/provider.rb +4 -4
- data/lib/npr/entity/pull_quote.rb +1 -1
- data/lib/npr/entity/related_link.rb +4 -4
- data/lib/npr/entity/show.rb +3 -3
- data/lib/npr/entity/story.rb +42 -72
- data/lib/npr/entity/text.rb +7 -7
- data/lib/npr/entity/title.rb +4 -4
- data/lib/npr/entity/transcript.rb +2 -2
- data/lib/npr/errors.rb +1 -1
- data/lib/npr/version.rb +1 -1
- data/lib/npr.rb +3 -0
- data/spec/fixtures/fetch_formats.rb +4 -4
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/api/client_spec.rb +4 -4
- data/spec/unit/api/message_spec.rb +9 -9
- data/spec/unit/api/query_builder_spec.rb +39 -39
- data/spec/unit/api/response_spec.rb +8 -8
- data/spec/unit/configuration_spec.rb +14 -14
- data/spec/unit/entity/audio_spec.rb +6 -6
- data/spec/unit/entity/author_spec.rb +3 -3
- data/spec/unit/entity/base_spec.rb +19 -19
- data/spec/unit/entity/book_edition_spec.rb +4 -4
- data/spec/unit/entity/book_spec.rb +2 -2
- data/spec/unit/entity/byline_spec.rb +3 -3
- data/spec/unit/entity/collection_spec.rb +1 -1
- data/spec/unit/entity/crop_spec.rb +2 -2
- data/spec/unit/entity/englargement_spec.rb +2 -2
- data/spec/unit/entity/external_assset_spec.rb +39 -0
- data/spec/unit/entity/formats_spec.rb +4 -4
- data/spec/unit/entity/image_spec.rb +7 -7
- data/spec/unit/entity/intro_text_spec.rb +3 -3
- data/spec/unit/entity/link_spec.rb +3 -3
- data/spec/unit/entity/list_spec.rb +3 -3
- data/spec/unit/entity/list_text_spec.rb +3 -3
- data/spec/unit/entity/member_byline_spec.rb +2 -2
- data/spec/unit/entity/member_promo_art_spec.rb +2 -2
- data/spec/unit/entity/member_spec.rb +4 -4
- data/spec/unit/entity/mp3_spec.rb +4 -4
- data/spec/unit/entity/name_spec.rb +3 -3
- data/spec/unit/entity/organization_spec.rb +2 -2
- data/spec/unit/entity/paragraph_spec.rb +3 -3
- data/spec/unit/entity/parent_spec.rb +39 -0
- data/spec/unit/entity/permissions_spec.rb +16 -6
- data/spec/unit/entity/program_spec.rb +7 -3
- data/spec/unit/entity/promo_art_book_edition_spec.rb +2 -2
- data/spec/unit/entity/promo_art_spec.rb +2 -2
- data/spec/unit/entity/pull_quote_spec.rb +2 -2
- data/spec/unit/entity/related_link_spec.rb +7 -7
- data/spec/unit/entity/show_spec.rb +3 -3
- data/spec/unit/entity/story_spec.rb +35 -36
- data/spec/unit/entity/text_spec.rb +4 -4
- data/spec/unit/entity/title_spec.rb +3 -3
- data/spec/unit/entity/transcript_spec.rb +2 -2
- metadata +10 -8
@@ -5,40 +5,40 @@ describe NPR::API::Response do
|
|
5
5
|
before :each do
|
6
6
|
@client = NPR::API::Client.new(:apiKey => "key")
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
describe "messages" do
|
10
10
|
it "generates messages" do
|
11
11
|
response = mock_response "json/04_invalid_id.json" do
|
12
12
|
@client.query(:id => 999)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
response.messages.size.should eq 1
|
16
16
|
response.messages.first.id.should eq "201"
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "adds the messages association even if there aren't any" do
|
20
20
|
response = mock_response "json/01_story_full_media.json" do
|
21
21
|
@client.query(:id => 999)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
response.messages.should eq []
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
describe "list" do
|
29
29
|
it "is generated" do
|
30
30
|
response = mock_response "json/01_story_full_media.json" do
|
31
31
|
@client.query(:id => 999)
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
response.list.should be_a NPR::Entity::List
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it "isn't generated no list node was present" do
|
38
38
|
response = mock_response "json/05_no_api_key.json" do
|
39
39
|
@client.query(:id => 999)
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
response.list.should eq nil
|
43
43
|
end
|
44
44
|
end
|
@@ -5,58 +5,58 @@ describe NPR::Configuration do
|
|
5
5
|
after :each do
|
6
6
|
NPR.instance_variable_set :@config, nil
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "takes a block to set global configuration" do
|
10
10
|
NPR.configure do |config|
|
11
11
|
config.sort = "cool sorting, bro"
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
NPR.config.sort.should eq "cool sorting, bro"
|
15
15
|
NPR.config.apiKey.should eq nil
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
describe "NPR.config" do
|
20
20
|
it "creates a new NPR::Configure object" do
|
21
21
|
config = NPR.config
|
22
22
|
config.should be_a NPR::Configuration
|
23
|
-
NPR.config.should equal config
|
23
|
+
NPR.config.should equal config
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
#------------------
|
28
|
-
|
28
|
+
|
29
29
|
describe "with options" do
|
30
30
|
it "assigns the passed-in options using the setter" do
|
31
31
|
config = NPR::Configuration.new(:apiKey => "hello")
|
32
32
|
config.apiKey.should eq "hello"
|
33
33
|
end
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
#------------------
|
37
|
-
|
37
|
+
|
38
38
|
describe "#to_hash" do
|
39
39
|
it "converts the config to a hash" do
|
40
40
|
config = NPR::Configuration.new
|
41
41
|
config.sort = "date"
|
42
42
|
config.apiKey = "key"
|
43
|
-
|
43
|
+
|
44
44
|
config.to_hash.should eq Hash[:sort => "date", :apiKey => "key"]
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
#------------------
|
49
|
-
|
49
|
+
|
50
50
|
describe "#merge" do
|
51
51
|
it "turns it into a hash and merges it with the passed-in hash" do
|
52
52
|
config = NPR::Configuration.new
|
53
53
|
config.sort = "date"
|
54
54
|
config.apiKey = "key"
|
55
|
-
|
55
|
+
|
56
56
|
config.merge(:title => "List").should eq Hash[
|
57
57
|
:title => "List",
|
58
|
-
:sort => "date",
|
59
|
-
:apiKey => "key"
|
58
|
+
:sort => "date",
|
59
|
+
:apiKey => "key"
|
60
60
|
]
|
61
61
|
end
|
62
62
|
end
|
@@ -47,11 +47,11 @@ describe NPR::Entity::Audio do
|
|
47
47
|
}
|
48
48
|
JSON
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
before :each do
|
52
52
|
@audio = NPR::Entity::Audio.new(@fixture)
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
it "sets attributes" do
|
56
56
|
@audio.id.should eq 167255688
|
57
57
|
@audio.type.should eq "primary"
|
@@ -60,16 +60,16 @@ describe NPR::Entity::Audio do
|
|
60
60
|
@audio.description.should eq ""
|
61
61
|
@audio.rightsHolder.should eq ""
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
it "sets permissions" do
|
65
65
|
@audio.permissions.should be_a NPR::Entity::Permissions
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
it "sets stream" do
|
69
69
|
@audio.stream.should eq false
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
it "sets format" do
|
73
73
|
@audio.formats.should be_a NPR::Entity::Formats
|
74
|
-
end
|
74
|
+
end
|
75
75
|
end
|
@@ -16,15 +16,15 @@ describe NPR::Entity::Author do
|
|
16
16
|
}
|
17
17
|
JSON
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
before :each do
|
21
21
|
@author = NPR::Entity::Author.new(@fixture)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
it "sets attributes" do
|
25
25
|
@author.id.should eq 139197905
|
26
26
|
@author.num.should eq 3
|
27
27
|
@author.title.should match /Kim/
|
28
28
|
@author.link.should be_a NPR::Entity::Link
|
29
29
|
end
|
30
|
-
end
|
30
|
+
end
|
@@ -6,15 +6,15 @@ describe NPR::Entity::Base do
|
|
6
6
|
@reset = NPR::Entity::Base.send :_shallow_attributes
|
7
7
|
NPR::Entity::Base.shallow_attribute("banjo", "kazooie")
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
after :all do
|
11
11
|
NPR::Entity::Base.send :_shallow_attributes=, @reset
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
it "assigns shallow_attributes" do
|
15
15
|
NPR::Entity::Base._shallow_attributes.should eq ["banjo", "kazooie"]
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "defines accessors" do
|
19
19
|
entity = NPR::Entity::Base.new
|
20
20
|
entity.should respond_to :banjo
|
@@ -23,33 +23,33 @@ describe NPR::Entity::Base do
|
|
23
23
|
entity.should respond_to :kazooie=
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
#--------------------
|
28
|
-
|
28
|
+
|
29
29
|
describe "::has_many" do
|
30
30
|
before :all do
|
31
31
|
@reset = NPR::Entity::Base.send :_has_many_relations
|
32
32
|
NPR::Entity::Base.has_many("objects", :key => "object", :class_name => Object)
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
after :all do
|
36
36
|
NPR::Entity::Base.send :_has_many_relations=, @reset
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
it "assigns relations" do
|
40
|
-
NPR::Entity::Base._has_many_relations.should eq [{
|
41
|
-
:name => "objects",
|
42
|
-
:key => "object",
|
40
|
+
NPR::Entity::Base._has_many_relations.should eq [{
|
41
|
+
:name => "objects",
|
42
|
+
:key => "object",
|
43
43
|
:class_name => Object
|
44
44
|
}]
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
it "defines accessors" do
|
48
48
|
entity = NPR::Entity::Base.new
|
49
49
|
entity.should respond_to :objects
|
50
50
|
entity.should respond_to :objects=
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
it "sets reader to array on first access" do
|
54
54
|
entity = NPR::Entity::Base.new
|
55
55
|
entity.instance_variable_get(:@objects).should eq nil
|
@@ -57,27 +57,27 @@ describe NPR::Entity::Base do
|
|
57
57
|
entity.instance_variable_get(:@objects).should eq []
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
#--------------------
|
62
|
-
|
62
|
+
|
63
63
|
describe "::has_one" do
|
64
64
|
before :all do
|
65
65
|
@reset = NPR::Entity::Base.send :_has_one_relations
|
66
66
|
NPR::Entity::Base.has_one "object", :class_name => Object
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
after :all do
|
70
70
|
NPR::Entity::Base.send :_has_one_relations=, @reset
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
it "assigns relations" do
|
74
74
|
NPR::Entity::Base._has_one_relations.should eq [{
|
75
|
-
:name => "object",
|
76
|
-
:key => "object",
|
75
|
+
:name => "object",
|
76
|
+
:key => "object",
|
77
77
|
:class_name => Object
|
78
78
|
}]
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
it "defines accessor" do
|
82
82
|
entity = NPR::Entity::Base.new
|
83
83
|
entity.should respond_to :object
|
@@ -36,11 +36,11 @@ describe NPR::Entity::BookEdition do
|
|
36
36
|
}
|
37
37
|
JSON
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
before :each do
|
41
41
|
@book_edition = NPR::Entity::BookEdition.new(@fixture)
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
it "sets up attributes" do
|
45
45
|
@book_edition.id.should eq 153611349
|
46
46
|
@book_edition.isbn.should be_a String
|
@@ -50,8 +50,8 @@ describe NPR::Entity::BookEdition do
|
|
50
50
|
@book_edition.pagination.should match /561 pages/
|
51
51
|
@book_edition.listPrice.should match /25\.99/
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
it "creates relations" do
|
55
55
|
@book_edition.book.should be_a NPR::Entity::Book
|
56
56
|
end
|
57
|
-
end
|
57
|
+
end
|
@@ -15,7 +15,7 @@ describe NPR::Entity::Book do
|
|
15
15
|
}
|
16
16
|
JSON
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
before :each do
|
20
20
|
@book = NPR::Entity::Book.new(@fixture)
|
21
21
|
end
|
@@ -24,7 +24,7 @@ describe NPR::Entity::Book do
|
|
24
24
|
@book.id.should eq 153611337
|
25
25
|
@book.title.should eq "2312"
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "creates relations" do
|
29
29
|
@book.link.should be_a NPR::Entity::Link
|
30
30
|
end
|
@@ -22,16 +22,16 @@ describe NPR::Entity::Byline do
|
|
22
22
|
}
|
23
23
|
JSON
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
before :each do
|
27
27
|
@byline = NPR::Entity::Byline.new(@fixture)
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
it "sets up attributes" do
|
31
31
|
@byline.id.should be_a Fixnum
|
32
32
|
@byline.id.should_not eq 0
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
it "creates relations" do
|
36
36
|
@byline.links.size.should eq 2
|
37
37
|
@byline.links.first.should be_a NPR::Entity::Link
|
@@ -9,11 +9,11 @@ describe NPR::Entity::Enlargement do
|
|
9
9
|
}
|
10
10
|
JSON
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
before :each do
|
14
14
|
@enlargement = NPR::Entity::Enlargement.new(@fixture)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "sets attributes" do
|
18
18
|
@enlargement.src.should match /media\.npr/
|
19
19
|
@enlargement.caption.should eq ""
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe NPR::Entity::ExternalAsset do
|
4
|
+
json_fixture do
|
5
|
+
<<-JSON
|
6
|
+
{
|
7
|
+
"id": "206744041",
|
8
|
+
"type": "Twitter",
|
9
|
+
"url": {
|
10
|
+
"$text": "https://twitter.com/danmericaCNN/statuses/361945098524717056"
|
11
|
+
},
|
12
|
+
"oEmbed": {
|
13
|
+
"$text": "oembed-361945098524717056"
|
14
|
+
},
|
15
|
+
"externalId": {
|
16
|
+
"$text": "361945098524717056"
|
17
|
+
},
|
18
|
+
"credit": {},
|
19
|
+
"parameters": {},
|
20
|
+
"caption": {}
|
21
|
+
}
|
22
|
+
JSON
|
23
|
+
end
|
24
|
+
|
25
|
+
# NOTE: I couldn't find an externalAsset in the API which actually
|
26
|
+
# has "credit", "parameters", or "caption" filled in, and this node
|
27
|
+
# isn't documented, so I kind of have no idea what they are.
|
28
|
+
before :each do
|
29
|
+
@external_asset = NPR::Entity::ExternalAsset.new(@fixture)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "sets attributes" do
|
33
|
+
@external_asset.id.should eq 206744041
|
34
|
+
@external_asset.type.should eq "Twitter"
|
35
|
+
@external_asset.url.should match /danmericaCNN/
|
36
|
+
@external_asset.oEmbed.should eq "oembed-361945098524717056"
|
37
|
+
@external_asset.externalId.should eq "361945098524717056"
|
38
|
+
end
|
39
|
+
end
|
@@ -23,19 +23,19 @@ describe NPR::Entity::Formats do
|
|
23
23
|
}
|
24
24
|
JSON
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
before :each do
|
28
28
|
@formats = NPR::Entity::Formats.new(@fixture)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
it "sets up attributes" do
|
32
32
|
@formats.wm.should match /npr\.org/
|
33
33
|
@formats.rm.should eq nil
|
34
34
|
@formats.mediastream.should match /flash/
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it "creates relations" do
|
38
38
|
@formats.mp3s.size.should eq 2
|
39
39
|
@formats.mp3s.first.should be_a NPR::Entity::MP3
|
40
40
|
end
|
41
|
-
end
|
41
|
+
end
|
@@ -45,11 +45,11 @@ describe NPR::Entity::Image do
|
|
45
45
|
}
|
46
46
|
JSON
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
before :each do
|
50
50
|
@image = NPR::Entity::Image.new(@fixture)
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
it "sets attributes" do
|
54
54
|
@image.id.should eq 167273389
|
55
55
|
@image.type.should eq "standard"
|
@@ -58,28 +58,28 @@ describe NPR::Entity::Image do
|
|
58
58
|
@image.hasBorder.should eq false
|
59
59
|
@image.link.should eq ""
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
it "sets enlargement" do
|
63
63
|
@image.enlargement.should be_a NPR::Entity::Enlargement
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
it "sets provider" do
|
67
67
|
@image.provider.url.should eq ""
|
68
68
|
@image.provider.to_s.should match /Brendan./
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
it "sets crops" do
|
72
72
|
@image.crops.size.should eq 2
|
73
73
|
@image.crops.first.should be_a NPR::Entity::Crop
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
it "sets shallow attributes" do
|
77
77
|
@image.title.should match /Jason/
|
78
78
|
@image.caption.should match /Geri/
|
79
79
|
@image.producer.should eq ""
|
80
80
|
@image.copyright.should eq ""
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
it "responds to type methods" do
|
84
84
|
@image.primary?.should eq false
|
85
85
|
@image.standard?.should eq true
|
@@ -9,16 +9,16 @@ describe NPR::Entity::IntroText do
|
|
9
9
|
}
|
10
10
|
JSON
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
before :each do
|
14
14
|
@intro_text = NPR::Entity::IntroText.new(@fixture)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "sets attributes" do
|
18
18
|
@intro_text.num.should eq 5
|
19
19
|
@intro_text.content.should match /sweeping space opera/
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "uses @content for to_s" do
|
23
23
|
@intro_text.to_s.should eq @intro_text.content
|
24
24
|
end
|
@@ -9,16 +9,16 @@ describe NPR::Entity::Link do
|
|
9
9
|
}
|
10
10
|
JSON
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
before :each do
|
14
14
|
@link = NPR::Entity::Link.new(@fixture)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "sets attributes" do
|
18
18
|
@link.type.should eq "html"
|
19
19
|
@link.content.should match /npr\.org/
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "uses @content for to_s" do
|
23
23
|
@link.to_s.should match /npr\.org/
|
24
24
|
end
|
@@ -5,16 +5,16 @@ describe NPR::Entity::List do
|
|
5
5
|
response = mock_response "json/01_story_full_media.json" do
|
6
6
|
NPR::API::Client.new(:apiKey => "key").query(:id => 999)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
@list = response.list
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "extracts the attributes" do
|
13
13
|
@list.title.should match /NPR/
|
14
14
|
@list.teaser.should match /NPR/
|
15
15
|
@list.miniTeaser.should match /NPR/
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "sets up relations" do
|
19
19
|
@list.links.size.should eq 2
|
20
20
|
@list.stories.size.should eq 1
|
@@ -15,16 +15,16 @@ describe NPR::Entity::ListText do
|
|
15
15
|
}
|
16
16
|
JSON
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
before :each do
|
20
20
|
@list_text = NPR::Entity::ListText.new(@fixture)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "sets up attributes" do
|
24
24
|
@list_text.id.should eq 166558361
|
25
25
|
@list_text.tag.should eq "p"
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "sets up relations" do
|
29
29
|
@list_text.paragraphs.first.should be_a NPR::Entity::Paragraph
|
30
30
|
end
|
@@ -9,11 +9,11 @@ describe NPR::Entity::MemberByline do
|
|
9
9
|
}
|
10
10
|
JSON
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
before :each do
|
14
14
|
@member_byline = NPR::Entity::MemberByline.new(@fixture)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "sets attributes" do
|
18
18
|
@member_byline.refId.should eq 166481286
|
19
19
|
@member_byline.num.should eq 6
|
@@ -9,11 +9,11 @@ describe NPR::Entity::MemberPromoArt do
|
|
9
9
|
}
|
10
10
|
JSON
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
before :each do
|
14
14
|
@member_promo_art = NPR::Entity::MemberPromoArt.new(@fixture)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "sets attributes" do
|
18
18
|
@member_promo_art.refId.should eq 153611356
|
19
19
|
@member_promo_art.num.should eq 1
|
@@ -39,15 +39,15 @@ describe NPR::Entity::Member do
|
|
39
39
|
}
|
40
40
|
JSON
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
before :each do
|
44
44
|
@member = NPR::Entity::Member.new(@fixture)
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
it "sets up attributes" do
|
48
48
|
@member.id.should eq 166481250
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
it "sets up relations" do
|
52
52
|
@member.promoArt.should be_a NPR::Entity::MemberPromoArt
|
53
53
|
@member.title.should be_a NPR::Entity::Title
|
@@ -56,4 +56,4 @@ describe NPR::Entity::Member do
|
|
56
56
|
@member.introText.should be_a NPR::Entity::IntroText
|
57
57
|
@member.byline.should be_a NPR::Entity::MemberByline
|
58
58
|
end
|
59
|
-
end
|
59
|
+
end
|
@@ -9,17 +9,17 @@ describe NPR::Entity::MP3 do
|
|
9
9
|
}
|
10
10
|
JSON
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
before :each do
|
14
14
|
@mp3 = NPR::Entity::MP3.new(@fixture)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "sets attributes" do
|
18
18
|
@mp3.type.should eq "mp3"
|
19
19
|
@mp3.content.should match /pd\.npr/
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "uses @content for #to_s" do
|
23
23
|
@mp3.to_s.should eq @mp3.content
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
@@ -9,16 +9,16 @@ describe NPR::Entity::Name do
|
|
9
9
|
}
|
10
10
|
JSON
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
before :each do
|
14
14
|
@name = NPR::Entity::Name.new(@fixture)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "sets attributes" do
|
18
18
|
@name.personId.should eq 134991966
|
19
19
|
@name.content.should match /Julie/
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "uses @content for to_s" do
|
23
23
|
@name.to_s.should eq @name.content
|
24
24
|
end
|