marvell 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,55 @@
1
+ require_relative "../spec_helper"
2
+
3
+ describe "a character entity" do
4
+ before { VCR.insert_cassette 'character', record: :new_episodes }
5
+ after { VCR.eject_cassette }
6
+
7
+ describe "parsing the json argument" do
8
+ let(:client) { Marvell::Client.new(public_key: "07e4dc912806b1c5d1e51687095bca09", private_key: 'a97d276fe66678f07ec9150e3012d41160937b85')}
9
+ let(:character){ client.character(id: 1009521) }
10
+
11
+ it "returns a hash result set" do
12
+ character.result.must_be_instance_of Hash
13
+ end
14
+
15
+ it "returns a name" do
16
+ character.name.must_equal " Hank Pym"
17
+ end
18
+
19
+ it "returns a description" do
20
+ character.description.must_equal ""
21
+ end
22
+
23
+ it "returns a modified date" do
24
+ character.modified.must_equal "1969-12-31T19:00:00-0500"
25
+ end
26
+
27
+ it "returns a thumbnail object" do
28
+ character.thumbnail.must_be_instance_of Hash
29
+ end
30
+
31
+ it "returns a resource URI" do
32
+ character.resourceURI.must_equal "http://gateway.marvel.com/v1/public/characters/1009521"
33
+ end
34
+
35
+ it "returns a comics object" do
36
+ character.comics.must_be_instance_of Hash
37
+ end
38
+
39
+ it "returns a series object" do
40
+ character.series.must_be_instance_of Hash
41
+ end
42
+
43
+ it "returns a stories object" do
44
+ character.stories.must_be_instance_of Hash
45
+ end
46
+
47
+ it "returns an events object" do
48
+ character.events.must_be_instance_of Hash
49
+ end
50
+
51
+ it "returns a set of public urls for the resource" do
52
+ character.urls.must_be_instance_of Array
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,178 @@
1
+ require_relative "../spec_helper"
2
+
3
+ describe Marvell::Client do
4
+ let(:client) { Marvell::Client.new(public_key: "07e4dc912806b1c5d1e51687095bca09", private_key: 'a97d276fe66678f07ec9150e3012d41160937b85')}
5
+
6
+ before { VCR.insert_cassette 'requests', record: :new_episodes }
7
+ after { VCR.eject_cassette }
8
+
9
+ describe "api functionality" do
10
+ it "uses the HTTParty library" do
11
+ Marvell::Client.must_include HTTParty
12
+ end
13
+
14
+ it "uses the correct base uri" do
15
+ Marvell::Client.base_uri.must_equal "http://gateway.marvel.com"
16
+ end
17
+ end
18
+
19
+ describe "#character" do
20
+
21
+ it "given an id, returns a Marvel::Character object" do
22
+ character = client.character(id: 1009521)
23
+ character.must_be_instance_of Marvell::Entity
24
+ character.name.must_equal " Hank Pym"
25
+ end
26
+ end
27
+
28
+ describe "#characters" do
29
+
30
+ it "returns an array of characters" do
31
+ characters = client.characters
32
+ characters.must_be_instance_of Array
33
+ characters.first.must_be_instance_of Marvell::Entity
34
+ end
35
+
36
+ describe "filtering the resultset" do
37
+
38
+ it "filters by limit" do
39
+ characters = client.characters(limit: 4)
40
+ characters.size.must_equal 4
41
+ end
42
+
43
+ it "filters by name" do
44
+ characters = client.characters(name: 'Spider-Man')
45
+ characters.first.name.must_equal "Spider-Man"
46
+ end
47
+ end
48
+
49
+ describe "second class resources" do
50
+ it "returns a set of characters which belong to a comic" do
51
+ characters = client.characters(comic_id: 36489)
52
+ characters.first.name.must_equal " Hank Pym"
53
+ end
54
+
55
+ it "returns a set of characters which belong to a story" do
56
+ characters = client.characters(story_id: 5621)
57
+ characters.first.name.must_equal " Hank Pym"
58
+ end
59
+
60
+ it "returns a set of characters which belong to a series" do
61
+ characters = client.characters(series_id: 20)
62
+ characters.first.name.must_equal "Ben Urich"
63
+ end
64
+
65
+ it "returns a set of characters which belong to an event" do
66
+ characters = client.characters(event_id: 318)
67
+ characters.first.name.must_equal " Hank Pym"
68
+ end
69
+ end
70
+ end
71
+
72
+ describe "#comic" do
73
+ it "given an id, returns a Marvel::Entity object" do
74
+ comic = client.comic(id: 41530)
75
+ comic.must_be_instance_of Marvell::Entity
76
+ end
77
+ end
78
+
79
+ describe "#comics" do
80
+ it "returns an array of comics" do
81
+ comics = client.comics
82
+ comics.must_be_instance_of Array
83
+ comics.first.must_be_instance_of Marvell::Entity
84
+ end
85
+
86
+ describe "filtering the resultset" do
87
+
88
+ it "filters by limit" do
89
+ comics = client.comics(limit: 4)
90
+ comics.size.must_equal 4
91
+ end
92
+
93
+ it "filters by format" do
94
+ comics = client.comics(format: 'digital comic')
95
+ comics.first.format.must_equal 'Digital Comic'
96
+ end
97
+ end
98
+ end
99
+
100
+ describe '#creator' do
101
+ it "given an id, returns a Marvel::Entity object" do
102
+ creator = client.creator(id: 546)
103
+ creator.must_be_instance_of Marvell::Entity
104
+ end
105
+ end
106
+
107
+ describe '#creators' do
108
+ it 'returns an array of creators' do
109
+ creators = client.creators
110
+ creators.must_be_instance_of Array
111
+ creators.first.must_be_instance_of Marvell::Entity
112
+ end
113
+
114
+ describe "filtering the resultset" do
115
+
116
+ it "filters by limit" do
117
+ creators = client.creators(limit: 4)
118
+ creators.size.must_equal 4
119
+ end
120
+
121
+ it "filters by first name" do
122
+ creators = client.creators(firstName: 'Brian')
123
+ creators.first.first_name.must_equal 'Brian'
124
+ end
125
+ end
126
+ end
127
+
128
+ describe "#story" do
129
+
130
+ it "given an id, returns a Marvel::Entity object" do
131
+ story = client.story(id: 3)
132
+ story.must_be_instance_of Marvell::Entity
133
+ end
134
+ end
135
+
136
+ describe "#stories" do
137
+
138
+ it "returns an array of stories" do
139
+ stories = client.stories
140
+ stories.must_be_instance_of Array
141
+ stories.first.must_be_instance_of Marvell::Entity
142
+ end
143
+
144
+ describe "filtering the resultset" do
145
+
146
+ it "filters by limit" do
147
+ stories = client.stories(limit: 4)
148
+ stories.size.must_equal 4
149
+ end
150
+ end
151
+ end
152
+
153
+ describe "#serie" do
154
+
155
+ it "given an id, returns a Marvel::Entity object" do
156
+ serie = client.serie(id: 3)
157
+ serie.must_be_instance_of Marvell::Entity
158
+ end
159
+ end
160
+
161
+ describe "#series" do
162
+
163
+ it "returns an array of series" do
164
+ series = client.series
165
+ series.must_be_instance_of Array
166
+ series.first.must_be_instance_of Marvell::Entity
167
+ end
168
+
169
+ describe "filtering the resultset" do
170
+
171
+ it "filters by limit" do
172
+ series = client.stories(limit: 4)
173
+ series.size.must_equal 4
174
+ end
175
+ end
176
+ end
177
+
178
+ end
@@ -0,0 +1,29 @@
1
+ require_relative "../spec_helper"
2
+
3
+ describe 'marvel comic entity' do
4
+ before { VCR.insert_cassette 'requests', record: :new_episodes }
5
+ after { VCR.eject_cassette }
6
+
7
+ let(:client) { Marvell::Client.new(public_key: "07e4dc912806b1c5d1e51687095bca09", private_key: 'a97d276fe66678f07ec9150e3012d41160937b85')}
8
+ let(:comic){ client.comic(id: 41530) }
9
+
10
+ it "returns a hash result set" do
11
+ comic.result.must_be_instance_of Hash
12
+ end
13
+
14
+ it "returns a title" do
15
+ comic.title.must_equal "Ant-Man: So (Trade Paperback)"
16
+ end
17
+
18
+ it "returns a description" do
19
+ comic.description.must_include "It's the origin of the original Avenger"
20
+ end
21
+
22
+ it "returns the date of last modification" do
23
+ comic.modified.must_equal "2012-09-25T18:05:58-0400"
24
+ end
25
+
26
+ it "returns the isbn number" do
27
+ comic.isbn.must_equal "978-0-7851-6390-9"
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ require_relative "../spec_helper"
2
+
3
+ describe Marvell::Entity do
4
+ let(:client) { Marvell::Client.new(public_key: "07e4dc912806b1c5d1e51687095bca09", private_key: 'a97d276fe66678f07ec9150e3012d41160937b85')}
5
+
6
+ before { VCR.insert_cassette 'character', record: :new_episodes }
7
+ after { VCR.eject_cassette }
8
+
9
+ it "finds an entity attribute if one exists" do
10
+ character = client.character(id: 1009521)
11
+ proc {character.name}.must_be_silent
12
+ end
13
+
14
+ it "throws an error if the given attribute doesn't exist" do
15
+ character = client.character(id: 1009521)
16
+ proc{character.some_random_attribute}.must_raise NoMethodError
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ require_relative "../lib/marvell"
2
+
3
+ require 'minitest/autorun'
4
+ require "webmock/minitest"
5
+ require "vcr"
6
+
7
+ #WebMock.allow_net_connect!
8
+
9
+ #VCR config
10
+ VCR.configure do |c|
11
+ c.cassette_library_dir = 'spec/fixtures/dish_cassettes'
12
+ c.hook_into :webmock
13
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: marvell
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Oz Huner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby Marvel Comics API Wrapper
14
+ email:
15
+ - oguzcanhuner@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/marvell.rb
21
+ - lib/marvell/entity.rb
22
+ - lib/marvell/json_parser.rb
23
+ - lib/marvell/client.rb
24
+ - spec/fixtures/dish_cassettes/character.yml
25
+ - spec/fixtures/dish_cassettes/requests.yml
26
+ - spec/lib/comic_spec.rb
27
+ - spec/lib/entity_spec.rb
28
+ - spec/lib/character_spec.rb
29
+ - spec/lib/client_spec.rb
30
+ - spec/spec_helper.rb
31
+ - Rakefile
32
+ - Gemfile
33
+ homepage: http://www.github.com/oguzcanhuner/marvell
34
+ licenses:
35
+ - MIT
36
+ metadata: {}
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 2.1.11
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: Ruby Marvel Comics API Wrapper
57
+ test_files:
58
+ - spec/fixtures/dish_cassettes/character.yml
59
+ - spec/fixtures/dish_cassettes/requests.yml
60
+ - spec/lib/comic_spec.rb
61
+ - spec/lib/entity_spec.rb
62
+ - spec/lib/character_spec.rb
63
+ - spec/lib/client_spec.rb
64
+ - spec/spec_helper.rb