marver 0.0.0 → 0.0.2
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/.ruby-version +1 -0
- data/Gemfile +13 -0
- data/LICENSE +20 -0
- data/README.md +32 -0
- data/Rakefile +1 -0
- data/lib/marver.rb +35 -21
- data/lib/marver/builders/common_entities_builder.rb +46 -0
- data/lib/marver/builders/core_entities_builder.rb +34 -0
- data/lib/marver/client.rb +13 -0
- data/lib/marver/credentials.rb +23 -0
- data/lib/marver/data_container.rb +18 -0
- data/lib/marver/entities/common/image.rb +9 -0
- data/lib/marver/entities/common/key_date.rb +10 -0
- data/lib/marver/entities/common/price.rb +10 -0
- data/lib/marver/entities/common/text_object.rb +11 -0
- data/lib/marver/entities/common/url.rb +10 -0
- data/lib/marver/entities/core/character.rb +35 -0
- data/lib/marver/entities/core/comic.rb +46 -0
- data/lib/marver/entities/core/creator.rb +36 -0
- data/lib/marver/entities/core/event.rb +35 -0
- data/lib/marver/entities/core/serie.rb +37 -0
- data/lib/marver/entities/core/story.rb +36 -0
- data/lib/marver/entities/summaries/character_summary.rb +22 -0
- data/lib/marver/entities/summaries/comic_summary.rb +20 -0
- data/lib/marver/entities/summaries/creator_summary.rb +12 -0
- data/lib/marver/entities/summaries/event_summary.rb +14 -0
- data/lib/marver/entities/summaries/serie_summary.rb +13 -0
- data/lib/marver/entities/summaries/story_summary.rb +14 -0
- data/lib/marver/finders/character_finder.rb +24 -0
- data/lib/marver/helpers/string_helper.rb +36 -0
- data/lib/marver/rest/client.rb +22 -0
- data/lib/marver/rest/error.rb +13 -0
- data/lib/marver/rest/response.rb +18 -0
- data/lib/marver/version.rb +3 -0
- data/marver.gemspec +23 -0
- data/spec/fixtures/character.json +398 -0
- data/spec/fixtures/comic.json +243 -0
- data/spec/fixtures/creator.json +345 -0
- data/spec/fixtures/event.json +104 -0
- data/spec/fixtures/raw_json.json +398 -0
- data/spec/fixtures/serie.json +102 -0
- data/spec/fixtures/story.json +94 -0
- data/spec/marver/client_spec.rb +12 -0
- data/spec/marver/credentials_spec.rb +19 -0
- data/spec/marver/data_container_spec.rb +23 -0
- data/spec/marver/entities/core/character_spec.rb +76 -0
- data/spec/marver/entities/core/comic_spec.rb +150 -0
- data/spec/marver/entities/core/creator_spec.rb +83 -0
- data/spec/marver/entities/core/event_spec.rb +106 -0
- data/spec/marver/entities/core/serie_spec.rb +106 -0
- data/spec/marver/entities/core/story_spec.rb +70 -0
- data/spec/marver/entities/image_spec.rb +9 -0
- data/spec/marver/entities/key_date_spec.rb +17 -0
- data/spec/marver/entities/price_spec.rb +13 -0
- data/spec/marver/entities/summaries/character_summary_spec.rb +65 -0
- data/spec/marver/entities/summaries/comic_summary_spec.rb +64 -0
- data/spec/marver/entities/summaries/creator_summary_spec.rb +23 -0
- data/spec/marver/entities/summaries/event_summary_spec.rb +30 -0
- data/spec/marver/entities/summaries/serie_summary_spec.rb +26 -0
- data/spec/marver/entities/summaries/story_summary_spec.rb +30 -0
- data/spec/marver/entities/text_object_spec.rb +20 -0
- data/spec/marver/entities/url_spec.rb +16 -0
- data/spec/marver/finders/character_finder_spec.rb +27 -0
- data/spec/marver/rest/client_spec.rb +10 -0
- data/spec/marver/rest/error_spec.rb +14 -0
- data/spec/marver/rest/response_spec.rb +22 -0
- data/spec/spec_helper.rb +17 -0
- metadata +137 -8
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
|
+
require './lib/marver.rb'
|
4
|
+
|
5
|
+
describe Marver::Creator do
|
6
|
+
|
7
|
+
let(:json) { fixture('creator.json').read }
|
8
|
+
let(:response) { Marver::REST::Response.new(json) }
|
9
|
+
let(:credentials) { Marver::Credentials.new('pub_key', 'priv_key') }
|
10
|
+
let(:data_container) { Marver::DataContainer.new(response) }
|
11
|
+
let(:creator) { Marver::Creator.new(data_container.results, credentials) }
|
12
|
+
|
13
|
+
it '#id - The unique ID of the creator resource.' do
|
14
|
+
expect(creator.id).to eq 648
|
15
|
+
end
|
16
|
+
|
17
|
+
it '#first_name - The first name of the creator.' do
|
18
|
+
expect(creator.first_name).to eq "Simone"
|
19
|
+
end
|
20
|
+
|
21
|
+
it '#middle_name - The middle name of the creator.' do
|
22
|
+
expect(creator.middle_name).to eq ""
|
23
|
+
end
|
24
|
+
|
25
|
+
it '#last_name - The last name of the creator.' do
|
26
|
+
expect(creator.last_name).to eq "Bianchi"
|
27
|
+
end
|
28
|
+
|
29
|
+
it '#suffix - The suffix or honorific for the creator.' do
|
30
|
+
expect(creator.suffix).to eq ''
|
31
|
+
end
|
32
|
+
|
33
|
+
it '#full_name - The full name of the creator (a space-separated concatenation of the above four fields).' do
|
34
|
+
expect(creator.full_name).to eq "Simone Bianchi"
|
35
|
+
end
|
36
|
+
|
37
|
+
it '#resource_uri - The canonical URL identifier for this resource.' do
|
38
|
+
expect(creator.resource_uri).to eq "http://gateway.marvel.com/v1/public/creators/648"
|
39
|
+
end
|
40
|
+
|
41
|
+
it '#urls - A set of public web site URLs for the resource.' do
|
42
|
+
expect(creator.urls.class).to eq Array
|
43
|
+
expect(creator.urls.first.class).to eq Marver::Url
|
44
|
+
expect(creator.urls.first.url).to eq "http://marvel.com/comics/creators/648/simone_bianchi?utm_campaign=apiRef&utm_source=f302f582215c3deedff86e8015f853c7"
|
45
|
+
end
|
46
|
+
|
47
|
+
it '#thumbnail - The representative image for this creator.' do
|
48
|
+
expect(creator.thumbnail.class).to eq Marver::Image
|
49
|
+
expect(creator.thumbnail.full_path).to eq "http://i.annihil.us/u/prod/marvel/i/mg/f/30/4bc5a8bb82ff1.jpg"
|
50
|
+
end
|
51
|
+
|
52
|
+
it '#series - A resource list containing the series which feature work by this creator.' do
|
53
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return '1'
|
54
|
+
expect(creator.series.class).to eq Array
|
55
|
+
expect(creator.series.first.class).to eq Marver::SerieSummary
|
56
|
+
expect(creator.series.first.name).to eq "Age of X: Universe (2011)"
|
57
|
+
expect(creator.series.first.resource_uri).to eq "http://gateway.marvel.com/v1/public/series/13896?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
58
|
+
end
|
59
|
+
|
60
|
+
it '#comics - A resource list containing the stories which feature work by this creator' do
|
61
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return '1'
|
62
|
+
expect(creator.comics.class).to eq Array
|
63
|
+
expect(creator.comics.first.class).to eq Marver::ComicSummary
|
64
|
+
expect(creator.comics.first.name).to eq "Age of X: Universe (2011) #1"
|
65
|
+
expect(creator.comics.first.resource_uri).to eq "http://gateway.marvel.com/v1/public/comics/38524?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
66
|
+
end
|
67
|
+
|
68
|
+
it '#stories - A resource list containing the comics which feature work by this creator.' do
|
69
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return '1'
|
70
|
+
expect(creator.stories.class).to eq Array
|
71
|
+
expect(creator.stories.first.class).to eq Marver::StorySummary
|
72
|
+
expect(creator.stories.first.name).to eq "1 of 6 - Evolution"
|
73
|
+
expect(creator.stories.first.resource_uri).to eq "http://gateway.marvel.com/v1/public/stories/2243?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
74
|
+
end
|
75
|
+
|
76
|
+
it '#events - A resource list containing the events which feature work by this creator.' do
|
77
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return '1'
|
78
|
+
expect(creator.events.class).to eq Array
|
79
|
+
expect(creator.events.first.class).to eq Marver::EventSummary
|
80
|
+
expect(creator.events.first.name).to eq "Age of X"
|
81
|
+
expect(creator.events.first.resource_uri).to eq "http://gateway.marvel.com/v1/public/events/303?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
|
+
require './lib/marver.rb'
|
4
|
+
|
5
|
+
describe Marver::Event do
|
6
|
+
let(:json) { fixture('event.json').read }
|
7
|
+
let(:response) { Marver::REST::Response.new(json) }
|
8
|
+
let(:credentials) { Marver::Credentials.new('pub_key', 'priv_key') }
|
9
|
+
let(:data_container) { Marver::DataContainer.new(response) }
|
10
|
+
let(:event) { Marver::Event.new(data_container.results, credentials) }
|
11
|
+
|
12
|
+
it "#title - The title of the event." do
|
13
|
+
expect(event.title).to eq "Fall of the Mutants"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "#resourceURI - The canonical URL identifier for this resource." do
|
17
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
18
|
+
expect(event.resource_uri).to eq "http://gateway.marvel.com/v1/public/events/248?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
19
|
+
end
|
20
|
+
|
21
|
+
it '#description - A description of the event.' do
|
22
|
+
expect(event.description).to eq "The X-Men battled the Adversary in Dallas, and X-Factor clashed with the Horsemen of Apocalypse in New York, while the New Mutants confronted the insane Ani-Mator on Paradise Island."
|
23
|
+
end
|
24
|
+
|
25
|
+
it '#urls - A set of public web site URLs for the event.' do
|
26
|
+
expect(event.urls.class).to eq Array
|
27
|
+
expect(event.urls.first.class).to eq Marver::Url
|
28
|
+
expect(event.urls.first.type).to eq 'detail'
|
29
|
+
expect(event.urls.first.url).to eq "http://marvel.com/comics/events/248/fall_of_the_mutants?utm_campaign=apiRef&utm_source=f302f582215c3deedff86e8015f853c7"
|
30
|
+
end
|
31
|
+
|
32
|
+
it '#start - The date of publication of the first issue in this event.' do
|
33
|
+
expect(event.start.class).to eq Date
|
34
|
+
expect(event.start.year).to eq 1988
|
35
|
+
expect(event.start.month).to eq 01
|
36
|
+
expect(event.start.day).to eq 10
|
37
|
+
end
|
38
|
+
|
39
|
+
it '#end - The date of publication of the last issue in this event.' do
|
40
|
+
expect(event.end.class).to eq Date
|
41
|
+
expect(event.end.year).to eq 2007
|
42
|
+
expect(event.end.month).to eq 01
|
43
|
+
expect(event.end.day).to eq 17
|
44
|
+
end
|
45
|
+
|
46
|
+
it '#thumbnail - The representative image for this event.' do
|
47
|
+
expect(event.thumbnail.class).to eq Marver::Image
|
48
|
+
expect(event.thumbnail.full_path).to eq "http://i.annihil.us/u/prod/marvel/i/mg/8/a0/51cb2f521ae35.jpg"
|
49
|
+
end
|
50
|
+
|
51
|
+
it '#comics - A resource list containing the comics in this event.' do
|
52
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
53
|
+
expect(event.comics.class).to eq Array
|
54
|
+
expect(event.comics.first.class).to eq Marver::ComicSummary
|
55
|
+
expect(event.comics.first.name).to eq "Captain America (1968) #339"
|
56
|
+
expect(event.comics.first.resource_uri).to eq "http://gateway.marvel.com/v1/public/comics/7720?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
57
|
+
end
|
58
|
+
|
59
|
+
it '#stories - A resource list containing the stories in this event.' do
|
60
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
61
|
+
expect(event.stories.class).to eq Array
|
62
|
+
expect(event.stories.first.class).to eq Marver::StorySummary
|
63
|
+
expect(event.stories.first.name).to eq "Fall of the Mutants"
|
64
|
+
expect(event.stories.first.resource_uri).to eq "http://gateway.marvel.com/v1/public/stories/22222?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
65
|
+
expect(event.stories.first.type).to eq 'cover'
|
66
|
+
end
|
67
|
+
|
68
|
+
it '#series - A resource list containing the series in this event.' do
|
69
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
70
|
+
expect(event.series.class).to eq Array
|
71
|
+
expect(event.series.first.class).to eq Marver::SerieSummary
|
72
|
+
expect(event.series.first.name).to eq "Daredevil (1963 - 1998)"
|
73
|
+
expect(event.series.first.resource_uri).to eq "http://gateway.marvel.com/v1/public/series/2002?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
74
|
+
end
|
75
|
+
|
76
|
+
it '#characters - A resource list containing the characters which appear in this event.' do
|
77
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
78
|
+
expect(event.characters.class).to eq Array
|
79
|
+
expect(event.characters.first.class).to eq Marver::CharacterSummary
|
80
|
+
expect(event.characters.first.name).to eq "Havok"
|
81
|
+
expect(event.characters.first.resource_uri).to eq "http://gateway.marvel.com/v1/public/characters/1009337?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
82
|
+
end
|
83
|
+
|
84
|
+
it '#creators - A resource list containing creators whose work appears in this event.' do
|
85
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
86
|
+
expect(event.creators.class).to eq Array
|
87
|
+
expect(event.creators.first.class).to eq Marver::CreatorSummary
|
88
|
+
expect(event.creators.first.name).to eq "Mark Gruenwald"
|
89
|
+
expect(event.creators.first.role).to eq "writer"
|
90
|
+
expect(event.creators.first.resource_uri).to eq "http://gateway.marvel.com/v1/public/creators/259?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
91
|
+
end
|
92
|
+
|
93
|
+
it '#next - A summary representation of the event which follows this event.' do
|
94
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
95
|
+
expect(event.next.class).to eq Marver::EventSummary
|
96
|
+
expect(event.next.resource_uri).to eq "http://gateway.marvel.com/v1/public/events/252?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
97
|
+
expect(event.next.type).to eq nil
|
98
|
+
end
|
99
|
+
|
100
|
+
it '#previous - A summary representation of the event which preceded this event.' do
|
101
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
102
|
+
expect(event.previous.class).to eq Marver::EventSummary
|
103
|
+
expect(event.previous.resource_uri).to eq "http://gateway.marvel.com/v1/public/events/246?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
104
|
+
expect(event.previous.type).to eq nil
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
|
+
require './lib/marver.rb'
|
4
|
+
|
5
|
+
describe Marver::Serie do
|
6
|
+
|
7
|
+
let(:json) { fixture('serie.json').read }
|
8
|
+
let(:response) { Marver::REST::Response.new(json) }
|
9
|
+
let(:credentials) { Marver::Credentials.new('pub_key', 'priv_key') }
|
10
|
+
let(:data_container) { Marver::DataContainer.new(response) }
|
11
|
+
let(:serie) { Marver::Serie.new(data_container.results, credentials) }
|
12
|
+
|
13
|
+
it '#id - The unique ID of the series resource.' do
|
14
|
+
expect(serie.id).to eq 2002
|
15
|
+
end
|
16
|
+
|
17
|
+
it '#description - A description of the series.' do
|
18
|
+
expect(serie.description).to eq "Join the Man Without Fear as he stands up for justice! Blind lawyer Matt Murdock protects the streets of Hell's Kitchen by night against dangerous foes like Bullseye and the Kingpin! Includes the classic stories by icon Frank Miller that changed comics forever."
|
19
|
+
end
|
20
|
+
|
21
|
+
it '#urls - A set of public web site URLs for the resource.' do
|
22
|
+
expect(serie.urls.class).to eq Array
|
23
|
+
expect(serie.urls.first.url).to eq "http://marvel.com/comics/series/2002/daredevil_1963_-_1998?utm_campaign=apiRef&utm_source=f302f582215c3deedff86e8015f853c7"
|
24
|
+
expect(serie.urls.first.type).to eq "detail"
|
25
|
+
expect(serie.urls.first.class).to eq Marver::Url
|
26
|
+
end
|
27
|
+
|
28
|
+
it '#start_year - The first year of publication for the series.' do
|
29
|
+
expect(serie.start_year).to eq 1963
|
30
|
+
end
|
31
|
+
|
32
|
+
it '#end_year - The last year of publication for the series (conventionally, 2099 for ongoing series).' do
|
33
|
+
expect(serie.end_year).to eq 1998
|
34
|
+
end
|
35
|
+
|
36
|
+
it '#rating - The age-appropriateness rating for the series.' do
|
37
|
+
expect(serie.rating).to eq ""
|
38
|
+
end
|
39
|
+
|
40
|
+
it '#thumbnail - The representative image for this series.' do
|
41
|
+
expect(serie.thumbnail.full_path).to eq "http://i.annihil.us/u/prod/marvel/i/mg/1/00/5130f628766d9.jpg"
|
42
|
+
expect(serie.thumbnail.class).to eq Marver::Image
|
43
|
+
end
|
44
|
+
|
45
|
+
it '#comics - A resource list containing comics in this series.' do
|
46
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
47
|
+
expect(serie.comics.class).to eq Array
|
48
|
+
expect(serie.comics.first.class).to eq Marver::ComicSummary
|
49
|
+
expect(serie.comics.first.name).to eq "Daredevil (1963)"
|
50
|
+
expect(serie.comics.first.resource_uri).to eq "http://gateway.marvel.com/v1/public/comics/8072?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
51
|
+
end
|
52
|
+
|
53
|
+
it '#stories - A resource list containing stories which occur in comics in this series.' do
|
54
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
55
|
+
expect(serie.stories.class).to eq Array
|
56
|
+
expect(serie.stories.first.class).to eq Marver::StorySummary
|
57
|
+
expect(serie.stories.first.name).to eq "Life Be Not Proud!"
|
58
|
+
expect(serie.stories.first.resource_uri).to eq "http://gateway.marvel.com/v1/public/stories/15722?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
59
|
+
expect(serie.stories.first.type).to eq "interiorStory"
|
60
|
+
end
|
61
|
+
|
62
|
+
it '#events - A resource list containing events which take place in comics in this series.' do
|
63
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
64
|
+
expect(serie.events.class).to eq Array
|
65
|
+
expect(serie.events.first.class).to eq Marver::EventSummary
|
66
|
+
expect(serie.events.first.name).to eq "Acts of Vengeance!"
|
67
|
+
expect(serie.events.first.resource_uri).to eq "http://gateway.marvel.com/v1/public/events/116?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
68
|
+
end
|
69
|
+
|
70
|
+
it '#characters - A resource list containing characters which appear in comics in this series.' do
|
71
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
72
|
+
expect(serie.characters.class).to eq Array
|
73
|
+
expect(serie.characters.first.class).to eq Marver::CharacterSummary
|
74
|
+
expect(serie.characters.first.name).to eq "Beast"
|
75
|
+
expect(serie.characters.first.resource_uri).to eq "http://gateway.marvel.com/v1/public/characters/1009175?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
76
|
+
end
|
77
|
+
|
78
|
+
it '#creators - A resource list of creators whose work appears in comics in this series.' do
|
79
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
80
|
+
expect(serie.creators.class).to eq Array
|
81
|
+
expect(serie.creators.first.class).to eq Marver::CreatorSummary
|
82
|
+
expect(serie.creators.first.name).to eq "Mark Bagley"
|
83
|
+
expect(serie.creators.first.resource_uri).to eq "http://gateway.marvel.com/v1/public/creators/87?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
84
|
+
expect(serie.creators.first.role).to eq "penciller (cover)"
|
85
|
+
end
|
86
|
+
|
87
|
+
it '#next - A summary representation of the series which follows this series.' do
|
88
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
89
|
+
expect(serie.next.class).to eq Marver::SerieSummary
|
90
|
+
expect(serie.next.resource_uri).to eq "http://gateway.marvel.com/v1/public/series/449?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
91
|
+
end
|
92
|
+
|
93
|
+
it '#previous - A summary representation of the series which preceded this series.' do
|
94
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
95
|
+
expect(serie.previous.class).to eq Marver::SerieSummary
|
96
|
+
expect(serie.previous.resource_uri).to eq "http://gateway.marvel.com/v1/public/series/449?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
97
|
+
end
|
98
|
+
|
99
|
+
it "#title - Serie's title" do
|
100
|
+
expect(serie.title).to eq "Daredevil (1963 - 1998)"
|
101
|
+
end
|
102
|
+
|
103
|
+
it "#resource_uri - Full cannonical URL of the entity" do
|
104
|
+
expect(serie.resource_uri).to eq "http://gateway.marvel.com/v1/public/series/2002"
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Marver::Story do
|
4
|
+
describe "Attributes" do
|
5
|
+
let(:json) { fixture('story.json').read }
|
6
|
+
let(:response) { Marver::REST::Response.new(json) }
|
7
|
+
let(:credentials) { Marver::Credentials.new('pub_key', 'priv_key') }
|
8
|
+
let(:data_container) { Marver::DataContainer.new(response) }
|
9
|
+
let(:story) { Marver::Story.new(data_container.results, credentials) }
|
10
|
+
|
11
|
+
it "#title - The story title." do
|
12
|
+
expect(story.title).to eq "Cover #892"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "#type - The story type e.g. interior story, cover, text story." do
|
16
|
+
expect(story.type).to eq "cover"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "#resource_uri - The canonical URL identifier for this resource." do
|
20
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
21
|
+
expect(story.resource_uri).to eq "http://gateway.marvel.com/v1/public/stories/892?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
22
|
+
end
|
23
|
+
|
24
|
+
it '#description - A short description of the story.' do
|
25
|
+
expect(story.description).to eq ""
|
26
|
+
end
|
27
|
+
|
28
|
+
it '#thumbnail - The representative image for this story.' do
|
29
|
+
expect(story.description).to eq ""
|
30
|
+
end
|
31
|
+
|
32
|
+
it '#comics - A resource list containing comics in which this story takes place.' do
|
33
|
+
expect(story.comics.class).to eq Array
|
34
|
+
expect(story.comics.first.class).to eq Marver::ComicSummary
|
35
|
+
expect(story.comics.first.name).to eq "Thor (1998) #81"
|
36
|
+
end
|
37
|
+
|
38
|
+
it '#series - A resource list containing series in which this story appears.' do
|
39
|
+
expect(story.series.class).to eq Array
|
40
|
+
expect(story.series.first.class).to eq Marver::SerieSummary
|
41
|
+
expect(story.series.first.name).to eq "Thor (1998 - 2004)"
|
42
|
+
end
|
43
|
+
|
44
|
+
it '#events - A resource list of the events in which this story appears.' do
|
45
|
+
expect(story.events.class).to eq Array
|
46
|
+
expect(story.events.first.class).to eq Marver::EventSummary
|
47
|
+
expect(story.events.first.name).to eq "Avengers Disassembled"
|
48
|
+
end
|
49
|
+
|
50
|
+
it '#characters - A resource list of characters which appear in this story.' do
|
51
|
+
expect(story.characters.class).to eq Array
|
52
|
+
expect(story.characters.first.class).to eq Marver::CharacterSummary
|
53
|
+
expect(story.characters.first.name).to eq "Avengers"
|
54
|
+
end
|
55
|
+
|
56
|
+
it '#creators - A resource list of creators who worked on this story.' do
|
57
|
+
expect(story.creators.class).to eq Array
|
58
|
+
expect(story.creators.first.class).to eq Marver::CreatorSummary
|
59
|
+
expect(story.creators.first.name).to eq "Steve Epting"
|
60
|
+
end
|
61
|
+
|
62
|
+
it '#original_issue - A summary representation of the issue in which this story was originally published.' do
|
63
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
64
|
+
expect(story.original_issue.class).to eq Marver::ComicSummary
|
65
|
+
expect(story.original_issue.name).to eq "Thor (1998) #81"
|
66
|
+
expect(story.original_issue.resource_uri).to eq "http://gateway.marvel.com/v1/public/comics/715?ts=1&apikey=priv_key&hash=668dea517c974c12d8d0193cf2d8f7f7"
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require './lib/marver.rb'
|
2
|
+
|
3
|
+
describe Marver::KeyDate do
|
4
|
+
let(:date) { Marver::KeyDate.new({ "type" => "onsaleDate",
|
5
|
+
"date" => "2011-03-30T00:00:00-0400" })
|
6
|
+
}
|
7
|
+
|
8
|
+
it '#date' do
|
9
|
+
expect(date.date.year).to eq 2011
|
10
|
+
expect(date.date.month).to eq 03
|
11
|
+
expect(date.date.day).to eq 30
|
12
|
+
end
|
13
|
+
|
14
|
+
it '#type' do
|
15
|
+
expect(date.type).to eq "onsaleDate"
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require './lib/marver.rb'
|
2
|
+
|
3
|
+
describe Marver::Price do
|
4
|
+
let(:price) { Marver::Price.new({"type" => "printPrice", "price" => 3.99}) }
|
5
|
+
|
6
|
+
it '#type - type of price' do
|
7
|
+
expect(price.type).to eq "printPrice"
|
8
|
+
end
|
9
|
+
|
10
|
+
it '#price - the price' do
|
11
|
+
expect(price.price).to eq 3.99
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require './lib/marver.rb'
|
3
|
+
|
4
|
+
describe Marver::CharacterSummary do
|
5
|
+
let(:json) { JSON.parse("{ \"id\": \"123\", \"resourceURI\": \"http://gateway.marvel.com/v1/public/characters/1009351\", \"name\": \"Hulk\" }") }
|
6
|
+
let(:credentials) { Marver::Credentials.new('priv_key', 'pub_key') }
|
7
|
+
let(:character_summary) { Marver::CharacterSummary.new(json,
|
8
|
+
credentials) }
|
9
|
+
|
10
|
+
it '#id' do
|
11
|
+
expect(character_summary.id).to eq 123
|
12
|
+
end
|
13
|
+
|
14
|
+
it '#resource_uri' do
|
15
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
16
|
+
expect(character_summary.resource_uri).to eq "http://gateway.marvel.com/v1/public/characters/1009351?ts=1&apikey=pub_key&hash=3d4ce88a477c7e4a5accbf6cd2c8b819"
|
17
|
+
end
|
18
|
+
|
19
|
+
it '#type should always be nil' do
|
20
|
+
expect(character_summary.type).to eq nil
|
21
|
+
end
|
22
|
+
|
23
|
+
it '#name' do
|
24
|
+
expect(character_summary.name).to eq "Hulk"
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#full' do
|
28
|
+
before :each do
|
29
|
+
Time.stub_chain(:now, :to_i, :to_s).and_return "1"
|
30
|
+
stub_get(character_summary.resource_uri).to_return(:body => fixture('character.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
31
|
+
@full_character = character_summary.full
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'fetches the full view of the entity' do
|
35
|
+
expect(@full_character.class).to eq Marver::Character
|
36
|
+
expect(@full_character.name).to eq "Captain America"
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'summary objects' do
|
40
|
+
it 'has list of comic summaries' do
|
41
|
+
expect(@full_character.comics.class).to eq Array
|
42
|
+
expect(@full_character.comics.first.class).to eq Marver::ComicSummary
|
43
|
+
expect(@full_character.comics.first.name).to eq "Age of Apocalypse (2011) #2 (Avengers Art Appreciation Variant)"
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'has a list of stories summaries' do
|
47
|
+
expect(@full_character.stories.class).to eq Array
|
48
|
+
expect(@full_character.stories.first.class).to eq Marver::StorySummary
|
49
|
+
expect(@full_character.stories.first.name).to eq "Cover #892"
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'has a list of events summaries' do
|
53
|
+
expect(@full_character.events.class).to eq Array
|
54
|
+
expect(@full_character.events.first.class).to eq Marver::EventSummary
|
55
|
+
expect(@full_character.events.first.name).to eq "Acts of Vengeance!"
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'has a list of series summaries' do
|
59
|
+
expect(@full_character.series.class).to eq Array
|
60
|
+
expect(@full_character.series.first.class).to eq Marver::SerieSummary
|
61
|
+
expect(@full_character.series.first.name).to eq "Age of Apocalypse (2011 - Present)"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|