Sha256: 708e087d7ac21c766a0a8f9b5819f88843dbb1ad40df883c84a80898b892cc67

Contents?: true

Size: 1.89 KB

Versions: 7

Compression:

Stored size: 1.89 KB

Contents

require "spec_helper"

describe "SauceWhisk::Sauce", :vcr => {:cassette_name => "info"}  do
  describe "#service_status"do
    it "calls the correct URI" do
      SauceWhisk::Sauce.service_status
      assert_requested :get, "https://saucelabs.com/rest/v1/info/status"
    end

    it "returns a hash" do
      expect( SauceWhisk::Sauce.service_status ).to be_a_kind_of Hash
    end

    it "symbolizes the keys" do
      SauceWhisk::Sauce.service_status.each do |k,v|
        expect( k ).to be_an_instance_of Symbol
      end
    end
  end

  describe "#test_count" do
    it "calls the correct URI" do
      SauceWhisk::Sauce.total_job_count
      assert_requested :get, "https://saucelabs.com/rest/v1/info/counter"
    end

    it "returns an integer" do
      expect( SauceWhisk::Sauce.total_job_count ).to be_a_kind_of Integer
    end
  end

  describe "#platforms" do
    it "calls the correct URI" do
      SauceWhisk::Sauce.platforms
      assert_requested :get, "https://saucelabs.com/rest/v1/info/browsers/webdriver"
    end

    it "only calls the api once" do
      SauceWhisk::Sauce.instance_variable_set(:@platforms, nil)
      SauceWhisk::Sauce.platforms
      SauceWhisk::Sauce.platforms
      assert_requested :get, "https://saucelabs.com/rest/v1/info/browsers/webdriver"
    end

    it "returns an array" do
      platforms = SauceWhisk::Sauce.platforms
      expect( platforms ).to be_a_kind_of Array
    end

    context "when called with true" do
      it "calls the API each time" do
        SauceWhisk::Sauce.instance_variable_set(:@platforms, nil)
        SauceWhisk::Sauce.platforms
        SauceWhisk::Sauce.platforms(true)

        assert_requested :get, "https://saucelabs.com/rest/v1/info/browsers/webdriver", :times => 2
      end
    end
  end

  describe "operational?" do
    it "returns true when the service is running" do
      expect( SauceWhisk::Sauce.operational? ).to be true
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sauce_whisk-0.0.20 spec/lib/sauce_whisk/info_spec.rb
sauce_whisk-0.0.19 spec/lib/sauce_whisk/info_spec.rb
sauce_whisk-0.0.18 spec/lib/sauce_whisk/info_spec.rb
sauce_whisk-0.0.17 spec/lib/sauce_whisk/info_spec.rb
sauce_whisk-0.0.16 spec/lib/sauce_whisk/info_spec.rb
sauce_whisk-0.0.15 spec/lib/sauce_whisk/info_spec.rb
sauce_whisk-0.0.14 spec/lib/sauce_whisk/info_spec.rb