rspec for runes, maasteries and history games

This commit is contained in:
danijoo
2014-03-24 16:31:43 +01:00
parent 99390a24d2
commit 64b301543b
4 changed files with 231 additions and 2 deletions

View File

@@ -26,7 +26,7 @@ end
# @attr [Fixnum] mapId ID of the played map
# @attr [Fixnum] spell1 selected summoner spell no 1
# @attr [Fixnum] spell2 selected summoner spell no 2
# @attr [String] subtype subtype
# @attr [String] subType subtype
# @attr [Fixnum] teamId ID of the team if there is a team associated to the game
# @attr [Hash<String, Fixnum, Boolean>] statistics statistics of the game as a Hash: name -> value
class HistoryGame
@@ -62,7 +62,7 @@ end
# player of a game
# @attr [Fixnum] championId ID of played Champion
# @attr [Fixnum] summonerId ID of the summoner
# @attr [Fixnum] teammId ID of the team
# @attr [Fixnum] teamId ID of the team
class Player
attr_accessor :championId, :summonerId, :teamId

70
spec/masterybook_spec.rb Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,88 @@
require 'spec_helper'
require 'json'
module Sightstone
describe MatchHistory do
before :all do
json_mockup = JSON.parse('{"games":[{"gameType": "MATCHED_GAME","fellowPlayers": [{"championId": 102,"teamId": 100,"summonerId": 19440603},{"championId": 51,"teamId": 200,"summonerId": 26261198},{"championId": 79,"teamId": 100,"summonerId": 22151489},{"championId": 13,"teamId": 200,"summonerId": 23429462},{"championId": 106,"teamId": 200,"summonerId": 30818765},{"championId": 48,"teamId": 200,"summonerId": 25932666},{"championId": 24,"teamId": 100,"summonerId": 22906613},{"championId": 89,"teamId": 200,"summonerId": 33288326},{"championId": 16,"teamId": 100,"summonerId": 238666}],"stats": {"totalDamageDealtToChampions": 26806,"item2": 3252,"goldEarned": 12738,"item1": 3031,"wardPlaced": 9,"totalDamageTaken": 25573,"item0": 1055,"trueDamageDealtPlayer": 10713,"physicalDamageDealtPlayer": 129104,"trueDamageDealtToChampions": 5597,"killingSprees": 2,"totalUnitsHealed": 1,"largestCriticalStrike": 696,"level": 16,"doubleKills": 1,"neutralMinionsKilledYourJungle": 8,"neutralMinionsKilledEnemyJungle": 7,"assists": 5,"magicDamageTaken": 9216,"numDeaths": 9,"totalTimeCrowdControlDealt": 604,"largestMultiKill": 2,"physicalDamageTaken": 15714,"sightWardsBought": 2,"win": false,"team": 100,"totalDamageDealt": 139818,"largestKillingSpree": 4,"totalHeal": 1004,"item4": 3072,"item3": 3046,"item6": 3340,"minionsKilled": 171,"timePlayed": 2124,"physicalDamageDealtToChampions": 21208,"championsKilled": 10,"trueDamageTaken": 642,"goldSpent": 14620,"neutralMinionsKilled": 15},"gameId": 1390514911,"spell1": 4,"teamId": 100,"spell2": 21,"gameMode": "CLASSIC","mapId": 1,"level": 30,"invalid": false,"subType": "RANKED_SOLO_5x5","championId": 29,"createDate": 1395672014277}], "summonerId": 12345}')
@mh = MatchHistory.new(json_mockup)
end
describe "#new" do
it "should init a match hisotry object" do
@mh.should be_instance_of MatchHistory
end
it "should init with correct params" do
@mh.summonerId.should be_instance_of Fixnum
@mh.games.should be_instance_of Array
@mh.games.each do |game|
game.should be_instance_of HistoryGame
end
end
end
end
describe HistoryGame do
before :all do
json_mockup = JSON.parse('{"gameType": "MATCHED_GAME","fellowPlayers": [{"championId": 102,"teamId": 100,"summonerId": 19440603},{"championId": 51,"teamId": 200,"summonerId": 26261198},{"championId": 79,"teamId": 100,"summonerId": 22151489},{"championId": 13,"teamId": 200,"summonerId": 23429462},{"championId": 106,"teamId": 200,"summonerId": 30818765},{"championId": 48,"teamId": 200,"summonerId": 25932666},{"championId": 24,"teamId": 100,"summonerId": 22906613},{"championId": 89,"teamId": 200,"summonerId": 33288326},{"championId": 16,"teamId": 100,"summonerId": 238666}],"stats": {"totalDamageDealtToChampions": 26806,"item2": 3252,"goldEarned": 12738,"item1": 3031,"wardPlaced": 9,"totalDamageTaken": 25573,"item0": 1055,"trueDamageDealtPlayer": 10713,"physicalDamageDealtPlayer": 129104,"trueDamageDealtToChampions": 5597,"killingSprees": 2,"totalUnitsHealed": 1,"largestCriticalStrike": 696,"level": 16,"doubleKills": 1,"neutralMinionsKilledYourJungle": 8,"neutralMinionsKilledEnemyJungle": 7,"assists": 5,"magicDamageTaken": 9216,"numDeaths": 9,"totalTimeCrowdControlDealt": 604,"largestMultiKill": 2,"physicalDamageTaken": 15714,"sightWardsBought": 2,"win": false,"team": 100,"totalDamageDealt": 139818,"largestKillingSpree": 4,"totalHeal": 1004,"item4": 3072,"item3": 3046,"item6": 3340,"minionsKilled": 171,"timePlayed": 2124,"physicalDamageDealtToChampions": 21208,"championsKilled": 10,"trueDamageTaken": 642,"goldSpent": 14620,"neutralMinionsKilled": 15},"gameId": 1390514911,"spell1": 4,"teamId": 100,"spell2": 21,"gameMode": "CLASSIC","mapId": 1,"level": 30,"invalid": false,"subType": "RANKED_SOLO_5x5","championId": 29,"createDate": 1395672014277}')
@hg = HistoryGame.new(json_mockup)
end
describe "#new" do
it "should init a history game" do
@hg.should be_instance_of HistoryGame
end
it "should init with correct params" do
@hg.championId.should be_instance_of Fixnum
@hg.createDate.should be_instance_of Fixnum
@hg.fellowPlayers.should be_instance_of Array
@hg.fellowPlayers.each do |p|
p.should be_instance_of Player
end
@hg.gameId.should be_instance_of Fixnum
@hg.gameMode.should be_instance_of String
@hg.gameType.should be_instance_of String
@hg.invalid.should satisfy {|s| [true, false].include? s}
@hg.level.should be_instance_of Fixnum
@hg.mapId.should be_instance_of Fixnum
@hg.spell1.should be_instance_of Fixnum
@hg.spell2.should be_instance_of Fixnum
@hg.statistics.should be_instance_of Hash
@hg.statistics.each do |key, stat|
key.should be_instance_of String
stat.should satisfy {|s| ([true, false].include?(s) or s.is_a?(Fixnum))}
end
@hg.subType.should be_instance_of String
@hg.teamId.should be_instance_of Fixnum
end
end
end
describe Player do
before :all do
mockup_json = JSON.parse('{"championId": 79,"teamId": 100,"summonerId": 22151489}')
@player = Player.new(mockup_json)
end
describe "#new" do
it "should init a player" do
@player.should be_instance_of Player
end
it "should init with correct params" do
@player.championId.should be_instance_of Fixnum
@player.summonerId.should be_instance_of Fixnum
@player.teamId.should be_instance_of Fixnum
end
end
end
end

71
spec/runebook_spec.rb Normal file
View File

@@ -0,0 +1,71 @@
require 'spec_helper'
require 'json'
module Sightstone
describe RuneBook do
before :all do
json_mockup = JSON.parse('{"pages":[{"id": 27005798,"slots": [{"runeSlotId": 1,"rune": {"id": 5273,"description": "+0.87 magic penetration","name": "Greater Mark of Magic Penetration","tier": 3}},{"runeSlotId": 2,"rune": {"id": 5273,"description": "+0.87 magic penetration","name": "Greater Mark of Magic Penetration","tier": 3}},{"runeSlotId": 3,"rune": {"id": 5273,"description": "+0.87 magic penetration","name": "Greater Mark of Magic Penetration","tier": 3}}],"name": "fulltank ap","current": false}], "summonerId":12345}')
@book = RuneBook.new(json_mockup)
end
describe "#new" do
it "should initialize a rune book object" do
@book.should be_an_instance_of RuneBook
end
it "should initialize with correct params" do
@book.pages.should be_instance_of Array
@book.pages.each do |page|
page.should be_instance_of RunePage
end
@book.summonerId.should be_instance_of Fixnum
end
end
end
describe RunePage do
before :all do
json_mockup = JSON.parse('{"id": 27005798,"slots": [{"runeSlotId": 1,"rune": {"id": 5273,"description": "+0.87 magic penetration","name": "Greater Mark of Magic Penetration","tier": 3}},{"runeSlotId": 2,"rune": {"id": 5273,"description": "+0.87 magic penetration","name": "Greater Mark of Magic Penetration","tier": 3}},{"runeSlotId": 3,"rune": {"id": 5273,"description": "+0.87 magic penetration","name": "Greater Mark of Magic Penetration","tier": 3}}],"name": "fulltank ap","current": false}')
@page = RunePage.new(json_mockup)
end
describe "#new" do
it "should initilalize a rune page" do
@page.should be_instance_of RunePage
end
it "should initilalize with correct params" do
@page.id.should be_instance_of Fixnum
@page.name.should be_instance_of String
@page.slots.should be_instance_of Hash
@page.slots.each do |key,slot|
slot.should be_instance_of Rune
end
end
end
end
describe Rune do
before :all do
json_mockup = JSON.parse('{"id": 5273,"description": "+0.87 magic penetration","name": "Greater Mark of Magic Penetration","tier": 3}')
@rune = Rune.new(json_mockup)
end
describe "#new" do
it "should init a talent" do
@rune.should be_instance_of Rune
end
it "should init with correct params" do
@rune.description.should be_instance_of String
@rune.id.should be_instance_of Fixnum
@rune.name.should be_instance_of String
@rune.tier.should be_instance_of Fixnum
end
end
end
end