uatu-marvel 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -1
  5. data/Gemfile +2 -1
  6. data/README.md +5 -3
  7. data/bin/console +7 -0
  8. data/lib/uatu.rb +13 -2
  9. data/lib/uatu/base.rb +10 -55
  10. data/lib/uatu/configuration.rb +3 -5
  11. data/lib/uatu/connection.rb +48 -41
  12. data/lib/uatu/endpoints/collection.rb +16 -0
  13. data/lib/uatu/endpoints/nested.rb +23 -0
  14. data/lib/uatu/endpoints/single.rb +17 -0
  15. data/lib/uatu/resource.rb +21 -19
  16. data/lib/uatu/resources.rb +3 -0
  17. data/lib/uatu/response.rb +1 -4
  18. data/lib/uatu/version.rb +1 -1
  19. data/spec/integration/characters_spec.rb +25 -0
  20. data/spec/integration/comics_spec.rb +17 -0
  21. data/spec/integration/creators_spec.rb +19 -0
  22. data/spec/integration/events_spec.rb +19 -0
  23. data/spec/integration/series_spec.rb +19 -0
  24. data/spec/integration/stories_spec.rb +19 -0
  25. data/spec/spec_helper.rb +18 -0
  26. data/spec/support/fake_marvel_api.rb +24 -0
  27. data/spec/support/fake_marvel_api/characters/list.json +381 -0
  28. data/spec/support/fake_marvel_api/characters/show.json +381 -0
  29. data/spec/support/fake_marvel_api/comics/list.json +1479 -0
  30. data/spec/support/fake_marvel_api/comics/show.json +134 -0
  31. data/spec/support/fake_marvel_api/creators/list.json +180 -0
  32. data/spec/support/fake_marvel_api/creators/show.json +323 -0
  33. data/spec/support/fake_marvel_api/events/list.json +2224 -0
  34. data/spec/support/fake_marvel_api/events/show.json +474 -0
  35. data/spec/support/fake_marvel_api/series/list.json +739 -0
  36. data/spec/support/fake_marvel_api/series/show.json +101 -0
  37. data/spec/support/fake_marvel_api/stories/list.json +523 -0
  38. data/spec/support/fake_marvel_api/stories/show.json +69 -0
  39. data/spec/uatu/configuration_spec.rb +26 -0
  40. data/spec/uatu/connection_spec.rb +54 -0
  41. data/spec/uatu/resource_spec.rb +40 -0
  42. data/spec/uatu_spec.rb +9 -0
  43. data/uatu.gemspec +6 -4
  44. metadata +123 -34
  45. data/test/helper.rb +0 -9
  46. data/test/uatu/base_test.rb +0 -51
  47. data/test/uatu/configuration_test.rb +0 -19
  48. data/test/uatu/connection_test.rb +0 -31
  49. data/test/uatu/resource_test.rb +0 -33
  50. data/test/uatu/uatu_test.rb +0 -9
@@ -1,9 +0,0 @@
1
- require 'uatu'
2
- require 'minitest/autorun'
3
- require 'minitest/spec'
4
-
5
- def keys?
6
- if ENV['MARVEL_PUBLIC_KEY'].nil? or ENV['MARVEL_PRIVATE_KEY'].nil?
7
- raise "WARNING: You must set pubic and private keys in your environment to run the tests."
8
- end
9
- end
@@ -1,51 +0,0 @@
1
- require 'helper'
2
-
3
- describe '.base' do
4
-
5
- before do
6
- keys?
7
- @uatu = Uatu::Base.new
8
- end
9
-
10
- it "should be able to connect to Marvel API and bring a character" do
11
- hero = @uatu.character(1009262)
12
- hero.name.must_equal 'Daredevil'
13
- end
14
-
15
- it "should be able to connect to Marvel API and bring a character by name" do
16
- hero = @uatu.characters(name: 'Daredevil').first
17
- hero.name.must_equal 'Daredevil'
18
- end
19
-
20
- it "should be able to connect to Marvel API and bring comics from a character " do
21
- hero_comics = @uatu.character_comics(1009262)
22
- hero_comics.first.class.must_equal Uatu::Comic
23
- hero_comics.first.characters.items.any?{|item| item['name'].must_equal 'Daredevil' }
24
- end
25
-
26
- it "should be able to connect to Marvel API and bring a creator" do
27
- creator = @uatu.creator(2)
28
- creator.first_name.must_equal 'Garth'
29
- end
30
-
31
- it "should be able to connect to Marvel API and bring a creator by name" do
32
- creator = @uatu.creators(first_name: 'Garth', last_name: 'Ennis').first
33
- creator.first_name.must_equal 'Garth'
34
- end
35
-
36
- it "should be able to connect to Marvel API and bring an event" do
37
- event = @uatu.event(238)
38
- event.title.must_equal 'Civil War'
39
- end
40
-
41
- it "should be able to connect to Marvel API and bring an event by nae" do
42
- event = @uatu.events(name: 'Civil War').first
43
- event.id.must_equal 238
44
- end
45
-
46
- it "should be able to connect to Marvel API and bring an comic" do
47
- comic = @uatu.comic(41530)
48
- comic.title.must_equal 'Ant-Man: So (Trade Paperback)'
49
- end
50
-
51
- end
@@ -1,19 +0,0 @@
1
- require 'helper'
2
-
3
-
4
- describe '.configure' do
5
- after do
6
- Uatu.reset
7
- end
8
-
9
- it "should set the public and private key" do
10
- Uatu.configure do |config|
11
- config.public_key = 'PUBLIC_KEY'
12
- config.private_key = 'PRIVATE_KEY'
13
- end
14
-
15
- Uatu.public_key.must_equal 'PUBLIC_KEY'
16
- Uatu.private_key.must_equal 'PRIVATE_KEY'
17
- end
18
-
19
- end
@@ -1,31 +0,0 @@
1
- require 'helper'
2
-
3
-
4
- describe '.connect' do
5
-
6
- before do
7
- @uatu = Uatu::Base.new
8
- end
9
-
10
- it "should prepare options just fine" do
11
- unrubified = @uatu.prepare_options(format_type: 'comic', date_descriptor: 'lastWeek', limit: 20, character_id: '1009262')
12
-
13
- unrubified[:formatType].must_equal 'comic'
14
- unrubified[:dateDescriptor].must_equal 'lastWeek'
15
- unrubified[:limit].must_equal 20
16
- unrubified[:characterId].must_equal nil
17
- end
18
-
19
- it "should build normal routes just fine" do
20
- route = @uatu.build_route('character', {})
21
- route.must_equal "/v1/public/characters"
22
-
23
- route = @uatu.build_route('characters', {})
24
- route.must_equal "/v1/public/characters"
25
-
26
- route = @uatu.build_route('character', {character_id: '1009262'})
27
- route.must_equal "/v1/public/characters/1009262"
28
-
29
- end
30
-
31
- end
@@ -1,33 +0,0 @@
1
- require 'helper'
2
-
3
-
4
- describe '.initialize' do
5
-
6
-
7
- it "should underscore the response keys and add the shortcuts" do
8
- original = {"id"=>1009521,
9
- "name"=>" Hank Pym",
10
- "resourceURI" => "http://gateway.marvel.com/v1/public/characters/1009521",
11
- "thumbnail" =>
12
- { "path" => "http://i.annihil.us/u/prod/marvel/i/mg/8/c0/4ce5a0e31f109",
13
- "extension" => "jpg"
14
- },
15
- "comics"=>
16
- { "available"=>44,
17
- "items"=>
18
- [{"resourceURI"=>"http://gateway.marvel.com/v1/public/comics/35533",
19
- "name"=>"Amazing Spider-Man (1999) #661"}]
20
- }
21
- }
22
-
23
- resource = Uatu::Resource.new(original)
24
- resource.thumbnail.must_equal "http://i.annihil.us/u/prod/marvel/i/mg/8/c0/4ce5a0e31f109.jpg"
25
- resource.resource_uri.must_equal "http://gateway.marvel.com/v1/public/characters/1009521"
26
- resource.resourceURI.must_equal nil
27
- resource.comics.items.first.resource_uri.must_equal "http://gateway.marvel.com/v1/public/comics/35533"
28
- resource.comics.items.first.resourceURI.must_equal nil
29
- end
30
-
31
-
32
-
33
- end
@@ -1,9 +0,0 @@
1
- require 'helper'
2
-
3
- describe Uatu do
4
-
5
- it "should have a Version" do
6
- Uatu::VERSION.wont_be_nil
7
- end
8
-
9
- end