Sha256: 5347e7fb13432918042b555cb402b98ac613aa9a6076e6d06091ca7185df4987

Contents?: true

Size: 1.75 KB

Versions: 6

Compression:

Stored size: 1.75 KB

Contents

require 'spec_helper'

describe Bnet::Diablo3::Career do

  describe ".from_api" do
    let(:attrs){
      {
        "heroes" => [], "lastheroplayed" => 'val', "lastupdated" => 'val',
        "kills" => 'val', "timeplayed" => 'val', "fallenheroes" => 'val',
        "paragonlevel" => 'val', "paragonlevelhardcore" => 'val',
        "battletag" => 'val', "progression" => 'val'
      }
    }
    subject{ described_class.from_api(attrs)}
    it "is initialized" do
      expect(subject).to be_a_kind_of(described_class)
    end
  end

  describe ".find(battle_tag: 'PlayerOne#1309', region: 'us')" do
    subject(:career) { described_class.find(args) }

    context "Playertag for the server exists" ,vcr: { cassette_name: 'find_diablo_career_player_one '} do
      let(:args) do
        { battle_tag: 'PlayerOne#1309', region: 'us' }
      end
      it { is_expected.to_not be_nil }

      it "sets account attributes that are of the json response" do
        expect(career.battle_tag).to eq('PlayerOne#1309')
        expect(career.region).to eq('us')
      end

      it "assigns autoloads the heroes" do
        expect(career.heroes).to_not be_empty

        career.heroes.each do |hero|
          expect(hero).to be_a_kind_of(Bnet::Diablo3::Hero)
          expect(hero.battle_tag).to eq('PlayerOne#1309')
          expect(hero.region).to eq(career.region)
          expect(hero.career).to be(career)
          expect(hero.passive_skills).to_not be_empty
          expect(hero.active_skills).to_not be_empty
        end

      end
    end

    context "Playertag for the server does not exist", vcr: { cassette_name: 'find_diablo_career_doesnt_exist'} do
      let(:args) do
        { battle_tag: 'DoesntExist-42', region: 'us' }
      end
      it { is_expected.to be_nil }
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bnet-0.0.10 spec/bnet/diablo3/career_spec.rb
bnet-0.0.5 spec/bnet/diablo3/career_spec.rb
bnet-0.0.4 spec/bnet/diablo3/career_spec.rb
bnet-0.0.3 spec/bnet/diablo3/career_spec.rb
bnet-0.0.2 spec/bnet/diablo3/career_spec.rb
bnet-0.0.1 spec/bnet/diablo3/career_spec.rb