Sha256: d7678580546c936b42a36ea6ff491ced86bc783385942f7f473530abb76f2dee

Contents?: true

Size: 986 Bytes

Versions: 5

Compression:

Stored size: 986 Bytes

Contents

require 'spec_helper'

describe 'Hero' do
  before do
    VCR.use_cassette('hero_profile') do
      @my_hero = Covetous::Profile::Hero.new 'corroded-6950', '12793941'
    end
  end

  after do
    VCR.eject_cassette
  end

  describe 'when given a battle tag name, id, and hero id' do
    it 'should have the correct url' do
      @my_hero.url.must_equal 'http://us.battle.net/api/d3/profile/corroded-6950/hero/12793941'
    end
  end

  describe 'when receiving the hero details' do
    it 'should have the top level keys as methods' do
      top_level_keys = %w{id name gender level paragonLevel hardcore skills items followers stats kills progress dead last-updated}

      top_level_keys.each do |tl_key|
        @my_hero.send(tl_key).must_equal @my_hero.response[tl_key.camelize(:lower)]
      end
    end

    it "should throw an error when trying to call a top level key that doesn't exist" do
      lambda { @my_hero.foo_attribute }.must_raise NoMethodError
    end
  end


end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
covetous-0.1.3 spec/covetous/profile/hero_spec.rb
covetous-0.1.2 spec/covetous/profile/hero_spec.rb
covetous-0.1.1 spec/covetous/profile/hero_spec.rb
covetous-0.1.0 spec/covetous/profile/hero_spec.rb
covetous-0.0.1 spec/covetous/profile/hero_spec.rb