kickscraper-snow 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,119 @@
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
+ it "searches projects for a specific one with wrong category" do
73
+ projects = client.search_projects('Spark Core Wi-Fi for Everything', nil, 1)
74
+ projects.length.should be 0
75
+ end
76
+
77
+ it "searches projects for a specific one with wrong state" do
78
+ projects = client.search_projects('Spark Core Wi-Fi for Everything', nil, nil, 'live')
79
+ projects.length.should be 0
80
+ end
81
+
82
+ it "searches projects for a specific one with correct category and state" do
83
+ projects = client.search_projects('Spark Core Wi-Fi for Everything', nil, 16, 'successful')
84
+ projects.length.should be > 0
85
+ projects[0].id.should be 373368980
86
+ end
87
+
88
+ describe "match search results seen in UI for projects with special characters" do
89
+ # https://www.kickstarter.com/projects/search?utf8=✓&term=%22angels%22+%26+demons+%21%40%23%24%27%25%5E%26*%28%29
90
+ it "handles searching for projects with isolated special characters" do
91
+ projects = client.search_projects %q{"angels" & demons !@#$'%^&*()}
92
+ projects.length.should == 0
93
+ end
94
+
95
+ # https://www.kickstarter.com/projects/search?utf8=✓&term=%22angels%22+%26demons%21%40%23%24%27%25%5E%26*%28%29
96
+ it "handles searching for projects with embedded special characters" do
97
+ projects = client.search_projects %q{"angels" &demons!@#$'%^&*()}
98
+ projects.length.should be > 0
99
+ end
100
+
101
+ # https://www.kickstarter.com/projects/search?term=Æsir
102
+ it "handles searching for projects with embedded special characters" do
103
+ pending("resolution of ArgumentError: invalid byte sequence in US-ASCII in lib/kickscrapper/connection.rb")
104
+ projects = client.search_projects "Æsir"
105
+ projects.length.should be > 0
106
+ end
107
+ end
108
+
109
+ it "returns an empty array when searching for projects and finding nothing" do
110
+ projects = client.search_projects "asfakjssdklfjsafajdfklafjdsl"
111
+ projects.should be_an(Array)
112
+ projects.should be_empty
113
+ end
114
+
115
+ context "doesn't load more projects after an unsuccessful search" do
116
+ before { client.search_projects "asfakjssdklfjsafajdfklafjdsl" }
117
+ its(:more_projects_available?) { should be_false }
118
+ end
119
+ end
@@ -0,0 +1,18 @@
1
+ # configure kickscraper before the tests
2
+ # (put your real kickstarter API credentials here)
3
+ KICKSCRAPER_TEST_API_EMAIL = 'your_kickstarter_email'
4
+ KICKSCRAPER_TEST_API_PASSWORD = 'your_kickstarter_password'
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,217 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kickscraper-snow
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ platform: ruby
6
+ authors:
7
+ - Mark Olson
8
+ - Ben Rugg
9
+ - James Allen
10
+ - Mark Anderson
11
+ - Amit Patel
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2015-07-27 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: bundler
19
+ requirement: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - "~>"
22
+ - !ruby/object:Gem::Version
23
+ version: '1.3'
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - "~>"
29
+ - !ruby/object:Gem::Version
30
+ version: '1.3'
31
+ - !ruby/object:Gem::Dependency
32
+ name: rake
33
+ requirement: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ - !ruby/object:Gem::Dependency
46
+ name: rspec-core
47
+ requirement: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - "~>"
50
+ - !ruby/object:Gem::Version
51
+ version: '2.14'
52
+ type: :development
53
+ prerelease: false
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - "~>"
57
+ - !ruby/object:Gem::Version
58
+ version: '2.14'
59
+ - !ruby/object:Gem::Dependency
60
+ name: faraday
61
+ requirement: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0.7'
66
+ - - "<"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.9'
69
+ type: :runtime
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0.7'
76
+ - - "<"
77
+ - !ruby/object:Gem::Version
78
+ version: '0.9'
79
+ - !ruby/object:Gem::Dependency
80
+ name: faraday_middleware
81
+ requirement: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '0.8'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '0.8'
93
+ - !ruby/object:Gem::Dependency
94
+ name: multi_json
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 1.0.3
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.0'
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 1.0.3
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: '1.0'
113
+ - !ruby/object:Gem::Dependency
114
+ name: hashie
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '2'
120
+ type: :runtime
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - "~>"
125
+ - !ruby/object:Gem::Version
126
+ version: '2'
127
+ - !ruby/object:Gem::Dependency
128
+ name: uri-query_params
129
+ requirement: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ description: Interact with Kickstarter through their API
142
+ email:
143
+ - amitkumarpatel44@gmail.com
144
+ executables: []
145
+ extensions: []
146
+ extra_rdoc_files: []
147
+ files:
148
+ - ".gitignore"
149
+ - ".rspec"
150
+ - CHANGELOG.md
151
+ - CONTRIBUTORS.md
152
+ - Gemfile
153
+ - Guardfile
154
+ - LICENSE.txt
155
+ - README.md
156
+ - Rakefile
157
+ - examples/my_projects.rb
158
+ - kickscraper.gemspec
159
+ - lib/kickscraper.rb
160
+ - lib/kickscraper/api.rb
161
+ - lib/kickscraper/client.rb
162
+ - lib/kickscraper/client/category.rb
163
+ - lib/kickscraper/client/comment.rb
164
+ - lib/kickscraper/client/location.rb
165
+ - lib/kickscraper/client/notifications.rb
166
+ - lib/kickscraper/client/project.rb
167
+ - lib/kickscraper/client/update.rb
168
+ - lib/kickscraper/client/user.rb
169
+ - lib/kickscraper/configure.rb
170
+ - lib/kickscraper/connection.rb
171
+ - lib/kickscraper/response.rb
172
+ - lib/kickscraper/version.rb
173
+ - spec/category_spec.rb
174
+ - spec/client_spec.rb
175
+ - spec/kickscraper_spec.rb
176
+ - spec/no_email_password_client_spec.rb
177
+ - spec/no_email_password_project_spec.rb
178
+ - spec/project_spec.rb
179
+ - spec/spec_helper.rb
180
+ - spec/support/shared_examples.rb
181
+ - spec/test_constants.rb
182
+ - spec/user_spec.rb
183
+ homepage: https://github.com/amitkumarpatel/kickscraper.git
184
+ licenses:
185
+ - N/A
186
+ metadata: {}
187
+ post_install_message:
188
+ rdoc_options: []
189
+ require_paths:
190
+ - lib
191
+ required_ruby_version: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ required_rubygems_version: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: '0'
201
+ requirements: []
202
+ rubyforge_project:
203
+ rubygems_version: 2.4.5
204
+ signing_key:
205
+ specification_version: 4
206
+ summary: API library for Kickstarter
207
+ test_files:
208
+ - spec/category_spec.rb
209
+ - spec/client_spec.rb
210
+ - spec/kickscraper_spec.rb
211
+ - spec/no_email_password_client_spec.rb
212
+ - spec/no_email_password_project_spec.rb
213
+ - spec/project_spec.rb
214
+ - spec/spec_helper.rb
215
+ - spec/support/shared_examples.rb
216
+ - spec/test_constants.rb
217
+ - spec/user_spec.rb