Skip to content

Commit

Permalink
Merge pull request #1 from wingyu/master
Browse files Browse the repository at this point in the history
update repo
  • Loading branch information
Dainii authored Oct 4, 2020
2 parents 8cf007f + d443c64 commit 8020035
Show file tree
Hide file tree
Showing 403 changed files with 1,239 additions and 917 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,18 @@ characters = RBattlenet::Wow::Character.all
```

## Testing
Test against the stored VCR cassettes
```ruby
CLIENT_ID=<your_id> CLIENT_SECRET=<your_secret> bundle exec rspec
bundle exec rspec spec/ # Execute all the tests
bundle exec rspec spec/lib/wow/character_spec.rb # Execute only the character_spec tests
```

If you wish to test with real API connections:
If there is no VCR cassette for the test
```ruby
RECORD_CASSETTE=1 CLIENT_ID=<your_id> CLIENT_SECRET=<your_secret> bundle exec rspec
```

If you wish to test against the real API and bypass the :
```ruby
REAL_CONNECTIONS=1 CLIENT_ID=<your_id> CLIENT_SECRET=<your_secret> bundle exec rspec
```
Expand Down
13 changes: 13 additions & 0 deletions lib/rbattlenet/endpoints/wow/class.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module RBattlenet
module Wow
class Class < RBattlenet::Endpoints::Base
def self.path(id)
RBattlenet.uri("data/wow/playable-class/#{id}?namespace=static-")
end

def self.index_path
RBattlenet.uri("data/wow/playable-class/index?namespace=static-")
end
end
end
end
9 changes: 9 additions & 0 deletions lib/rbattlenet/endpoints/wow/class/media.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module RBattlenet
module Wow
class Class::Media < RBattlenet::Endpoints::Base
def self.path(id)
RBattlenet.uri("data/wow/media/playable-class/#{id}?namespace=static-")
end
end
end
end
13 changes: 13 additions & 0 deletions lib/rbattlenet/endpoints/wow/race.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module RBattlenet
module Wow
class Race < RBattlenet::Endpoints::Base
def self.path(id)
RBattlenet.uri("data/wow/playable-race/#{id}?namespace=static-")
end

def self.index_path
RBattlenet.uri("data/wow/playable-race/index?namespace=static-")
end
end
end
end
7 changes: 6 additions & 1 deletion lib/rbattlenet/rbattlenet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ def self.authenticate(client_id:, client_secret:)
true
end

# Set a fake token for RSpec tests
def self.fake_authenticate
@@token = "abcdefghijklmnopqrstuvwxyz01234567"
end

def self.set_options(region: @@region, locale: @@locale, response_type: @@response_type, concurrency: @@concurrency, timeout: @@timeout)
@@region, @@locale, @@response_type, @@concurrency, @@timeout = region, locale, response_type, concurrency, timeout
true
Expand All @@ -35,7 +40,7 @@ def get(subjects)
hydra = Typhoeus::Hydra.new(max_concurrency: @@concurrency)
subjects.each do |uris, subject|
uris.each do |field, uri|
request = Typhoeus::Request.new(URI.encode(uri), headers: headers, timeout: @@timeout)
request = Typhoeus::Request.new(URI::DEFAULT_PARSER.escape(uri), headers: headers, timeout: @@timeout)

request.on_complete do |response|
if @@response_type == :raw
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/account_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::Account do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::Account, type: :community do

describe "#find_account" do
it "fetches account data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/act_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::Act do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::Act, type: :community do

describe "#find_act" do
it "fetches act data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/artisan_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::Artisan do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::Artisan, type: :community do

describe "#find_artisan" do
it "fetches artisan data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/character_class_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::CharacterClass do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::CharacterClass, type: :community do

describe "#find_character_class" do
it "fetches character_class data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/era_leaderboard_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::EraLeaderboard do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::EraLeaderboard, type: :game_data do

describe "#find_era_leaderboard" do
it "fetches era leaderboard data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/era_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::Era do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::Era, type: :game_data do

describe "#find_era" do
it "fetches era data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/follower_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::Follower do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::Follower, type: :community do

describe "#find_follower" do
it "fetches follower data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/hero_follower_items_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::Hero::FollowerItems do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::Hero::FollowerItems, type: :community do

describe "#find_hero_follower_items" do
it "fetches hero follower items data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/hero_items_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::Hero::Items do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::Hero::Items, type: :community do

describe "#find_hero_items" do
it "fetches hero items data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/hero_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::Hero do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::Hero, type: :community do

describe "#find_hero" do
it "fetches hero data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/item_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::Item do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::Item, type: :community do

describe "#find_item" do
it "fetches item data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/item_type_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::ItemType do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::ItemType, type: :community do

describe "#find_item_type" do
it "fetches item_type data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/recipe_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::Recipe do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::Recipe, type: :community do

describe "#find_recipe" do
it "fetches recipe data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/season_leaderboard_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::SeasonLeaderboard do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::SeasonLeaderboard, type: :game_data do

describe "#find_season_leaderboard" do
it "fetches season leaderboard data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/season_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::Season do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::Season, type: :game_data do

describe "#find_season" do
it "fetches season data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/d3/skill_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::D3::Skill do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::D3::Skill, type: :community do

describe "#find_skill" do
it "fetches skill data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/hearthstone/card_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::Hearthstone::Card do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::Hearthstone::Card, type: :game_data do

describe "#find_single_card" do
it "fetches card data" do
Expand Down
3 changes: 0 additions & 3 deletions spec/lib/hearthstone/deck_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::Hearthstone::Deck do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end

describe "#find_deck" do
it "fetches deck data" do
Expand Down
3 changes: 0 additions & 3 deletions spec/lib/hearthstone/metadata_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::Hearthstone::Metadata do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end

describe "#find_metadata" do
it "fetches metadata" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/sc2/account_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::Sc2::Account do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::Sc2::Account, type: :community do

describe "#find_account" do
it "fetches account data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/sc2/leaderboard_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::Sc2::Leaderboard do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::Sc2::Leaderboard, type: :community do

describe "#find_leaderboard" do
it "fetches leaderboard profile data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/sc2/league_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::Sc2::League do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::Sc2::League, type: :game_data do

describe "#find_league" do
it "fetches league data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/sc2/legacy/achievements_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::Sc2::Legacy::Achievements do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::Sc2::Legacy::Achievements, type: :community do

describe "#find_achievements" do
it "fetches achievements data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/sc2/legacy/ladder_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::Sc2::Legacy::Ladder do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::Sc2::Legacy::Ladder, type: :community do

describe "#find_ladder" do
it "fetches ladder data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/sc2/legacy/profile_ladders_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::Sc2::Legacy::ProfileLadders do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::Sc2::Legacy::ProfileLadders, type: :community do

describe "#find_legacy_profile_ladders" do
it "fetches legacy profile ladders data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/sc2/legacy/profile_match_history_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::Sc2::Legacy::ProfileMatchHistory do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::Sc2::Legacy::ProfileMatchHistory, type: :community do

describe "#find_legacy_profile_match_history" do
it "fetches legacy profile match history data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/sc2/legacy/profile_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::Sc2::Legacy::Profile do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::Sc2::Legacy::Profile, type: :community do

describe "#find_legacy_profile" do
it "fetches legacy profile data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/sc2/legacy/rewards_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::Sc2::Legacy::Rewards do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::Sc2::Legacy::Rewards, type: :community do

describe "#find_rewards" do
it "fetches rewards data" do
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/sc2/profile_ladder_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'spec_helper'

describe RBattlenet::Sc2::ProfileLadder do
before do
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
end
describe RBattlenet::Sc2::ProfileLadder, type: :community do

describe "#find_profile_ladder" do
it "fetches profile ladder data" do
Expand Down
Loading

0 comments on commit 8020035

Please sign in to comment.