comic_vine 0.1.5 → 1.0.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.
@@ -1,122 +0,0 @@
1
- require 'spec_helper'
2
- describe ComicVine do
3
- before(:all) do
4
- ComicVine::API.key = "some_api_key"
5
- end
6
-
7
- specify { ComicVine::API.key.should == "some_api_key" }
8
-
9
- context "when has invalid api key" do
10
- it "should get a CVError" do
11
- WebMock.allow_net_connect!
12
- lambda { ComicVine::API.issues }.should raise_error(ComicVine::CVError)
13
- WebMock.disable_net_connect!
14
- end
15
- end
16
-
17
- context "when has valid api key" do
18
- before { stub_request(:get, "http://comicvine.gamespot.com/api/types/").with(:query => {:format => 'json', :api_key => ComicVine::API.key}, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).to_return(:status => 200, :body => TYPES_BODY, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}) }
19
-
20
- describe "invalid method" do
21
- it "should raise NoMethodError" do
22
- lambda { ComicVine::API.something }.should raise_error(NoMethodError)
23
- end
24
- end
25
-
26
- describe "types_detail" do
27
- before { @types_detail = ComicVine::API.find_detail "issue" }
28
- subject { @types_detail }
29
-
30
- specify { @types_detail["list_resource_name"].should == "issues" }
31
- specify { @types_detail["detail_resource_name"].should == "issue" }
32
- end
33
-
34
- describe "types_list" do
35
- before { @types_list = ComicVine::API.find_list "issues" }
36
- subject { @types_list }
37
-
38
- specify { @types_list["list_resource_name"].should == "issues" }
39
- specify { @types_list["detail_resource_name"].should == "issue" }
40
- end
41
-
42
- describe "ComicVine search" do
43
- before do
44
- stub_request(:get, "http://comicvine.gamespot.com/api/search/").with(:query => {:format => 'json', :api_key => ComicVine::API.key, :limit => 1, :resources => "volume", :query => "gizmo"}, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).to_return(:status => 200, :body => SEARCH_BODY_1, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'})
45
- stub_request(:get, "http://comicvine.gamespot.com/api/search/").with(:query => {:format => 'json', :api_key => ComicVine::API.key, :limit => 1, :page => 1, :resources => "volume", :query => "gizmo"}, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).to_return(:status => 200, :body => SEARCH_BODY_1, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'})
46
- stub_request(:get, "http://comicvine.gamespot.com/api/search/").with(:query => {:format => 'json', :api_key => ComicVine::API.key, :limit => 1, :page => 2, :resources => "volume", :query => "gizmo"}, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).to_return(:status => 200, :body => SEARCH_BODY_2, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'})
47
- @results = ComicVine::API.search "volume", "gizmo", {:limit => 1}
48
- end
49
- subject { @results }
50
-
51
- it { should be_a_kind_of ComicVine::CVSearchList }
52
- it { should respond_to("total_count", "offset", "limit", "resource", "query")}
53
- specify { @results.first.should be_a_kind_of ComicVine::CVObject }
54
- specify { @results.first.should == @results.last }
55
- specify { @results.prev_page.should be_nil }
56
-
57
- context "when on last page" do
58
- before { @results.next_page }
59
-
60
- specify { @results.should be_a_kind_of ComicVine::CVSearchList }
61
- specify { @results.next_page.should be_nil }
62
- it "should update the list on prev_page" do
63
- @results.prev_page
64
- @results.should be_a_kind_of ComicVine::CVSearchList
65
- end
66
- end
67
-
68
- it "should fetch the full CVObject" do
69
- stub_request(:get, "http://comicvine.gamespot.com/api/volume/4050-24708/").with(:query => {:format => 'json', :api_key => ComicVine::API.key}, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).to_return(:status => 200, :body => VOLUME_BODY, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'})
70
- vol = @results.first.fetch
71
- vol.should be_a_kind_of ComicVine::CVObject
72
- end
73
- end
74
-
75
- describe "ComicVine list" do
76
- before do
77
- stub_request(:get, "http://comicvine.gamespot.com/api/issues/").with(:query => {:format => 'json', :api_key => ComicVine::API.key}, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).to_return(:status => 200, :body => ISSUES_BODY_1, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'})
78
- stub_request(:get, "http://comicvine.gamespot.com/api/issues/").with(:query => {:format => 'json', :api_key => ComicVine::API.key, :limit => 2, :offset => 0}, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).to_return(:status => 200, :body => ISSUES_BODY_1, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'})
79
- stub_request(:get, "http://comicvine.gamespot.com/api/issues/").with(:query => {:format => 'json', :api_key => ComicVine::API.key, :limit => 2, :offset => 2}, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).to_return(:status => 200, :body => ISSUES_BODY_2, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'})
80
- @issues = ComicVine::API.issues
81
- end
82
- subject { @issues }
83
-
84
- it { should be_a_kind_of ComicVine::CVList }
85
- it { should respond_to("total_count", "offset", "limit", "resource")}
86
- specify { @issues.prev_page.should be_nil }
87
-
88
- context "when on last page" do
89
- before { @issues.next_page }
90
-
91
- specify { @issues.should be_a_kind_of ComicVine::CVList }
92
- specify { @issues.next_page.should be_nil }
93
- it "should update the list on prev_page" do
94
- @issues.prev_page
95
- @issues.should be_a_kind_of ComicVine::CVList
96
- end
97
- end
98
- end
99
-
100
- describe "ComicVine detail" do
101
- before do
102
- stub_request(:get, "http://comicvine.gamespot.com/api/issue/4000-145830/").with(:query => {:format => 'json', :api_key => ComicVine::API.key}, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).to_return(:status => 200, :body => ISSUE_BODY, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'})
103
- @issue = ComicVine::API.issue 145830
104
- end
105
- subject { @issue }
106
-
107
- it { should be_a_kind_of ComicVine::CVObject }
108
- it { should respond_to("site_detail_url", "publish_year")}
109
- specify { lambda { @issue.something }.should raise_error(NoMethodError) }
110
- specify { lambda { @issue.get_something }.should raise_error(NoMethodError) }
111
-
112
- it "should have a detail and list association" do
113
- stub_request(:get, "http://comicvine.gamespot.com/api/volume/4050-24708/").with(:query => {:format => 'json', :api_key => ComicVine::API.key}, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).to_return(:status => 200, :body => VOLUME_BODY, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'})
114
- vol = @issue.get_volume
115
- vol.should be_a_kind_of ComicVine::CVObject
116
- iss = vol.get_issues
117
- iss.should be_a_kind_of Array
118
- iss.first.should be_a_kind_of ComicVine::CVObject
119
- end
120
- end
121
- end
122
- end
data/spec/spec_helper.rb DELETED
@@ -1,34 +0,0 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # Require this file using `require "spec_helper.rb"` to ensure that it is only
4
- # loaded once.
5
- #
6
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
- require 'simplecov'
8
- SimpleCov.start
9
-
10
- require 'comic_vine'
11
- #require 'webmock'
12
- require 'webmock/rspec'
13
-
14
-
15
- RSpec.configure do |config|
16
- config.treat_symbols_as_metadata_keys_with_true_values = true
17
- config.run_all_when_everything_filtered = true
18
- #config.filter_run :focus
19
- end
20
-
21
- TYPES_BODY = '{"number_of_page_results": 17, "status_code": 1, "error": "OK", "results": [{"detail_resource_name": "issue", "id": 4000, "list_resource_name": "issues"}, {"detail_resource_name": "volume", "id": 4050, "list_resource_name": "volumes"}], "limit": 17, "offset": 0, "number_of_total_results": 17}'
22
-
23
- ISSUE_BODY = '{"number_of_page_results": 1, "status_code": 1, "error": "OK", "results": {"site_detail_url": "http://comicvine.gamespot.com/gizmo-/37-145830/", "id": 145830, "volume": {"api_detail_url": "http://comicvine.gamespot.com/api/volume/4050-24708/", "id": 24708, "name": "Gizmo"}, "publish_year": null}, "limit": 1, "offset": 0, "number_of_total_results": 1}'
24
-
25
- ISSUES_BODY_1 = '{"number_of_page_results": 2, "status_code": 1, "error": "OK", "results": [{"api_detail_url": "http://comicvine.gamespot.com/api/issue/6/", "site_detail_url": "http://comicvine.gamespot.com/chamber-of-chills-magazine-man-in-the-hood-the-lost-race-the-man-germ-the-things/37-6/", "description": "", "deck": "", "aliases": "", "issue_number": "13.00", "publish_year": 1952, "has_staff_review": false, "date_added": "2008-06-06 11:10:16", "publish_day": null, "publish_month": 10, "id": 6, "name": "Man In the Hood; The Lost Race; The Man Germ; The Things; "}, {"api_detail_url": "http://comicvine.gamespot.com/api/issue/7/", "site_detail_url": "http://comicvine.gamespot.com/fighting-fronts-/37-7/", "description": "", "deck": "", "aliases": "", "issue_number": "3.00", "publish_year": 0, "has_staff_review": false, "date_added": "2008-06-06 11:10:16", "publish_day": null, "publish_month": 0, "id": 7, "name": ""}], "limit": 2, "offset": 0, "number_of_total_results": 4}'
26
-
27
- ISSUES_BODY_2 = '{"number_of_page_results": 2, "status_code": 1, "error": "OK", "results": [{"api_detail_url": "http://comicvine.gamespot.com/api/issue/6/", "site_detail_url": "http://comicvine.gamespot.com/chamber-of-chills-magazine-man-in-the-hood-the-lost-race-the-man-germ-the-things/37-6/", "description": "", "deck": "", "aliases": "", "date_last_updated": "2009-01-27 12:47:44", "volume": {"api_detail_url": "http://comicvine.gamespot.com/api/volume/4050-1487/", "id": 1487, "name": "Chamber of Chills Magazine"}, "issue_number": "13.00", "publish_year": 1952, "has_staff_review": false, "date_added": "2008-06-06 11:10:16", "publish_day": null, "publish_month": 10, "id": 6, "name": "Man In the Hood; The Lost Race; The Man Germ; The Things; "}, {"api_detail_url": "http://comicvine.gamespot.com/api/issue/7/", "site_detail_url": "http://comicvine.gamespot.com/fighting-fronts-/37-7/", "description": "", "deck": "", "aliases": "", "date_last_updated": "2008-06-06 11:32:53", "volume": {"api_detail_url": "http://comicvine.gamespot.com/api/volume/4050-1488/", "id": 1488, "name": "Fighting Fronts!"}, "issue_number": "3.00", "publish_year": 0, "has_staff_review": false, "date_added": "2008-06-06 11:10:16", "publish_day": null, "publish_month": 0, "id": 7, "name": ""}], "limit": 2, "offset": 2, "number_of_total_results": 4}'
28
-
29
- VOLUME_BODY = '{"number_of_page_results": 1, "status_code": 1, "error": "OK", "results": {"id": 24708, "issues": [{"api_detail_url": "http://comicvine.gamespot.com/api/issue/4000-145830/", "issue_number": "1.00", "id": 145830, "name": " "}]}, "limit": 1, "offset": 0, "number_of_total_results": 1}'
30
-
31
-
32
- SEARCH_BODY_1 = '{"number_of_page_results": 1, "status_code": 1, "error": "OK", "results": [{"publisher": {"api_detail_url": "http://comicvine.gamespot.com/api/publisher/517/", "id": 517, "name": "Mirage"}, "start_year": 1985, "description": "", "deck": "", "last_issue": null, "date_last_updated": "2010-07-04 20:51:17", "first_issue": null, "api_detail_url": "http://comicvine.gamespot.com/api/volume/4050-24708/", "count_of_issues": 6, "id": 24708, "date_added": "2008-12-12 16:58:16", "aliases": "", "site_detail_url": "http://comicvine.gamespot.com/gizmo/49-24708/", "resource_type": "volume", "name": "Gizmo"}], "limit": 1, "offset": 0, "number_of_total_results": 2}'
33
-
34
- SEARCH_BODY_2 = '{"number_of_page_results": 1, "status_code": 1, "error": "OK", "results": [{"publisher": {"api_detail_url": "http://comicvine.gamespot.com/api/publisher/517/", "id": 517, "name": "Mirage"}, "start_year": null, "description": "", "deck": "Mirage volume starring Fugitoid and Gizmo", "last_issue": null, "date_last_updated": "2010-04-28 14:24:46", "first_issue": null, "api_detail_url": "http://comicvine.gamespot.com/api/volume/4050-32839/", "count_of_issues": 2, "id": 32839, "date_added": "2010-04-28 14:22:46", "aliases": "", "site_detail_url": "http://comicvine.gamespot.com/gizmo-and-the-fugitoid/49-32839/", "resource_type": "volume", "name": "Gizmo and the Fugitoid"}], "limit": 1, "offset": 1, "number_of_total_results": 2}'