market_bot 0.12.2 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,67 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ include MarketBot::Movie
4
+
5
+ test_id = :topselling_paid
6
+ test_category = :comedy
7
+
8
+ def stub_hydra(hydra)
9
+ test_src_page = read_file(File.dirname(__FILE__), 'data', 'leaderboard-movies_comedy_topselling_paid.txt')
10
+ response = Typhoeus::Response.new(:code => 200, :headers => '', :body => test_src_page)
11
+ url = 'https://play.google.com/store/movies/category/COMEDY/collection/topselling_paid?start=0&num=24&hl=en'
12
+ Typhoeus.stub(url).and_return(response)
13
+ end
14
+
15
+ def check_results(results)
16
+ it 'should have the top ranking app with valid details' do
17
+ results.first[:genre].should == 'Comedy'
18
+ results.first[:stars].should == '3.6'
19
+ results.first[:title].should == 'Dear White People'
20
+ results.first[:price_usd].should == '$4.99'
21
+ results.first[:market_id].should == 'vRpjPMDxpg0'
22
+ results.first[:market_url].should == 'https://play.google.com/store/movies/details/Dear_White_People?id=vRpjPMDxpg0&hl=en'
23
+ end
24
+ end
25
+
26
+ describe 'Leaderboard' do
27
+ context 'Construction' do
28
+ it 'should copy params' do
29
+ lb = MarketBot::Movie::Leaderboard.new(test_id, test_category)
30
+ lb.identifier.should == test_id
31
+ lb.category.should == test_category
32
+ end
33
+
34
+ it 'should copy optional params' do
35
+ hydra = Typhoeus::Hydra.new
36
+ lb = MarketBot::Movie::Leaderboard.new(test_id, test_category, :hydra => hydra)
37
+ lb.hydra.should equal(hydra)
38
+ end
39
+
40
+ it 'should have an optional category parameter' do
41
+ lb = MarketBot::Movie::Leaderboard.new(test_id)
42
+ lb.identifier.should == test_id
43
+ lb.category.should == nil
44
+ end
45
+ end
46
+
47
+ describe 'Updating' do
48
+ context 'Quick API' do
49
+ stub_hydra(Typhoeus::Hydra.hydra)
50
+ lb = MarketBot::Movie::Leaderboard.new(test_id, test_category)
51
+ lb.instance_variable_set('@hydra', Typhoeus::Hydra.hydra)
52
+ lb.update(:min_rank => 1, :max_rank => 24)
53
+
54
+ check_results(lb.results)
55
+ end
56
+
57
+ context 'Batch API' do
58
+ hydra = Typhoeus::Hydra.new
59
+ stub_hydra(hydra)
60
+ lb = MarketBot::Movie::Leaderboard.new(test_id, test_category, :hydra => hydra)
61
+ lb.enqueue_update(:min_rank => 1, :max_rank => 24)
62
+ hydra.run
63
+
64
+ check_results(lb.results)
65
+ end
66
+ end
67
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: market_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.2
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Remesch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-04 00:00:00.000000000 Z
11
+ date: 2015-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -74,6 +74,9 @@ files:
74
74
  - lib/market_bot/android/leaderboard.rb
75
75
  - lib/market_bot/android/leaderboard/constants.rb
76
76
  - lib/market_bot/android/search_query.rb
77
+ - lib/market_bot/movie/leaderboard.rb
78
+ - lib/market_bot/movie/leaderboard/constants.rb
79
+ - lib/market_bot/movie/search_query.rb
77
80
  - lib/market_bot/version.rb
78
81
  - market_bot.gemspec
79
82
  - spec/market_bot/android/app_spec.rb
@@ -89,6 +92,8 @@ files:
89
92
  - spec/market_bot/android/developer_spec.rb
90
93
  - spec/market_bot/android/leaderboard_spec.rb
91
94
  - spec/market_bot/android/search_query_spec.rb
95
+ - spec/market_bot/movie/data/leaderboard-movies_comedy_topselling_paid.txt
96
+ - spec/market_bot/movie/leaderboard_spec.rb
92
97
  - spec/market_bot_spec.rb
93
98
  - spec/spec_helper.rb
94
99
  homepage: https://github.com/chadrem/market_bot
@@ -128,5 +133,7 @@ test_files:
128
133
  - spec/market_bot/android/developer_spec.rb
129
134
  - spec/market_bot/android/leaderboard_spec.rb
130
135
  - spec/market_bot/android/search_query_spec.rb
136
+ - spec/market_bot/movie/data/leaderboard-movies_comedy_topselling_paid.txt
137
+ - spec/market_bot/movie/leaderboard_spec.rb
131
138
  - spec/market_bot_spec.rb
132
139
  - spec/spec_helper.rb