ultron 0.1.13 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +1 -1
- data/Gemfile +1 -1
- data/README.md +28 -28
- data/lib/ultron.rb +2 -2
- data/lib/ultron/version.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/ultron/auth_spec.rb +2 -2
- data/spec/ultron/config_spec.rb +6 -6
- data/spec/ultron/equality_spec.rb +2 -2
- data/spec/ultron/exceptions_spec.rb +10 -10
- data/spec/ultron/models/characters_spec.rb +7 -7
- data/spec/ultron/models/comics_spec.rb +3 -3
- data/spec/ultron/models/creators_spec.rb +6 -6
- data/spec/ultron/models/entities_spec.rb +2 -2
- data/spec/ultron/models/events_spec.rb +6 -6
- data/spec/ultron/models/series_spec.rb +4 -4
- data/spec/ultron/searches/sample_spec.rb +9 -9
- data/spec/ultron/searches/searches_spec.rb +13 -13
- data/spec/ultron/url_spec.rb +4 -3
- data/ultron.gemspec +3 -3
- metadata +4 -32
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjRlNTFjYjc0NTlmZmY4ZWEwYTYwNDFhNjBiNWUwMGQ0MmY1M2Y2Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTdlMWNjZjlkZTUzODg2OGQ0NzAyMzY4NTg0MGQxMTEyM2QxMjJlMQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTNiNTE4NDM2NDczODA3MmRjMzY5OTU5NmEyZGFmNDcxZmI1MTk2NTllZjhj
|
10
|
+
N2UxZWFkYjkxNDYyZTU3M2IxYWI3NmIwYmVjNzM5M2M3OGM4NDBjODAzOWVh
|
11
|
+
YzQwNmYxNTU5YTkyNWQ1ZTRmODkwZGQwN2YxNTg5YzZiYWY0NGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWNmNmU0MWI1MGE5ZDA5NDQ1NDYyNjlmZjU2ZGU1ODY2ZDBmZDllNTFiNzBj
|
14
|
+
YzEyMDEyYWYwN2I4YWRjM2Y4OTRjYjQ2OTg2M2E2MmE2ODZjMzgzOTRlNDhh
|
15
|
+
MTkxNGExMDIzNDBmYzJhOWIyNTYxNzViMGNjOTVhODRiMTc5NGI=
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -14,7 +14,7 @@ Ruby bindings for the [Marvel Comics API](http://developer.marvel.com/)
|
|
14
14
|
ultron
|
15
15
|
bundle
|
16
16
|
rake
|
17
|
-
|
17
|
+
|
18
18
|
Or just
|
19
19
|
|
20
20
|
gem install ultron
|
@@ -34,76 +34,76 @@ I've tried to follow the [Marvel API](http://developer.marvel.com/docs#!/public/
|
|
34
34
|
|
35
35
|
it 'should find a comic', :vcr do
|
36
36
|
comic = Comics.find 12518
|
37
|
-
comic.title.
|
37
|
+
expect(comic.title).to eq ('Uncanny X-Men (1963) #67')
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
### Get a set of things filtered by some other thing
|
41
41
|
|
42
42
|
it 'should find a list of comics featuring the character', :vcr do
|
43
43
|
character = Characters.find 1009610
|
44
|
-
character.name.
|
44
|
+
expect(character.name).to eq ('Spider-Man')
|
45
45
|
comics = Comics.by_character 1009610
|
46
|
-
comics.first.title.
|
47
|
-
comics.class.
|
48
|
-
comics.count.
|
46
|
+
expect(comics.first.title).to eq ('Superior Spider-Man (2013) #22')
|
47
|
+
expect(comics.class).to eq (Comics)
|
48
|
+
expect(comics.count).to eq (20)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
### Get a set of things using query-string parameters
|
52
52
|
|
53
53
|
it 'should let us search with parameters', :vcr do
|
54
54
|
comics = Comics.where sharedAppearances: '1009351,1009718' # Hulk and Wolverine
|
55
|
-
comics[7].title.
|
55
|
+
expect(comics[7].title).to eq ('Deadpool (2008) #37')
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
### Get a set of things using multiple query-string parameters
|
59
59
|
|
60
60
|
it 'should let us search with multiple parameters', :vcr do
|
61
61
|
comics = Comics.where sharedAppearances: '1009610,1009718', events: 302 # Spider-Man and Wolverine, Fear Itself
|
62
|
-
comics.first.title.
|
62
|
+
expect(comics.first.title).to eq ('Fear Itself (2010) #7')
|
63
63
|
end
|
64
64
|
|
65
65
|
### Get a set of things filtered by another thing and with a query-string
|
66
66
|
|
67
67
|
it 'should let us get comics by a creator *with params*', :vcr do
|
68
68
|
comics = Comics.by_creator_and_with 214, dateRange: '1980-01-01,1989-12-31'
|
69
|
-
comics.first.resourceURI.
|
69
|
+
expect(comics.first.resourceURI).to eq ('http://gateway.marvel.com/v1/public/comics/8268')
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
### Get a random thing
|
73
73
|
|
74
74
|
Something like this works, but it's proving very difficult to test it:
|
75
75
|
|
76
76
|
Characters.sample
|
77
|
-
|
77
|
+
|
78
78
|
### Get a random thing from a search
|
79
79
|
|
80
80
|
it 'should give us a random comic', :vcr do
|
81
81
|
set = Comics.by_character 1009610
|
82
82
|
set.stub(:random_offset).and_return(512)
|
83
|
-
set.sample.title.
|
83
|
+
expect(set.sample.title).to eq ('Amazing Spider-Man (1999) #590')
|
84
84
|
end
|
85
85
|
|
86
86
|
it 'should give us a random comic for a more complex search', :vcr do
|
87
87
|
set = Comics.by_creator_and_with 214, dateRange: '1980-01-01,1989-12-31'
|
88
88
|
set.stub(:random_offset).and_return(99)
|
89
|
-
set.sample.title.
|
89
|
+
expect(set.sample.title).to eq ('Dazzler (1981) #19')
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
### Pre-baked custom searches
|
93
93
|
|
94
94
|
There's a lot of noise in the data, and I found myself applying the same filters again and again. So:
|
95
95
|
|
96
96
|
it 'should give us regular comics filtered by character', :vcr do
|
97
97
|
comics = Comics.by_character_and_vanilla_comics 1009685
|
98
|
-
comics.first.title.
|
98
|
+
expect(comics.first.title).to eq ('AGE OF ULTRON (2013) #1')
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
101
|
This applies the following search params:
|
102
102
|
|
103
103
|
format: 'comic', formatType: 'comic', noVariants: true
|
104
|
-
|
104
|
+
|
105
105
|
which purges all sorts of hardbacks and reprints and so on from the results.
|
106
|
-
|
106
|
+
|
107
107
|
## Exceptions
|
108
108
|
|
109
109
|
### Catch and re-raise a 404
|
@@ -112,21 +112,21 @@ which purges all sorts of hardbacks and reprints and so on from the results.
|
|
112
112
|
begin
|
113
113
|
comic = Comics.find 1000000 # there are not a million comics
|
114
114
|
rescue MarvelException => e
|
115
|
-
e.code.
|
116
|
-
e.status.
|
115
|
+
expect(e.code).to eq (404)
|
116
|
+
expect(e.status).to eq ("We couldn't find that comic_issue")
|
117
117
|
end
|
118
118
|
end
|
119
|
-
|
119
|
+
|
120
120
|
### Raise a custom exception when we do something dumb
|
121
121
|
|
122
122
|
it 'should throw a Resource Not Found exception when we search for something nonsensical', :vcr do
|
123
123
|
begin
|
124
124
|
characters = Characters.by_creator 186 # characters by creator is a nonsense concept in the Marvel API
|
125
125
|
rescue UltronException => e
|
126
|
-
e.status.
|
126
|
+
expect(e.status).to eq ('Resource does not exist. Check http://developer.marvel.com/docs')
|
127
127
|
end
|
128
128
|
end
|
129
|
-
|
130
|
-
This all got a lot more elegant after a chat over a fry-up with @floppy at the always-superb [First-Step Cafe](https://plus.google.com/100027883675109761806/about?gl=uk&hl=en) in Shoreditch.
|
131
129
|
|
132
|
-
|
130
|
+
This all got a lot more elegant after a chat over a fry-up with [@floppy](http://github.com/floppy) at the always-superb [First-Step Cafe](https://plus.google.com/100027883675109761806/about?gl=uk&hl=en) in Shoreditch.
|
131
|
+
|
132
|
+
And here's a [Gource video](https://vimeo.com/86940385) of the project as of 2014-02-17.
|
data/lib/ultron.rb
CHANGED
@@ -7,6 +7,8 @@ require 'digest'
|
|
7
7
|
require 'ostruct'
|
8
8
|
require 'active_support/core_ext/string'
|
9
9
|
|
10
|
+
require 'pry'
|
11
|
+
|
10
12
|
require 'ultron/version'
|
11
13
|
require 'ultron/auth'
|
12
14
|
require 'ultron/config'
|
@@ -23,5 +25,3 @@ require 'ultron/models/stories'
|
|
23
25
|
|
24
26
|
require 'ultron/exceptions/marvel_exception'
|
25
27
|
require 'ultron/exceptions/ultron_exception'
|
26
|
-
|
27
|
-
require 'pry'
|
data/lib/ultron/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/ultron/auth_spec.rb
CHANGED
@@ -5,9 +5,9 @@ module Ultron
|
|
5
5
|
context 'auth' do
|
6
6
|
it 'should return the correct string' do
|
7
7
|
Timecop.freeze '2014-02-08T21:20:00+00:00'
|
8
|
-
Ultron.auth('public', 'private').
|
8
|
+
expect(Ultron.auth('public', 'private')).to eq ('ts=1391894400&apikey=private&hash=7b0ecfd5af9875bc436cfd5ecc58ef3d')
|
9
9
|
Timecop.return
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end
|
data/spec/ultron/config_spec.rb
CHANGED
@@ -6,24 +6,24 @@ module Ultron
|
|
6
6
|
@conf = Ultron::Config.instance.config
|
7
7
|
end
|
8
8
|
it 'should have a host name' do
|
9
|
-
@conf['host'].
|
9
|
+
expect(@conf['host']).to eq ('http://gateway.marvel.com')
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'should have a url path' do
|
13
|
-
@conf['path'].
|
13
|
+
expect(@conf['path']).to eq ('/v1/public/')
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should have a root url' do
|
17
|
-
Ultron::Config.instance.root_url.
|
17
|
+
expect(Ultron::Config.instance.root_url).to eq ('http://gateway.marvel.com/v1/public/')
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should let us add arbitrary keys' do
|
21
21
|
@conf['doge'] = 'wow'
|
22
|
-
@conf['doge'].
|
22
|
+
expect(@conf['doge']).to eq ('wow')
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should give us OpenStruct-style attribute access' do
|
26
|
-
@conf.host.
|
26
|
+
expect(@conf.host).to eq ('http://gateway.marvel.com')
|
27
27
|
end
|
28
28
|
end
|
29
|
-
end
|
29
|
+
end
|
@@ -8,36 +8,36 @@ module Ultron
|
|
8
8
|
|
9
9
|
it 'should throw a 404 (wrapped in a Marvel exception) on a 404', :vcr do
|
10
10
|
expect { Comics.find 1000000 }.to raise_exception { |exception| # there are not a million comics
|
11
|
-
exception.
|
12
|
-
exception.code.
|
13
|
-
exception.status.
|
11
|
+
expect(exception).to be_a MarvelException
|
12
|
+
expect(exception.code).to eq (404)
|
13
|
+
expect(exception.status).to eq ("We couldn't find that comic_issue")
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should throw a No Idea What This Param Is exception', :vcr do
|
18
18
|
expect { Characters.where(Thor: 'Mighty') }.to raise_exception { |exception|
|
19
|
-
exception.
|
20
|
-
exception.code.
|
21
|
-
exception.status.
|
19
|
+
expect(exception).to be_a (MarvelException)
|
20
|
+
expect(exception.code).to eq (409)
|
21
|
+
expect(exception.status).to eq ("We don't recognize the parameter Thor")
|
22
22
|
}
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should throw an Ultron exception when we do something dumb', :vcr do
|
26
26
|
expect { Comics.where offset: 1000000 }.to raise_exception { |exception|
|
27
|
-
exception.status.
|
27
|
+
expect(exception.status).to eq ('The search returned no results')
|
28
28
|
}
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should throw a Resource Not Found exception when we search for something nonsensical', :vcr do
|
32
32
|
expect { Characters.by_creator 186 }.to raise_exception { |exception| # characters by creator is a nonsense concept in the Marvel API
|
33
|
-
exception.status.
|
33
|
+
expect(exception.status).to eq ('Resource does not exist. Check http://developer.marvel.com/docs')
|
34
34
|
}
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'should throw a Resource Throttled Exception when we hit our limit', :vcr do
|
38
38
|
pending 'Guess I need to stub this request'
|
39
39
|
expect { Events.get }.to raise_exception { |exception|
|
40
|
-
exception.status.
|
40
|
+
expect(exception.status).to eq ('You have exceeded your rate limit. Please try again later')
|
41
41
|
}
|
42
42
|
end
|
43
43
|
|
@@ -45,4 +45,4 @@ module Ultron
|
|
45
45
|
Timecop.return
|
46
46
|
end
|
47
47
|
end
|
48
|
-
end
|
48
|
+
end
|
@@ -7,25 +7,25 @@ module Ultron
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should generate the right string for the URL path' do
|
10
|
-
Characters.name_for_path.
|
10
|
+
expect(Characters.name_for_path).to eq ('characters')
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should find a character', :vcr do
|
14
14
|
character = Characters.find 1009685
|
15
|
-
character.name.
|
15
|
+
expect(character.name).to eq ('Ultron')
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should find a list of comics featuring the character', :vcr do
|
19
19
|
character = Characters.find 1009610
|
20
|
-
character.name.
|
20
|
+
expect(character.name).to eq ('Spider-Man')
|
21
21
|
comics = Comics.by_character 1009610
|
22
|
-
comics.first.title.
|
23
|
-
comics.class.
|
24
|
-
comics.count.
|
22
|
+
expect(comics.first.title).to eq ('Superior Spider-Man (2013) #22')
|
23
|
+
expect(comics.class).to eq (Comics)
|
24
|
+
expect(comics.count).to eq (20)
|
25
25
|
end
|
26
26
|
|
27
27
|
after :each do
|
28
28
|
Timecop.return
|
29
29
|
end
|
30
30
|
end
|
31
|
-
end
|
31
|
+
end
|
@@ -7,16 +7,16 @@ module Ultron
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should generate the right string for the URL path' do
|
10
|
-
Comics.name_for_path.
|
10
|
+
expect(Comics.name_for_path).to eq ('comics')
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should find a comic', :vcr do
|
14
14
|
comic = Comics.find 12518
|
15
|
-
comic.title.
|
15
|
+
expect(comic.title).to eq ('Uncanny X-Men (1963) #67')
|
16
16
|
end
|
17
17
|
|
18
18
|
after :each do
|
19
19
|
Timecop.return
|
20
20
|
end
|
21
21
|
end
|
22
|
-
end
|
22
|
+
end
|
@@ -7,20 +7,20 @@ module Ultron
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should generate the right string for the URL path' do
|
10
|
-
Creators.name_for_path.
|
10
|
+
expect(Creators.name_for_path).to eq ('creators')
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should find a list of series by the creator', :vcr do
|
14
14
|
creator = Creators.find 196
|
15
|
-
creator.fullName.
|
15
|
+
expect(creator.fullName).to eq ('Jack Kirby')
|
16
16
|
series = Series.by_creator 196
|
17
|
-
series[3].title.
|
18
|
-
series.class.
|
19
|
-
series.count.
|
17
|
+
expect(series[3].title).to eq ('Amazing Fantasy (1962)')
|
18
|
+
expect(series.class).to eq (Series)
|
19
|
+
expect(series.count).to eq (20)
|
20
20
|
end
|
21
21
|
|
22
22
|
after :each do
|
23
23
|
Timecop.return
|
24
24
|
end
|
25
25
|
end
|
26
|
-
end
|
26
|
+
end
|
@@ -4,7 +4,7 @@ module Ultron
|
|
4
4
|
describe Entities do
|
5
5
|
it 'should parse params correctly' do
|
6
6
|
hash = {thor: 'Mighty', hulk: 'Incredible'}
|
7
|
-
Entities.by_params(hash).
|
7
|
+
expect(Entities.by_params(hash)).to eq ('thor=Mighty&hulk=Incredible&')
|
8
8
|
end
|
9
9
|
end
|
10
|
-
end
|
10
|
+
end
|
@@ -7,20 +7,20 @@ module Ultron
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should generate the right string for the URL path' do
|
10
|
-
Events.name_for_path.
|
10
|
+
expect(Events.name_for_path).to eq ('events')
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should find a list of stories for the event', :vcr do
|
14
14
|
event = Events.find 271
|
15
|
-
event.title.
|
15
|
+
expect(event.title).to eq ('Secret Wars II')
|
16
16
|
stories = Stories.by_event 271
|
17
|
-
stories[4].title.
|
18
|
-
stories[4].id.
|
19
|
-
stories.class.
|
17
|
+
expect(stories[4].title).to eq ('Doctor Doom Versus the Beyonder')
|
18
|
+
expect(stories[4].id).to eq (12850)
|
19
|
+
expect(stories.class).to eq (Stories)
|
20
20
|
end
|
21
21
|
|
22
22
|
after :each do
|
23
23
|
Timecop.return
|
24
24
|
end
|
25
25
|
end
|
26
|
-
end
|
26
|
+
end
|
@@ -8,19 +8,19 @@ module Ultron
|
|
8
8
|
|
9
9
|
it 'should give a default set of series', :vcr do
|
10
10
|
series = Series.get
|
11
|
-
series.count.
|
11
|
+
expect(series.count).to eq (20)
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'should give us a larger set of series', :vcr do
|
15
15
|
series = Series.get_and_with limit: 50
|
16
|
-
series.count.
|
16
|
+
expect(series.count).to eq (50)
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should not accept any old method', :vcr do
|
20
20
|
begin
|
21
21
|
series = Series.derp
|
22
22
|
rescue Exception => e
|
23
|
-
e.class.
|
23
|
+
expect(e.class).to eq (NoMethodError)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -28,4 +28,4 @@ module Ultron
|
|
28
28
|
Timecop.return
|
29
29
|
end
|
30
30
|
end
|
31
|
-
end
|
31
|
+
end
|
@@ -9,29 +9,29 @@ module Ultron
|
|
9
9
|
context 'let us pick a random item' do
|
10
10
|
it 'should get a count of items for a lookup', :vcr do
|
11
11
|
total = Comics.by_character(1009610).metadata.total # All comics featuring Spider-Man
|
12
|
-
total.
|
12
|
+
expect(total).to eq (2576)
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should give us a random offset into the result set', :vcr do
|
16
16
|
set = Comics.by_character 1009610
|
17
|
-
set.
|
18
|
-
set.random_offset.
|
17
|
+
allow(set).to receive(:random_offset).and_return(233)
|
18
|
+
expect(set.random_offset).to eq (233)
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should give us a random comic', :vcr do
|
22
22
|
set = Comics.by_character 1009610
|
23
|
-
set.
|
24
|
-
set.sample.title.
|
23
|
+
allow(set).to receive(:random_offset).and_return(512)
|
24
|
+
expect(set.sample.title).to eq ('Amazing Spider-Man (1999) #590')
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'should give us a random comic for a more complex search', :vcr do
|
28
28
|
set = Comics.by_creator_and_with 214, dateRange: '1980-01-01,1989-12-31'
|
29
|
-
set.
|
30
|
-
set.sample.title.
|
29
|
+
allow(set).to receive(:random_offset).and_return(100)
|
30
|
+
expect(set.sample.title).to eq ('Dazzler (1981) #19')
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'should support sample as a class method', :vcr do
|
34
|
-
|
34
|
+
skip 'I have no idea how to test this. Works, though'
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -39,4 +39,4 @@ module Ultron
|
|
39
39
|
Timecop.return
|
40
40
|
end
|
41
41
|
end
|
42
|
-
end
|
42
|
+
end
|
@@ -8,57 +8,57 @@ module Ultron
|
|
8
8
|
|
9
9
|
it 'should let us get a comic', :vcr do
|
10
10
|
comic = Comics.find 10588
|
11
|
-
comic.title.
|
11
|
+
expect(comic.title).to eq ('Secret Wars (1984) #6')
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'should let us get comics by a creator', :vcr do
|
15
15
|
comics = Comics.by_creator 196 # Jack Kirby
|
16
|
-
comics[14].title.
|
16
|
+
expect(comics[14].title).to eq ('INHUMANS: THE ORIGIN OF THE INHUMANS TPB (Trade Paperback)')
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should let us search with parameters', :vcr do
|
20
20
|
comics = Comics.where sharedAppearances: '1009351,1009718' # Hulk and Wolverine
|
21
|
-
comics[7].title.
|
21
|
+
expect(comics[7].title).to eq ('Deadpool (2008) #37')
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'should let us search with multiple parameters', :vcr do
|
25
25
|
comics = Comics.where sharedAppearances: '1009610,1009718', events: 302 # Spider-Man and Wolverine, Fear Itself
|
26
|
-
comics.first.title.
|
26
|
+
expect(comics.first.title).to eq ('Fear Itself (2010) #7')
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should accept with as a synonym for where', :vcr do
|
30
30
|
comics = Comics.with sharedAppearances: '1009685,1009351' # Ultron and Hulk
|
31
|
-
comics.first.title.
|
31
|
+
expect(comics.first.title).to eq ('Avengers: First to Last (Hardcover)')
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should let us get comics by a creator *with params*', :vcr do
|
35
35
|
comics = Comics.by_creator_and_with 214, dateRange: '1980-01-01,1989-12-31'
|
36
|
-
comics.first.resourceURI.
|
36
|
+
expect(comics.first.resourceURI).to eq ('http://gateway.marvel.com/v1/public/comics/8268')
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'should let us get more than the default 20 results', :vcr do
|
40
40
|
comics = Comics.where limit: 50
|
41
|
-
comics.count.
|
41
|
+
expect(comics.count).to eq (50)
|
42
42
|
end
|
43
43
|
|
44
44
|
context 'pre-baked searches' do
|
45
45
|
it 'should give us just regular comics', :vcr do
|
46
46
|
comics = Comics.vanilla_comics
|
47
|
-
comics.first.id.
|
48
|
-
comics.first.title.
|
49
|
-
comics.first.issueNumber.
|
47
|
+
expect(comics.first.id).to eq (47589)
|
48
|
+
expect(comics.first.title).to eq ('Avengers A.I. (2013) #12')
|
49
|
+
expect(comics.first.issueNumber).to eq (12)
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'should give us regular comics filtered by character', :vcr do
|
53
53
|
comics = Comics.by_character_and_vanilla_comics 1009685
|
54
|
-
comics.first.title.
|
54
|
+
expect(comics.first.title).to eq ('AGE OF ULTRON (2013) #1')
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'should barf on an unknown search', :vcr do
|
58
58
|
begin
|
59
59
|
comics = Comics.fake_search
|
60
60
|
rescue Exception => e
|
61
|
-
e.class.
|
61
|
+
expect(e.class).to eq (NoMethodError)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -67,4 +67,4 @@ module Ultron
|
|
67
67
|
Timecop.return
|
68
68
|
end
|
69
69
|
end
|
70
|
-
end
|
70
|
+
end
|
data/spec/ultron/url_spec.rb
CHANGED
@@ -6,14 +6,15 @@ module Ultron
|
|
6
6
|
it 'should be equal regardless of the auth part', :vcr do
|
7
7
|
ts = '2014-02-16T19:48:00+00:00'
|
8
8
|
Timecop.freeze ts
|
9
|
-
|
9
|
+
#Ultron.stub(:auth).and_return(Date.parse(ts).strftime '%s')
|
10
|
+
allow(Ultron).to receive(:auth).and_return(Date.parse(ts).strftime '%s')
|
10
11
|
first_url = URL.new '/path/parts', 'query=string&'
|
11
12
|
ts = '2014-02-17T19:48:00+00:00'
|
12
13
|
Timecop.freeze ts
|
13
14
|
second_url = URL.new '/path/parts', 'query=string&'
|
14
15
|
|
15
|
-
first_url.
|
16
|
+
expect(first_url).to eq (second_url)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
19
|
-
end
|
20
|
+
end
|
data/ultron.gemspec
CHANGED
@@ -24,9 +24,9 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.5'
|
26
26
|
spec.add_development_dependency 'rake', '~> 10.1'
|
27
|
-
spec.add_development_dependency 'rspec', '~>
|
28
|
-
spec.add_development_dependency 'rspec-mocks', '~> 2.14'
|
29
|
-
spec.add_development_dependency 'rspec-pride', '~> 2.3'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3'
|
28
|
+
# spec.add_development_dependency 'rspec-mocks', '~> 2.14'
|
29
|
+
# spec.add_development_dependency 'rspec-pride', '~> 2.3'
|
30
30
|
spec.add_development_dependency 'cucumber', '~> 1.3'
|
31
31
|
spec.add_development_dependency 'guard', '~> 2.4'
|
32
32
|
spec.add_development_dependency 'guard-rspec', '~> 4.2'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ultron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pikesley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curb
|
@@ -86,42 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '3'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rspec-mocks
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ~>
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '2.14'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ~>
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '2.14'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rspec-pride
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ~>
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '2.3'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ~>
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '2.3'
|
96
|
+
version: '3'
|
125
97
|
- !ruby/object:Gem::Dependency
|
126
98
|
name: cucumber
|
127
99
|
requirement: !ruby/object:Gem::Requirement
|