Sha256: 27e780a0e7dd23f066e9e8d0fe3bd468af50e40c711d6866bd949ba0a2b9dff3

Contents?: true

Size: 1.92 KB

Versions: 4

Compression:

Stored size: 1.92 KB

Contents

require "spec_helper"

module Eve
  describe SkillQueue do
    let(:skillQueue) { SkillQueue.new }

    before(:each) {
      skillQueue.stub(:query).and_return({characterID: "123", keyID: "123", vCode: "abc"})
    }

    describe "hours_left" do
      context "when more than one skill is qeueued" do
        it "calculates hours left by using the last queued skill" do
          VCR.use_cassette('skillqueue_many') do
            skillQueue.hours_left.should == 49
          end
        end
      end

      context "when exactly one skill is queued" do
        it "calculates hours left by using the last queued skill" do
          VCR.use_cassette('skillqueue_one') do
            skillQueue.hours_left.should == 44
          end
        end
      end

      context "when queue is empty" do
        it "returns 0" do
          VCR.use_cassette('skillqueue_empty') do
            skillQueue.hours_left.should == 0
          end
        end
      end

      context "when queue is paused" do
        it "returns 0" do
          VCR.use_cassette('skillqueue_paused') do
            skillQueue.hours_left.should == 0
          end
        end
      end

      context "when api is blocked" do
        it "returns -1h left" do
          VCR.use_cassette('skillqueue_blocked') do
            skillQueue.hours_left.should == -1 
          end
        end
      end
    end

    it "respects the cacheUntil setting" do
      SkillQueue.should_receive(:get).once.and_call_original

      VCR.use_cassette('skillqueue_one') do
        2.times { skillQueue.hours_left }
      end
    end

    it "fetches new data when the cache expires" do
      SkillQueue.should_receive(:get).twice.and_call_original
      
      VCR.use_cassette('skillqueue_one') do
        skillQueue.hours_left
      end

      skillQueue.instance_variable_set("@expire_time", (Time.now - 1))

      VCR.use_cassette('skillqueue_empty') do
        skillQueue.hours_left
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
blinkenstein-0.2.4 spec/eve/skill_queue_spec.rb
blinkenstein-0.2.3 spec/eve/skill_queue_spec.rb
blinkenstein-0.2.2 spec/eve/skill_queue_spec.rb
blinkenstein-0.2.1 spec/eve/skill_queue_spec.rb