add spec tests for sightstone and champion object
This commit is contained in:
10
Gemfile.lock
10
Gemfile.lock
@@ -7,14 +7,24 @@ PATH
|
|||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
diff-lcs (1.2.5)
|
||||||
mime-types (2.2)
|
mime-types (2.2)
|
||||||
rake (10.1.1)
|
rake (10.1.1)
|
||||||
rest-client (1.6.7)
|
rest-client (1.6.7)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
|
rspec (2.14.1)
|
||||||
|
rspec-core (~> 2.14.0)
|
||||||
|
rspec-expectations (~> 2.14.0)
|
||||||
|
rspec-mocks (~> 2.14.0)
|
||||||
|
rspec-core (2.14.8)
|
||||||
|
rspec-expectations (2.14.5)
|
||||||
|
diff-lcs (>= 1.1.3, < 2.0)
|
||||||
|
rspec-mocks (2.14.6)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
x64-mingw32
|
x64-mingw32
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
rake
|
rake
|
||||||
|
rspec
|
||||||
sightstone!
|
sightstone!
|
||||||
|
|||||||
9
Rakefile
9
Rakefile
@@ -1,9 +1,6 @@
|
|||||||
require 'rake/testtask'
|
require 'rspec/core/rake_task'
|
||||||
|
|
||||||
Rake::TestTask.new do |t|
|
RSpec::Core::RakeTask.new('spec')
|
||||||
t.libs << 'test'
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
task :default => :spec
|
||||||
task :default #=> :test
|
|
||||||
@@ -15,17 +15,10 @@ class Champion
|
|||||||
attr_accessor :active, :attackRank, :botEnabled, :botMmEnabled
|
attr_accessor :active, :attackRank, :botEnabled, :botMmEnabled
|
||||||
attr_accessor :defenseRank, :difficultyRank, :freeToPlay, :id, :magicRank, :name, :rankedPlayEnabled
|
attr_accessor :defenseRank, :difficultyRank, :freeToPlay, :id, :magicRank, :name, :rankedPlayEnabled
|
||||||
|
|
||||||
def initialize(data)
|
def initialize args
|
||||||
@active = data['active']
|
args.each do |k,v|
|
||||||
@attackRank = data['attackRank']
|
instance_variable_set("@#{k}", v) unless v.nil?
|
||||||
@botEnabled = data['botEnabled']
|
end
|
||||||
@defenseRank = data['defenseRank']
|
|
||||||
@difficultyRank = data['difficultyRank']
|
|
||||||
@freeToPlay = data['freeToPlay']
|
|
||||||
@id = data['id']
|
|
||||||
@magicRank = data['magicRank']
|
|
||||||
@name = data['name']
|
|
||||||
@rankedPlayEnabled = data['rankedPlayEnabled']
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,4 +12,5 @@ Gem::Specification.new do |s|
|
|||||||
|
|
||||||
s.add_runtime_dependency 'rest-client'
|
s.add_runtime_dependency 'rest-client'
|
||||||
s.add_development_dependency 'rake'
|
s.add_development_dependency 'rake'
|
||||||
|
s.add_development_dependency "rspec"
|
||||||
end
|
end
|
||||||
|
|||||||
13
spec/champion_spec.rb
Normal file
13
spec/champion_spec.rb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
module Sightstone
|
||||||
|
describe Champion do
|
||||||
|
describe "#new" do
|
||||||
|
it "should initialize a champion object" do
|
||||||
|
c = Champion.new({active: true, attackRank: 1, botEnabled: true, botMmEnabled: true, defenseRank: 1,
|
||||||
|
freeToPlay: false, id: 1, magicRank: 1, name: "testName", rankedPlayEnabled: true})
|
||||||
|
c.should be_an_instance_of Champion
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
39
spec/sightstone_spec.rb
Normal file
39
spec/sightstone_spec.rb
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
module Sightstone
|
||||||
|
describe Sightstone do
|
||||||
|
|
||||||
|
before :each do
|
||||||
|
@sightstone = Sightstone.new("key", "region")
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#new" do
|
||||||
|
|
||||||
|
it "should initialize a sightstone object" do
|
||||||
|
@sightstone.should be_an_instance_of Sightstone
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should initialize with the correct params" do
|
||||||
|
@sightstone.api_key.should eql "key"
|
||||||
|
@sightstone.region.should eql "region"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should initialize all modules" do
|
||||||
|
@sightstone.summoner.should be_an_instance_of SummonerModule
|
||||||
|
@sightstone.champion.should be_an_instance_of ChampionModule
|
||||||
|
@sightstone.game.should be_an_instance_of GameModule
|
||||||
|
@sightstone.league.should be_an_instance_of LeagueModule
|
||||||
|
@sightstone.stats.should be_an_instance_of StatsModule
|
||||||
|
@sightstone.ddragon.should be_an_instance_of DatadragonModule
|
||||||
|
@sightstone.team.should be_an_instance_of TeamModule
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should initialize with a default region" do
|
||||||
|
s = Sightstone.new "my key"
|
||||||
|
s.region.should eql "euw"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
7
spec/spec_helper.rb
Normal file
7
spec/spec_helper.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
require 'rspec'
|
||||||
|
require 'sightstone'
|
||||||
|
|
||||||
|
RSpec.configure do |config|
|
||||||
|
config.color_enabled = true
|
||||||
|
config.formatter = 'documentation'
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user