Sha256: a25759314a71dce9ba600c03be1dff5d8dc724fbed77e95d5d5790cac007191e

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

require 'spec_helper'

describe Bnet::WOW::Character do
  describe ".from_api" do
    let(:attrs) {
      {
        "name" => 'Alexeistukov',
        "realm" => 'Dalvengyr',
        "battlegroup" => 'somebg',
        "class" => 3,
        "race" => 9,
        "gender" => 1,
        "level" => 85,
        "achievement_points" => 1000,
        "calc_class" => "b'",
        "total_honorable_kills" => 100
      }
    }
    subject{ described_class.from_api(attrs)}

    it "initializes and instance when passed with bnet json args" do
      expect(subject).to be_a_kind_of(described_class)
      expect(subject.name).to eq("Alexeistukov")
      expect(subject.level).to eq(85)
      expect(subject.realm).to eq('Dalvengyr')
      expect(subject.gender).to eq('Male')
      #TODO assigns :gender, :class, :race
    end
  end

  describe ".find" do
    subject { described_class.find(attrs) }
    context "Specified character exists for the server", vcr: {cassette_name: 'wow_character_found'} do
      let(:attrs){
        {
          region: 'us', name: 'AlexeiStukov', realm: 'Dragonmaw'
        }
      }
      it "returns the instance" do
        expect(subject).to be_a_kind_of(described_class)
        expect(subject.name).to eq("Alexeistukov")
        expect(subject.realm).to eq("Dragonmaw")
        expect(subject.region).to eq("us")
      end
    end

    context "specified character does not exist on the server", vcr: {cassette_name: 'wow_character_not_found'} do
      let(:attrs){
        {
          region: 'us', name: 'NotHereYo', realm: 'Dragonmaw'
        }
      }
      it { is_expected.to be_nil }
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bnet-0.0.10 spec/bnet/wow/character_spec.rb