Skip to content

Commit eff9dcd

Browse files
author
Vincent Wong
authored
Merge pull request #20 from Dainii/add-wow-race-endpoint
WoW - Add Race endpoint
2 parents 9190b1b + bc16fb4 commit eff9dcd

File tree

5 files changed

+293
-0
lines changed

5 files changed

+293
-0
lines changed

lib/rbattlenet/endpoints/wow/race.rb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module RBattlenet
2+
module Wow
3+
class Race < RBattlenet::Endpoints::Base
4+
def self.path(id)
5+
RBattlenet.uri("data/wow/playable-race/#{id}?namespace=static-")
6+
end
7+
8+
def self.index_path
9+
RBattlenet.uri("data/wow/playable-race/index?namespace=static-")
10+
end
11+
end
12+
end
13+
end

spec/lib/wow/race_spec.rb

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
require 'spec_helper'
2+
3+
describe RBattlenet::Wow::Race do
4+
before do
5+
RBattlenet.authenticate(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
6+
end
7+
8+
describe "#find_race" do
9+
it "fetches race data" do
10+
with_connection("wow_race") do
11+
result = RBattlenet::Wow::Race.find(2)
12+
expect(result.name).to eq "Orc"
13+
end
14+
end
15+
end
16+
17+
describe "#find_multiple_races" do
18+
it "fetches race data" do
19+
with_connection("wow_race_multiple") do
20+
collection = RBattlenet::Wow::Race.find([2, 3])
21+
expect(collection.results.map(&:name).sort).to eq ["Dwarf", "Orc"]
22+
end
23+
end
24+
end
25+
26+
describe "#find_all_races" do
27+
it "fetches all race data" do
28+
with_connection("wow_race_all") do
29+
result = RBattlenet::Wow::Race.all
30+
expect(result.races.size).to eq 25
31+
end
32+
end
33+
end
34+
end

spec/vcr_cassettes/wow_race.yml

+60
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/vcr_cassettes/wow_race_all.yml

+69
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/vcr_cassettes/wow_race_multiple.yml

+117
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)