sauce_whisk 0.0.20 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,43 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe SauceWhisk::Account do
4
- describe "##new" do
5
- it "sets any options passed in as a hash" do
6
- options = {
7
- :access_key => 12345,
8
- :minutes => 23,
9
- :mac_minutes => 11,
10
- :manual_minutes => 4,
11
- :mac_manual_minutes => 87,
12
- :id => "someone"
13
- }
14
-
15
- test_account = SauceWhisk::Account.new options
16
- expect( test_account.access_key ).to eq 12345
17
- expect( test_account.minutes ).to eq 23
18
- expect( test_account.mac_minutes ).to eq 11
19
- expect( test_account.manual_minutes ).to eq 4
20
- expect( test_account.mac_manual_minutes ).to eq 87
21
- expect( test_account.username ).to eq "someone"
22
- end
23
-
24
- it "sets concurrency figures" do
25
- concurrencies = {
26
- :mac_concurrency => 23,
27
- :total_concurrency => 100
28
- }
29
-
30
- test_account = SauceWhisk::Account.new concurrencies
31
- expect( test_account.mac_concurrency ).to eq 23
32
- expect( test_account.total_concurrency ).to eq 100
33
- end
34
- end
35
-
36
- describe "#add_subaccount", :vcr => {:cassette_name => "accounts"} do
37
- let(:parent) {SauceWhisk::Account.new(:access_key => 12345, :minutes => 23, :id => ENV["SAUCE_USERNAME"])}
38
-
39
- it "creates a subaccount" do
40
- subaccount = parent.add_subaccount("Manny", "newsub77", "Manny@blackbooks.co.uk", "davesdisease")
41
- end
42
- end
43
- end
@@ -1,136 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe SauceWhisk::Accounts, :vcr => {:cassette_name => "accounts", :match_requests_on => [:uri, :body]} do
4
- let(:auth) {"#{ENV["SAUCE_USERNAME"]}:#{ENV["SAUCE_ACCESS_KEY"]}"}
5
-
6
- describe "#fetch" do
7
- it "fetches the passed in account" do
8
- SauceWhisk::Accounts.fetch ENV["SAUCE_USERNAME"]
9
- assert_requested :get, "https://#{auth}@saucelabs.com/rest/v1/users/#{ENV["SAUCE_USERNAME"]}"
10
- end
11
-
12
- it "returns an Account object" do
13
- username = ENV["SAUCE_USERNAME"]
14
- account = SauceWhisk::Accounts.fetch(username)
15
- expect( account ).to be_an_instance_of SauceWhisk::Account
16
-
17
- expect( account.username) .to eq username
18
- expect( account.access_key ).to_not be_nil
19
- end
20
-
21
- it "includes the concurrency by default" do
22
- account = SauceWhisk::Accounts.fetch ENV["SAUCE_USERNAME"]
23
- assert_requested :get, "https://#{auth}@saucelabs.com/rest/v1/#{ENV["SAUCE_USERNAME"]}/limits"
24
- expect( account.total_concurrency ).to eq 20
25
- expect( account.mac_concurrency ).to eq 5
26
- end
27
-
28
- it "should not include concurrency when conservative is set to false" do
29
- account = SauceWhisk::Accounts.fetch(ENV["SAUCE_USERNAME"], false)
30
- assert_not_requested :get, "https://#{auth}@saucelabs.com/rest/v1/#{ENV["SAUCE_USERNAME"]}/limits"
31
- expect( account.total_concurrency ).to be_nil
32
- end
33
-
34
- context "with an invalid account" do
35
- it "Raises an InvalidAccountError" do
36
- expect{
37
- SauceWhisk::Accounts.fetch "IDontExist"
38
- }.to raise_error SauceWhisk::InvalidAccountError
39
- end
40
- end
41
- end
42
-
43
- describe "#concurrency_for" do
44
- it "fetches the concurrency for the passed in account" do
45
- SauceWhisk::Accounts.concurrency_for ENV["SAUCE_USERNAME"]
46
- assert_requested :get, "https://#{auth}@saucelabs.com/rest/v1/#{ENV["SAUCE_USERNAME"]}/limits"
47
- end
48
-
49
- it "returns concurrencies with altered names" do
50
- expected_hash = {:mac_concurrency => 5, :total_concurrency => 20}
51
- SauceWhisk::Accounts.concurrency_for(ENV["SAUCE_USERNAME"]).should eq expected_hash
52
- end
53
-
54
- it "returns just mac as an integer when requested" do
55
- SauceWhisk::Accounts.concurrency_for(ENV["SAUCE_USERNAME"], :mac).should eq 5
56
- end
57
-
58
- it "returns just the total as an integer when requested" do
59
- SauceWhisk::Accounts.concurrency_for(ENV["SAUCE_USERNAME"], :total).should eq 20
60
- end
61
- end
62
-
63
- describe "#create_subaccount" do
64
- let(:params) {{
65
- :username => "newsub77",
66
- :password => "davesdisease",
67
- :name => "Manny",
68
- :email => "Manny@blackbooks.co.uk"
69
- }}
70
-
71
- let(:parent) {SauceWhisk::Account.new(:access_key => 12345, :minutes => 23, :id => ENV["SAUCE_USERNAME"])}
72
-
73
- it "calls the correct url" do
74
- SauceWhisk::Accounts.create_subaccount(parent,
75
- "Manny", "newsub77", "Manny@blackbooks.co.uk", "davesdisease")
76
-
77
- assert_requested(:post,
78
- "https://#{auth}@saucelabs.com/rest/v1/users/#{ENV["SAUCE_USERNAME"]}",
79
- :body => params.to_json
80
- )
81
- end
82
-
83
- it "returns a Subaccount object" do
84
- sub = SauceWhisk::Accounts.create_subaccount(parent, "Manny", "newsub77",
85
- "Manny@blackbooks.co.uk", "davesdisease")
86
-
87
- expect( sub ).to be_a_kind_of SauceWhisk::Account
88
- end
89
-
90
- it "returns a Subaccount, parented to the Parent account" do
91
- parent = SauceWhisk::Accounts.fetch ENV["SAUCE_USERNAME"]
92
-
93
- sub = SauceWhisk::Accounts.create_subaccount(parent, "Manny", "newsub77",
94
- "Manny@blackbooks.co.uk", "davesdisease")
95
-
96
- expect( sub.parent ).to be parent
97
- end
98
-
99
- context "trying to create too many subaccounts" do
100
- it "should throw SubaccountCreationError" do
101
- expect{
102
- SauceWhisk::Accounts.create_subaccount(parent, "Manny", "toomany",
103
- "Manny@blackbooks.co.uk", "davesdisease")
104
- }.to raise_error SauceWhisk::SubAccountCreationError
105
- end
106
- end
107
-
108
- context "trying to create a subaccount which already exists" do
109
- it "should throw SubaccountCreationError" do
110
- expect{
111
- SauceWhisk::Accounts.create_subaccount(parent, "Manny", "duplicate",
112
- "Manny@blackbooks.co.uk", "davesdisease")
113
- }.to raise_error SauceWhisk::SubAccountCreationError
114
- end
115
- end
116
-
117
- context "trying to create a subaccount which causes the tree to be too deep" do
118
- it "should throw SubaccountCreationError" do
119
- expect{
120
- SauceWhisk::Accounts.create_subaccount(parent, "Manny", "deeptree",
121
- "Manny@blackbooks.co.uk", "davesdisease")
122
- }.to raise_error SauceWhisk::SubAccountCreationError
123
- end
124
- end
125
-
126
- context "with a non-existant parent" do
127
- let(:parent) {SauceWhisk::Account.new(:access_key => 12345, :minutes => 23, :id =>"nopenotaperson")}
128
- it "should throw SubaccountCreationError" do
129
- expect{
130
- SauceWhisk::Accounts.create_subaccount(parent, "Manny", "deeptree",
131
- "Manny@blackbooks.co.uk", "davesdisease")
132
- }.to raise_error SauceWhisk::InvalidAccountError
133
- end
134
- end
135
- end
136
- end
@@ -1,39 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe SauceWhisk::Asset do
4
-
5
- describe "#initialize" do
6
- let(:data) {"DEDEDEDEDED"}
7
- let(:name) {"video01.mpg"}
8
- let(:job_id) {"c4revevegegerg"}
9
- let(:type) {:video}
10
-
11
- before :each do
12
- params = {:data => data, :name => name, :type => type, :job_id => job_id}
13
-
14
- @asset = SauceWhisk::Asset.new params
15
- end
16
-
17
- it "should store the name" do
18
- expect( @asset.name ).to eq name
19
- end
20
-
21
- it "should store the data" do
22
- expect( @asset.data ).to eq data
23
- end
24
-
25
- it "should store the type" do
26
- expect( @asset.asset_type ).to eq type
27
- end
28
-
29
- it "should store the job_id" do
30
- expect( @asset.job ).to eq job_id
31
- end
32
- end
33
-
34
- describe "#type" do
35
- it "should default to screenshot" do
36
- expect( SauceWhisk::Asset.new.asset_type ).to eq :screenshot
37
- end
38
- end
39
- end
@@ -1,61 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe SauceWhisk::Assets do
4
- let(:auth) {"#{ENV["SAUCE_USERNAME"]}:#{ENV["SAUCE_ACCESS_KEY"]}"}
5
- let(:user) {ENV["SAUCE_USERNAME"]}
6
-
7
- describe "#fetch", :vcr => {:cassette_name => "assets"} do
8
- let(:job_id) {"bd9c43dd6b5549f1b942d1d581d98cac"}
9
- let(:asset_name) {"0000screenshot.png"}
10
-
11
- it "fetches an asset for the requested job" do
12
- SauceWhisk::Assets.fetch job_id, asset_name
13
-
14
- assert_requested :get, "https://#{auth}@saucelabs.com/rest/v1/#{user}/jobs/#{job_id}/assets/#{asset_name}"
15
- end
16
-
17
- it "returns an asset" do
18
- SauceWhisk::Assets.fetch(job_id, asset_name).should be_an_instance_of SauceWhisk::Asset
19
- end
20
-
21
- it "initializes the asset properly" do
22
- asset = SauceWhisk::Assets.fetch job_id, asset_name
23
- expect( asset.name ).to eq asset_name
24
- expect( asset.job ).to eq job_id
25
- expect( asset.asset_type ).to eq :screenshot
26
- end
27
-
28
- context "for an invalid asset" do
29
- let(:invalid_job_id) {"aaaaaaaaaaaaaaaa"}
30
-
31
- it "returns a RestClient::ResourceNotFound Exception" do
32
- expect {
33
- SauceWhisk::Assets.fetch invalid_job_id, asset_name
34
- }.to raise_error RestClient::ResourceNotFound
35
- end
36
- end
37
-
38
- context "for an asset that's not available immediately" do
39
- let(:slow_job_id) {"n0th3r3y3t"}
40
-
41
- it "returns the asset" do
42
- SauceWhisk::Assets.fetch(slow_job_id, asset_name).should be_an_instance_of SauceWhisk::Asset
43
- end
44
- end
45
- end
46
-
47
- describe "#delete", :vcr => {:cassette_name => "assets"} do
48
- let(:asset_job_id) {"f7bcec8f706f4910ba128f48e0b8c6c7"}
49
- it "can delete a job" do
50
- SauceWhisk::Assets.delete(asset_job_id).should be_an_instance_of SauceWhisk::Asset
51
- end
52
- end
53
-
54
- describe "#already_deleted_asset", :vcr => {:cassette_name => "assets"} do
55
- let(:asset_job_id) {"651c7d737b7547e994678d981dcc433c"}
56
- it "returns nil for already deleted assets" do
57
- SauceWhisk::Assets.delete(asset_job_id).should be_an_instance_of SauceWhisk::Asset
58
- end
59
- end
60
-
61
- end
@@ -1,66 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "SauceWhisk::Sauce", :vcr => {:cassette_name => "info"} do
4
- describe "#service_status"do
5
- it "calls the correct URI" do
6
- SauceWhisk::Sauce.service_status
7
- assert_requested :get, "https://saucelabs.com/rest/v1/info/status"
8
- end
9
-
10
- it "returns a hash" do
11
- expect( SauceWhisk::Sauce.service_status ).to be_a_kind_of Hash
12
- end
13
-
14
- it "symbolizes the keys" do
15
- SauceWhisk::Sauce.service_status.each do |k,v|
16
- expect( k ).to be_an_instance_of Symbol
17
- end
18
- end
19
- end
20
-
21
- describe "#test_count" do
22
- it "calls the correct URI" do
23
- SauceWhisk::Sauce.total_job_count
24
- assert_requested :get, "https://saucelabs.com/rest/v1/info/counter"
25
- end
26
-
27
- it "returns an integer" do
28
- expect( SauceWhisk::Sauce.total_job_count ).to be_a_kind_of Integer
29
- end
30
- end
31
-
32
- describe "#platforms" do
33
- it "calls the correct URI" do
34
- SauceWhisk::Sauce.platforms
35
- assert_requested :get, "https://saucelabs.com/rest/v1/info/browsers/webdriver"
36
- end
37
-
38
- it "only calls the api once" do
39
- SauceWhisk::Sauce.instance_variable_set(:@platforms, nil)
40
- SauceWhisk::Sauce.platforms
41
- SauceWhisk::Sauce.platforms
42
- assert_requested :get, "https://saucelabs.com/rest/v1/info/browsers/webdriver"
43
- end
44
-
45
- it "returns an array" do
46
- platforms = SauceWhisk::Sauce.platforms
47
- expect( platforms ).to be_a_kind_of Array
48
- end
49
-
50
- context "when called with true" do
51
- it "calls the API each time" do
52
- SauceWhisk::Sauce.instance_variable_set(:@platforms, nil)
53
- SauceWhisk::Sauce.platforms
54
- SauceWhisk::Sauce.platforms(true)
55
-
56
- assert_requested :get, "https://saucelabs.com/rest/v1/info/browsers/webdriver", :times => 2
57
- end
58
- end
59
- end
60
-
61
- describe "operational?" do
62
- it "returns true when the service is running" do
63
- expect( SauceWhisk::Sauce.operational? ).to be true
64
- end
65
- end
66
- end
@@ -1,137 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe SauceWhisk::Job do
4
- let(:job) {SauceWhisk::Job.new}
5
- let(:user) {ENV["SAUCE_USERNAME"]}
6
- subject {SauceWhisk::Job.new}
7
-
8
- it {should respond_to :id}
9
-
10
- context "Initialized" do
11
- let(:params) {{
12
- "id" => "dsfargeg",
13
- "owner" => "Dave",
14
- "status" => "Things",
15
- "error" => nil,
16
- "name" => "Test All The RESTS",
17
- "browser" => "firefox",
18
- "browser_version" => "18",
19
- "os" => "Windows 2008",
20
- "creation_time" => Time.now.to_i,
21
- "start_time" => Time.now + 4,
22
- "end_time" => Time.now + 118,
23
- "video_url" => "http://www.notarealplace.com/somewhere/resource",
24
- "log_url" => "http://www.underthesea.com/notreally/404",
25
- "public" => false,
26
- "tags" => ["ruby", "awesome", "restful"],
27
- "custom_data" => ""
28
- }}
29
-
30
- subject {SauceWhisk::Job.new(params)}
31
-
32
- it "sets parameters at init" do
33
- params.each do |k,v|
34
- subject.send(k).should eq v
35
- end
36
- end
37
-
38
- it "tracks changes to methods" do
39
- subject.name = "ANewName"
40
- expect( subject.updated_fields ).to include :name
41
-
42
- subject.visibility = true
43
- expect( subject.updated_fields ).to include :visibility
44
- end
45
-
46
- it "does not track unchanged methods" do
47
- expect( subject.updated_fields ).to_not include :build
48
- end
49
-
50
- it "has empty updated_fields for new instances" do
51
- new_job = SauceWhisk::Job.new(params)
52
- expect( new_job.updated_fields ).to eq []
53
- end
54
-
55
- describe "#save" do
56
- subject {SauceWhisk::Job.new(params)}
57
-
58
- context "with changed values" do
59
- before(:each) do
60
- subject.name = "New_Name"
61
- end
62
-
63
- it "calls the save method of the SauceWhisk::Jobs object" do
64
- expect( SauceWhisk::Jobs ).to receive(:save).with(subject)
65
- subject.save
66
- end
67
- end
68
- end
69
-
70
- describe "#stop" do
71
- subject {SauceWhisk::Job.new(params.merge({"id" => "3edc8fe6d52645bf931b1003da65af1f"}))}
72
-
73
- it "Calls the correct REST API method", :vcr => {:cassette_name => "jobs"} do
74
- subject.stop
75
- assert_requested :put, "https://#{user}:#{ENV["SAUCE_ACCESS_KEY"]}@saucelabs.com/rest/v1/#{user}/jobs/#{subject.id}/stop"
76
- end
77
- end
78
-
79
- describe "parameters" do
80
- it "lets you set only the parameters which are mutable" do
81
- [:name, :build, :passed, :tags, :custom_data, :visibility].each do |param|
82
- changed_value = "Changed#{param}"
83
- subject.send("#{param}=", changed_value)
84
- subject.send(param).should eq changed_value
85
- end
86
- end
87
-
88
- it "throws an exception if you try to set one of the fixed attributes" do
89
- [:id, :owner, :browser, :browser_version, :os, :error, :creation_time,
90
- :start_time, :end_time, :video_url, :log_url
91
- ].each do |param|
92
- expect {
93
- subject.send("#{param}=", "TOTALLYDIFFERENT")
94
- }.to raise_exception
95
-
96
- expect( subject.send(param) ).not_to eq "TOTALLYDIFFERENT"
97
- end
98
- end
99
- end
100
- end
101
-
102
- context "fetched from the API", :vcr => {:cassette_name => "assets"} do
103
- context "with all asset details" do
104
- subject {SauceWhisk::Jobs.fetch "bd9c43dd6b5549f1b942d1d581d98cac"}
105
-
106
- it "will set has_all_asset_names true" do
107
- expect( subject.has_all_asset_names? ).to be true
108
- end
109
-
110
- describe "#screenshots" do
111
- it "contains all the screenshots for that job" do
112
- expect( subject.screenshots.length ).to be 4
113
- end
114
-
115
- it "contains actual screenshots" do
116
- expect( subject.screenshots.first ).to be_a_kind_of SauceWhisk::Asset
117
- expect( subject.screenshots.first.asset_type ).to eq :screenshot
118
- end
119
- end
120
-
121
- describe "#video", :vcr => {:cassette_name => "assets"} do
122
- it "should be a video asset" do
123
- expect( subject.video ).to be_a_kind_of SauceWhisk::Asset
124
- expect( subject.video.asset_type ).to eq :video
125
- end
126
- end
127
- end
128
-
129
- context "without asset details" do
130
- subject {SauceWhisk::Jobs.fetch "1ca64b180cfa40e0a4aee5a4a482f271" }
131
-
132
- it "will set has_all_asset_names false" do
133
- expect( subject.has_all_asset_names? ).to be false
134
- end
135
- end
136
- end
137
- end