kickscraper 0.2.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,76 @@
1
+ describe Kickscraper::Project do
2
+ context "no email no password client" do
3
+ before(:all) do
4
+ @save_token = Kickscraper.token
5
+ Kickscraper.token=nil
6
+ end
7
+
8
+ after (:all) do
9
+ Kickscraper.token=@save_token
10
+ end
11
+
12
+ let(:client) do
13
+ Kickscraper.configure do |config|
14
+ config.email = nil
15
+ config.password = nil
16
+ end
17
+ Kickscraper::Client.new
18
+ end
19
+ subject (:project) { client.recently_launched_projects[0]}
20
+
21
+
22
+ it "loads all info for a project" do
23
+ project.id.should be > 0
24
+ project.name.should_not be_empty
25
+ project.launched_at.should be >= 1262304000
26
+ project.blurb.should_not be_empty
27
+ project.photo.length.should be > 0
28
+ project.goal.should be > 0
29
+ project.creator.should be_a Kickscraper::User
30
+ project.pledged.should be >= 0
31
+ project.created_at.should be >= 1262304000
32
+ project.slug.should_not be_empty
33
+ project.deadline.should be >= 1262304000
34
+ (project.active?.is_a?(TrueClass) || project.active?.is_a?(FalseClass)).should be_true
35
+ (project.successful?.is_a?(TrueClass) || project.successful?.is_a?(FalseClass)).should be_true
36
+ project.category.should be_a Kickscraper::Category
37
+ project.video.should be_nil
38
+ project.rewards.should be_nil
39
+ end
40
+
41
+ it "reloads" do
42
+ save_id = project.id
43
+ save_name = project.name
44
+
45
+ project.reload!
46
+
47
+ project.id.should == save_id
48
+ project.name.should == save_name
49
+ project.creator.should be_a Kickscraper::User
50
+ end
51
+
52
+ it "loads empty array for comments that depend on user being looged in and called by a separate API call" do
53
+ projects = client.popular_projects
54
+ project = projects[0]
55
+
56
+ comments = project.comments
57
+ comments.length.should be == 0
58
+ end
59
+
60
+ it "loads empty array for updates that depend on user being looged in and called by a separate API call" do
61
+ projects = client.popular_projects
62
+ project = projects[0]
63
+
64
+ updates = project.updates
65
+ updates.length.should be == 0
66
+ end
67
+
68
+
69
+ it "does not load the rewards for a project brought in thru public call" do
70
+ projects = client.recently_launched_projects
71
+ project = projects[0]
72
+
73
+ project.rewards.should be_nil
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,57 @@
1
+ describe Kickscraper::Project do
2
+ let(:client) { Kickscraper.client }
3
+ subject (:project) { client.find_project TEST_PROJECT_ID }
4
+
5
+ it "loads all info for a project" do
6
+ project.id.should be > 0
7
+ project.name.should_not be_empty
8
+ project.launched_at.should be >= 1262304000
9
+ project.blurb.should_not be_empty
10
+ project.photo.length.should be > 0
11
+ project.goal.should be > 0
12
+ project.creator.should be_a Kickscraper::User
13
+ project.pledged.should be >= 0
14
+ project.created_at.should be >= 1262304000
15
+ project.slug.should_not be_empty
16
+ project.deadline.should be >= 1262304000
17
+ (project.active?.is_a?(TrueClass) || project.active?.is_a?(FalseClass)).should be_true
18
+ (project.successful?.is_a?(TrueClass) || project.successful?.is_a?(FalseClass)).should be_true
19
+ project.category.should be_a Kickscraper::Category
20
+ project.video.length.should be > 0
21
+ project.rewards.length.should be > 0
22
+ end
23
+
24
+ it "reloads" do
25
+ project.reload!
26
+
27
+ project.id.should == TEST_PROJECT_ID
28
+ project.name.should == TEST_PROJECT_NAME
29
+ project.creator.should be_a Kickscraper::User
30
+ end
31
+
32
+ it "loads comments that must be called by a separate API call" do
33
+ projects = client.popular_projects
34
+ project = projects[0]
35
+
36
+ comments = project.comments
37
+ comments.length.should be >= 0
38
+ if comments.length > 0 then comments[0].should be_a Kickscraper::Comment end
39
+ end
40
+
41
+ it "loads updates that must be called by a separate API call" do
42
+ projects = client.popular_projects
43
+ project = projects[0]
44
+
45
+ updates = project.updates
46
+ updates.length.should be >= 0
47
+ if updates.length > 0 then updates[0].should be_a Kickscraper::Update end
48
+ end
49
+
50
+ it "loads the rewards for a project that was brought in through a different API call" do
51
+ projects = client.recently_launched_projects
52
+ project = projects[0]
53
+
54
+ rewards = project.rewards
55
+ rewards.length.should be > 0
56
+ end
57
+ end
@@ -0,0 +1,24 @@
1
+ @root_dir = File.expand_path(File.join(File.dirname(__FILE__), "../"))
2
+
3
+ $: << './'
4
+ $: << File.join(@root_dir, "lib", "kickscraper")
5
+ $: << File.join(@root_dir, "lib", "kickscraper", "client")
6
+ $: << File.join(@root_dir, "spec")
7
+
8
+ Dir["./spec/support/**/*.rb"].each {|f| require f}
9
+
10
+ require 'rubygems'
11
+ require 'rspec'
12
+ require 'kickscraper'
13
+ require 'test_constants'
14
+
15
+ # initialize kickscraper
16
+ Kickscraper.configure do |config|
17
+ config.email = KICKSCRAPER_TEST_API_EMAIL
18
+ config.password = KICKSCRAPER_TEST_API_PASSWORD
19
+ config.proxy = LOCAL_PROXY if defined? LOCAL_PROXY
20
+ end
21
+
22
+ RSpec.configure do |config|
23
+ config.alias_it_should_behave_like_to :it_returns, "returns"
24
+ end
@@ -0,0 +1,103 @@
1
+ shared_examples_for "a collection" do |type|
2
+ let(:item) { subject.first }
3
+
4
+ it { should_not be_empty}
5
+
6
+ it "first element is a #{type}" do
7
+ item.should be_a type
8
+ item.name.should_not be_empty if item.respond_to? :name
9
+ end
10
+ end
11
+
12
+ shared_examples_for "ending_soon projects" do
13
+ context "finds projects ending soon" do
14
+ subject { client.ending_soon_projects }
15
+ it_returns "a collection", Kickscraper::Project
16
+ end
17
+ end
18
+
19
+ shared_examples_for "recently_launched projects" do
20
+ context "finds projects recently lanunched" do
21
+ subject { client.recently_launched_projects}
22
+ it_returns "a collection", Kickscraper::Project
23
+ end
24
+
25
+ context "loads more projects after a successful search" do
26
+ subject do
27
+ client.recently_launched_projects
28
+ client.more_projects_available?.should be_true
29
+ client.load_more_projects
30
+ end
31
+
32
+ it_returns "a collection", Kickscraper::Project
33
+ end
34
+ end
35
+
36
+ shared_examples_for "newest_projects projects" do
37
+ context "finds recently launched projects with the 'newest_projects' method for backwards compatibility" do
38
+ subject { client.newest_projects }
39
+ it_behaves_like "recently_launched projects"
40
+ end
41
+ end
42
+
43
+ shared_examples_for "popular projects" do
44
+ context "finds popular projects" do
45
+ subject { client.popular_projects}
46
+ it_returns "a collection", Kickscraper::Project
47
+ end
48
+
49
+ context "loads popular projects starting at a specific page" do
50
+ subject { client.popular_projects(30) }
51
+ it_returns "a collection", Kickscraper::Project
52
+ end
53
+ end
54
+
55
+ shared_examples_for "search projects" do
56
+ context "searches projects with a keyword" do
57
+ subject { client.search_projects 'arduino' }
58
+ it_returns "a collection", Kickscraper::Project
59
+ end
60
+
61
+ context "searches for projects starting at a specific page of results" do
62
+ subject { client.search_projects('arduino', 2) }
63
+ it_returns "a collection", Kickscraper::Project
64
+ end
65
+
66
+ it "searches projects for a specific one" do
67
+ projects = client.search_projects 'Spark Core Wi-Fi for Everything'
68
+ projects.length.should be > 0
69
+ projects[0].id.should be 373368980
70
+ end
71
+
72
+ describe "match search results seen in UI for projects with special characters" do
73
+ # https://www.kickstarter.com/projects/search?utf8=✓&term=%22angels%22+%26+demons+%21%40%23%24%27%25%5E%26*%28%29
74
+ it "handles searching for projects with isolated special characters" do
75
+ projects = client.search_projects %q{"angels" & demons !@#$'%^&*()}
76
+ projects.length.should == 0
77
+ end
78
+
79
+ # https://www.kickstarter.com/projects/search?utf8=✓&term=%22angels%22+%26demons%21%40%23%24%27%25%5E%26*%28%29
80
+ it "handles searching for projects with embedded special characters" do
81
+ projects = client.search_projects %q{"angels" &demons!@#$'%^&*()}
82
+ projects.length.should be > 0
83
+ end
84
+
85
+ # https://www.kickstarter.com/projects/search?term=Æsir
86
+ it "handles searching for projects with embedded special characters" do
87
+ pending("resolution of ArgumentError: invalid byte sequence in US-ASCII in lib/kickscrapper/connection.rb")
88
+ projects = client.search_projects "Æsir"
89
+ projects.length.should be > 0
90
+ end
91
+ end
92
+
93
+ it "returns an empty array when searching for projects and finding nothing" do
94
+ projects = client.search_projects "asfakjssdklfjsafajdfklafjdsl"
95
+ projects.should be_an(Array)
96
+ projects.should be_empty
97
+ end
98
+
99
+ context "doesn't load more projects after an unsuccessful search" do
100
+ before { client.search_projects "asfakjssdklfjsafajdfklafjdsl" }
101
+ its(:more_projects_available?) { should be_false }
102
+ end
103
+ end
@@ -0,0 +1,18 @@
1
+ # configure kickscraper before the tests
2
+ # (put your real kickstarter API credentials here)
3
+ KICKSCRAPER_TEST_API_EMAIL = 'jumpkick.us@gmail.com'
4
+ KICKSCRAPER_TEST_API_PASSWORD = 'seriouslyReallyCreative282828'
5
+
6
+
7
+ # if you want to use a proxy (like Charles, etc) to capture
8
+ # data for debugging, set it here
9
+ LOCAL_PROXY = 'https://localhost:8888'
10
+
11
+
12
+ # define some test contants
13
+ TEST_USER_ID = 1869987317
14
+ TEST_PROJECT_ID = 1871494789
15
+ TEST_PROJECT_SLUG = 'wish-i-was-here-1'
16
+ TEST_PROJECT_NAME = "WISH I WAS HERE"
17
+ TEST_CATEGORY_NAME = 'Design'
18
+ TEST_CATEGORY_ID = 7
data/spec/user_spec.rb ADDED
@@ -0,0 +1,33 @@
1
+ describe Kickscraper::User do
2
+ subject { client.find_user TEST_USER_ID }
3
+ let(:client) { Kickscraper.client }
4
+
5
+ context "loading all info for a user" do
6
+
7
+ its(:id) { should be > 0 }
8
+ its(:name) { should_not be_empty }
9
+ its(:avatar) { should have_at_least(0).items }
10
+ its(:biography) { should_not be_empty }
11
+ its(:backed_projects_count) { should_not be_nil }
12
+ its(:created_at) { should be > 1262304000 }
13
+
14
+ its(:backed_projects) { should have_at_least(0).items }
15
+ its(:starred_projects) { should have_at_least(0).items }
16
+ its(:created_projects) { should have_at_least(0).items }
17
+ end
18
+
19
+ context "reloads" do
20
+ before(:each) { subject.reload! }
21
+
22
+ its(:id) { should eq TEST_USER_ID }
23
+ its(:name) { should eq 'Zach Braff'}
24
+ end
25
+
26
+
27
+ context "loads the biography for a user that was brought in through a different API call" do
28
+ let(:project) { client.find_project TEST_PROJECT_ID }
29
+ subject { project.creator }
30
+
31
+ its(:biography) { should_not be_empty }
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,216 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kickscraper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Mark Olson
8
+ - Ben Rugg
9
+ - James Allen
10
+ - Mark Anderson
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2014-03-10 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.3'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ - !ruby/object:Gem::Dependency
45
+ name: rspec-core
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ - !ruby/object:Gem::Dependency
59
+ name: faraday
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0.7'
65
+ - - "<"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.9'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0.7'
75
+ - - "<"
76
+ - !ruby/object:Gem::Version
77
+ version: '0.9'
78
+ - !ruby/object:Gem::Dependency
79
+ name: faraday_middleware
80
+ requirement: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '0.8'
85
+ type: :runtime
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '0.8'
92
+ - !ruby/object:Gem::Dependency
93
+ name: multi_json
94
+ requirement: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: 1.0.3
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '1.0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: 1.0.3
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '1.0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: hashie
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '2'
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '2'
126
+ - !ruby/object:Gem::Dependency
127
+ name: uri-query_params
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :runtime
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ description: Interact with Kickstarter through their API
141
+ email:
142
+ - theothermarkolson@gmail.com
143
+ executables: []
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - CHANGELOG.md
150
+ - CONTRIBUTORS.md
151
+ - Gemfile
152
+ - Guardfile
153
+ - LICENSE.txt
154
+ - README.md
155
+ - Rakefile
156
+ - examples/my_projects.rb
157
+ - kickscraper.gemspec
158
+ - lib/kickscraper.rb
159
+ - lib/kickscraper/api.rb
160
+ - lib/kickscraper/client.rb
161
+ - lib/kickscraper/client/category.rb
162
+ - lib/kickscraper/client/comment.rb
163
+ - lib/kickscraper/client/location.rb
164
+ - lib/kickscraper/client/notifications.rb
165
+ - lib/kickscraper/client/project.rb
166
+ - lib/kickscraper/client/update.rb
167
+ - lib/kickscraper/client/user.rb
168
+ - lib/kickscraper/configure.rb
169
+ - lib/kickscraper/connection.rb
170
+ - lib/kickscraper/response.rb
171
+ - lib/kickscraper/version.rb
172
+ - spec/category_spec.rb
173
+ - spec/client_spec.rb
174
+ - spec/kickscraper_spec.rb
175
+ - spec/no_email_password_client_spec.rb
176
+ - spec/no_email_password_project_spec.rb
177
+ - spec/project_spec.rb
178
+ - spec/spec_helper.rb
179
+ - spec/support/shared_examples.rb
180
+ - spec/test_constants.rb
181
+ - spec/user_spec.rb
182
+ homepage: https://github.com/markolson/kickscraper
183
+ licenses:
184
+ - MIT
185
+ metadata: {}
186
+ post_install_message:
187
+ rdoc_options: []
188
+ require_paths:
189
+ - lib
190
+ required_ruby_version: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ required_rubygems_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ requirements: []
201
+ rubyforge_project:
202
+ rubygems_version: 2.2.1
203
+ signing_key:
204
+ specification_version: 4
205
+ summary: API library for Kickstarter
206
+ test_files:
207
+ - spec/category_spec.rb
208
+ - spec/client_spec.rb
209
+ - spec/kickscraper_spec.rb
210
+ - spec/no_email_password_client_spec.rb
211
+ - spec/no_email_password_project_spec.rb
212
+ - spec/project_spec.rb
213
+ - spec/spec_helper.rb
214
+ - spec/support/shared_examples.rb
215
+ - spec/test_constants.rb
216
+ - spec/user_spec.rb