Skip to content

Commit

Permalink
Merge pull request #23 from drecom/feature/new_game_category
Browse files Browse the repository at this point in the history
Feature/new game category
  • Loading branch information
sue445 committed Mar 19, 2014
2 parents 3714686 + 12db805 commit 5c21373
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 36 deletions.
1 change: 1 addition & 0 deletions android_market_api.gemspec
Expand Up @@ -28,6 +28,7 @@ Gem::Specification.new do |s|
# development dependencies
#
s.add_development_dependency "rspec", "~> 2.14.1"
s.add_development_dependency "rspec-parameterized", "~> 0.0.9"
s.add_development_dependency "pry"
s.add_development_dependency "pry-nav"
s.add_development_dependency "coveralls"
Expand Down
78 changes: 63 additions & 15 deletions lib/android_market_api/android_market.rb
Expand Up @@ -13,9 +13,69 @@

class AndroidMarket

@@game_categories=Array.[]('ARCADE','BRAIN','CARDS','CASUAL','GAME_WALLPAPER','RACING','SPORTS_GAMES','GAME_WIDGETS')
@@application_categories=Array.[]('BOOKS_AND_REFERENCE','BUSINESS','COMICS','COMMUNICATION','EDUCATION','ENTERTAINMENT','FINANCE','HEALTH_AND_FITNESS','LIBRARIES_AND_DEMO','LIFESTYLE','APP_WALLPAPER','MEDIA_AND_VIDEO','MEDICAL','MUSIC_AND_AUDIO','NEWS_AND_MAGAZINES','PERSONALIZATION','PHOTOGRAPHY','PRODUCTIVITY','SHOPPING','SOCIAL','SPORTS','TOOLS','TRANSPORTATION','TRAVEL_AND_LOCAL','WEATHER','APP_WIDGETS')
@@languages=Array.[]('en','pt_PT','pt_BR','es','es_419','fr','it','es')
GAME_CATEGORIES = %w(
GAME
GAME_ACTION
GAME_ADVENTURE
GAME_ARCADE
GAME_WIDGETS
GAME_CASINO
GAME_CASUAL
GAME_CARD
GAME_SIMULATION
GAME_STRATEGY
GAME_SPORTS
GAME_PUZZLE
GAME_FAMILY
GAME_BOARD
GAME_WALLPAPER
GAME_RACING
GAME_ROLE_PLAYING
GAME_EDUCATIONAL
GAME_WORD
GAME_TRIVIA
GAME_MUSIC
)

APPLICATION_CATEGORIES = %w(
APP_WIDGETS
ENTERTAINMENT
PERSONALIZATION
COMICS
SHOPPING
SPORTS
SOCIAL
TOOLS
NEWS_AND_MAGAZINES
BUSINESS
FINANCE
MEDIA_AND_VIDEO
LIFESTYLE
LIBRARIES_AND_DEMO
APP_WALLPAPER
TRANSPORTATION
PRODUCTIVITY
HEALTH_AND_FITNESS
PHOTOGRAPHY
MEDICAL
WEATHER
EDUCATION
TRAVEL_AND_LOCAL
BOOKS_AND_REFERENCE
COMMUNICATION
MUSIC_AND_AUDIO
)

LANGUAGES = %w(
en
pt_PT
pt_BR
es
es_419
fr
it
es
)

@@debug=false

Expand Down Expand Up @@ -85,18 +145,6 @@ def get_developer_app_list(developer_name, position, options={})
get_apps_in_carousel(developer_app_url(developer_name, position, options), DEVELOPER_APP_XPATH, options)
end

def get_languages()
return @@languages
end

def get_game_categories()
return @@game_categories
end

def get_application_categories()
return @@application_categories
end

def debug=(is_debug)
@@debug = is_debug
end
Expand Down
93 changes: 72 additions & 21 deletions spec/android_market_spec.rb
Expand Up @@ -7,27 +7,6 @@
AndroidMarket::APP_COUNT_IN_PAGE = 1
end

describe "#get_application_categories" do
subject { AndroidMarket.get_application_categories }

it{ should have_at_least(1).items }
it{ should include "BOOKS_AND_REFERENCE" }
end

describe "#get_languages" do
subject { AndroidMarket.get_languages }

it{ should have_at_least(1).items }
it{ should include "en" }
end

describe "#get_game_categories" do
subject { AndroidMarket.get_game_categories }

it{ should have_at_least(1).items }
it{ should include "ARCADE" }
end

let(:category) { "BOOKS_AND_REFERENCE" }
let(:position) { 1 }
let(:options) do
Expand All @@ -46,12 +25,52 @@
subject { AndroidMarket.get_top_selling_free_app_in_category(category, position, options) }

it{ should be_an_instance_of AndroidMarketApplication }

context "each GAME_CATEGORIES" do
where(:category) do
AndroidMarket::GAME_CATEGORIES.product
end

with_them do
it{ should be_an_instance_of AndroidMarketApplication }
end
end

context "each APPLICATION_CATEGORIES" do
where(:category) do
AndroidMarket::APPLICATION_CATEGORIES.product
end

with_them do
it{ should be_an_instance_of AndroidMarketApplication }
end
end
end

describe "#get_top_selling_paid_app_in_category" do
subject { AndroidMarket.get_top_selling_paid_app_in_category(category, position, options) }

it{ should be_an_instance_of AndroidMarketApplication }

context "each GAME_CATEGORIES" do
where(:category) do
AndroidMarket::GAME_CATEGORIES.product
end

with_them do
it{ should be_an_instance_of AndroidMarketApplication }
end
end

context "each APPLICATION_CATEGORIES" do
where(:category) do
AndroidMarket::APPLICATION_CATEGORIES.product
end

with_them do
it{ should be_an_instance_of AndroidMarketApplication }
end
end
end

describe "#get_overall_top_selling_free_app" do
Expand Down Expand Up @@ -203,4 +222,36 @@
end
end
end

describe "GAME_CATEGORIES", :content => "real" do
where(:category) do
AndroidMarket::GAME_CATEGORIES.inject([]){|array, category| array << [category]; array }
end

with_them do
it "get_top_selling_free_app_in_category should be success" do
AndroidMarket.get_top_selling_free_app_in_category(category, position)
end

it "get_top_selling_paid_app_in_category should be success" do
AndroidMarket.get_top_selling_paid_app_in_category(category, position)
end
end
end

describe "APPLICATION_CATEGORIES", :content => "real" do
where(:category) do
AndroidMarket::APPLICATION_CATEGORIES.inject([]){|array, category| array << [category]; array }
end

with_them do
it "get_top_selling_free_app_in_category should be success" do
AndroidMarket.get_top_selling_free_app_in_category(category, position)
end

it "get_top_selling_paid_app_in_category should be success" do
AndroidMarket.get_top_selling_paid_app_in_category(category, position)
end
end
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Expand Up @@ -3,6 +3,7 @@
require "android_market_api"
require "rspec"
require "pry"
require "rspec-parameterized"

require 'coveralls'
Coveralls.wear!
Expand Down

0 comments on commit 5c21373

Please sign in to comment.