sauce_whisk 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +64 -5
- data/lib/sauce_whisk/assets.rb +19 -17
- data/lib/sauce_whisk/jobs.rb +80 -78
- data/lib/sauce_whisk/rest_request_builder.rb +26 -24
- data/lib/sauce_whisk/version.rb +1 -1
- data/spec/lib/sauce_whisk/asset_spec.rb +3 -3
- data/spec/lib/sauce_whisk/assets_spec.rb +4 -4
- data/spec/lib/sauce_whisk/job_spec.rb +11 -11
- data/spec/lib/sauce_whisk/jobs_spec.rb +16 -16
- data/spec/lib/sauce_whisk/rest_request_builder_spec.rb +2 -2
- data/spec/lib/sauce_whisk/sauce_whisk_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmIzOTdjOTU0M2IyNDIyOWE4YWRiZGIyYjdlNjY1ZTA5OTFjMWIxOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YThkYzRhMTNiNTk5MTYwYTlmZTc0MzBlOTliMTQzMmJjNTk0ODgwNA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2MwNWVkNTk0YzI0N2NmMmUxZGZmOTJjMDFjNmY2NmE0OTc1OWFjNjgyMDc5
|
10
|
+
ZWI3ZDE2ZTNiMzdhYTNkMmYzMWFjMTE4YzdlNjZhOWFhMzZhN2NlZTdkMzk0
|
11
|
+
MTViZjZiMWM3MDkyMDViMWEzZWYxOTBlM2YwZThlZDNhMzZiMDY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmEwZjAzMDc2MDk1NTNjYTVkNDFjYmQ1NzE1Mzg0YjE5ZDVhODNiYWU1NmI2
|
14
|
+
NGJhZmY3MTFkN2M1ZjQ0NjhhYTg0YjQyOThhM2U3ZmI2ZTUwOGY5NzVmOWNm
|
15
|
+
ZmJkOTQwZGE4ZjE0NTgwYzI0NjNmMDExZTZjOGE2ZWIwMWQ3ZTQ=
|
data/README.md
CHANGED
@@ -18,15 +18,74 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install sauce_whisk
|
20
20
|
|
21
|
+
## Configuration
|
22
|
+
|
23
|
+
You'll need a [Sauce Labs account](http://wwww.saucelabs.com/signup). They're free to try and, if you're an open source project, [your access is always free](http://saucelabs.com/opensauce).
|
24
|
+
|
25
|
+
Once you've got your account, set the following environment variables:
|
26
|
+
|
27
|
+
```bash
|
28
|
+
SAUCE_USERNAME=Your Sauce Username
|
29
|
+
SAUCE_ACCESS_KEY=Your Access Key, found on the lower left of your Account page
|
30
|
+
```
|
31
|
+
|
21
32
|
## Usage
|
22
33
|
|
23
|
-
### Marking
|
24
|
-
|
34
|
+
### Marking jobs passed or failed
|
35
|
+
```ruby
|
25
36
|
SauceWhisk::Jobs.pass_job job_id
|
26
|
-
|
27
|
-
### Marking a Job as Failed
|
28
|
-
|
29
37
|
SauceWhisk::Jobs.fail_job job_id
|
38
|
+
```
|
39
|
+
|
40
|
+
### Creating Job Objects
|
41
|
+
|
42
|
+
There are two ways to create a Job object.
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
# Create an 'empty' job (i.e. don't retrieve job details from the API)
|
46
|
+
empty_job = Job.new job_id
|
47
|
+
|
48
|
+
# Create a job with details fetched from the API
|
49
|
+
fully_detailed_job = Jobs.fetch job_id
|
50
|
+
```
|
51
|
+
|
52
|
+
Use the first form when you just want a simple way to push details to the API. Use the last form when you want to fetch details from the API.
|
53
|
+
|
54
|
+
NB: It's not possible to create a new job on Sauce Labs' infrastructure with the API.
|
55
|
+
|
56
|
+
### Updating Job Metadata
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
job = Job.new job_id
|
60
|
+
job.build = "12.3.04-beta"
|
61
|
+
job.visibility = "public"
|
62
|
+
job.tags = "new_user"
|
63
|
+
job.name = "Determine if the User can Invite Friends"
|
64
|
+
job.custom_data = {:executor => "jparth", :team_city_config => "standard_with_instrumentation"}
|
65
|
+
job.passed = false
|
66
|
+
|
67
|
+
job.save
|
68
|
+
```
|
69
|
+
|
70
|
+
It is not possible to alter any other job properties.
|
71
|
+
|
72
|
+
### Assets
|
73
|
+
|
74
|
+
There are three types of asset for Sauce Labs jobs: screenshots, video and logs. Assets are represented as an Asset object, which include the name, asset type and data.
|
75
|
+
|
76
|
+
#### Screenshots
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
job = Job.fetch job_id
|
80
|
+
screenshots = job.screenshots # An array of Screenshot assets
|
81
|
+
```
|
82
|
+
|
83
|
+
#### Video
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
job = Job.fetch job_id
|
87
|
+
video = job.video # A single Asset, holding the video
|
88
|
+
```
|
30
89
|
|
31
90
|
## Contributing
|
32
91
|
|
data/lib/sauce_whisk/assets.rb
CHANGED
@@ -1,25 +1,27 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module SauceWhisk
|
2
|
+
class Assets
|
3
|
+
extend RestRequestBuilder
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
def self.resource
|
6
|
+
"#{SauceWhisk.username}/jobs"
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def self.fetch(job_id, asset, type=nil)
|
10
|
+
data = get "#{job_id}/assets/#{asset}"
|
11
|
+
Asset.new({:name => asset, :data => data, :job_id => job_id, :type => type})
|
12
|
+
end
|
11
13
|
end
|
12
|
-
end
|
13
14
|
|
14
|
-
class Asset
|
15
|
+
class Asset
|
15
16
|
|
16
|
-
|
17
|
+
attr_reader :asset_type, :name, :data, :job
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
def initialize(parameters={})
|
20
|
+
@asset_type = parameters[:type] || :screenshot
|
21
|
+
@name = parameters[:name]
|
22
|
+
@data = parameters[:data]
|
23
|
+
@job = parameters[:job_id]
|
24
|
+
end
|
24
25
|
|
26
|
+
end
|
25
27
|
end
|
data/lib/sauce_whisk/jobs.rb
CHANGED
@@ -2,111 +2,113 @@ require 'json'
|
|
2
2
|
|
3
3
|
require 'sauce_whisk/rest_request_builder'
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
module SauceWhisk
|
6
|
+
class Jobs
|
7
|
+
extend RestRequestBuilder
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def self.resource
|
10
|
+
"#{SauceWhisk.username}/jobs"
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
def self.all
|
14
|
+
all_jobs = JSON.parse get
|
15
|
+
all_jobs.map {|job| Job.new(job)}
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def self.change_status(job_id, status)
|
19
|
+
put job_id, {"passed" => status}.to_json
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
def self.pass_job(job_id)
|
23
|
+
change_status(job_id, true)
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
def self.fail_job(job_id)
|
27
|
+
change_status(job_id, false)
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
def self.save(job)
|
31
|
+
fields_to_save = job.updated_fields.each_with_object(Hash.new) do |field, hsh|
|
32
|
+
hsh[field] = job.send(field.to_s)
|
33
|
+
end
|
34
|
+
put job.id, fields_to_save.to_json
|
32
35
|
end
|
33
|
-
put job.id, fields_to_save.to_json
|
34
|
-
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
def self.fetch(job_id)
|
38
|
+
job_hash = JSON.parse(get job_id)
|
39
|
+
assets = JSON.parse get "#{job_id}/assets"
|
40
|
+
screenshots = assets["screenshots"]
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
job_hash.merge!({"screenshot_urls" => screenshots})
|
43
|
+
Job.new(job_hash)
|
44
|
+
end
|
44
45
|
|
45
|
-
|
46
|
-
|
46
|
+
def self.fetch_asset(job_id, asset)
|
47
|
+
asset = get "#{job_id}/assets/#{asset}"
|
48
|
+
end
|
47
49
|
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
50
|
+
|
51
|
+
class Job
|
52
|
+
attr_writer :updated_fields
|
53
|
+
|
54
|
+
def self.tracked_attr_accessor(*methods)
|
55
|
+
methods.each do |method|
|
56
|
+
attr_reader method
|
57
|
+
self.send(:define_method, "#{method}=") do |arg|
|
58
|
+
if method != arg
|
59
|
+
updated_fields << method
|
60
|
+
instance_variable_set("@#{method}", arg)
|
61
|
+
end
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
63
|
-
end
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
attr_reader :id, :owner, :browser, :browser_version, :os, :log_url
|
67
|
+
attr_reader :error, :creation_time, :start_time, :end_time, :video_url
|
68
|
+
attr_reader :screenshot_urls
|
68
69
|
|
69
|
-
|
70
|
+
tracked_attr_accessor :custom_data, :tags, :name, :visibility, :build, :passed
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
def initialize(parameters={})
|
73
|
+
passed = parameters.delete "status"
|
74
|
+
cd = parameters.delete "custom-data"
|
75
|
+
visibility = parameters.delete "public"
|
75
76
|
|
76
|
-
|
77
|
-
|
78
|
-
|
77
|
+
self.passed = passed
|
78
|
+
self.custom_data = cd
|
79
|
+
self.visibility = visibility
|
79
80
|
|
80
|
-
|
81
|
-
|
82
|
-
|
81
|
+
parameters.each do |k,v|
|
82
|
+
self.instance_variable_set("@#{k}".to_sym, v)
|
83
|
+
end
|
83
84
|
|
84
|
-
|
85
|
-
|
85
|
+
@updated_fields = []
|
86
|
+
end
|
86
87
|
|
87
|
-
|
88
|
-
|
89
|
-
|
88
|
+
def save
|
89
|
+
Jobs.save(self)
|
90
|
+
end
|
90
91
|
|
91
|
-
|
92
|
-
|
93
|
-
|
92
|
+
def updated_fields
|
93
|
+
@updated_fields ||= []
|
94
|
+
end
|
94
95
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
def screenshots
|
97
|
+
unless @screenshots
|
98
|
+
@screenshots = screenshot_urls.map do |screenshot|
|
99
|
+
Assets.fetch id, screenshot
|
100
|
+
end
|
99
101
|
end
|
102
|
+
|
103
|
+
@screenshots
|
100
104
|
end
|
101
105
|
|
102
|
-
|
103
|
-
|
106
|
+
def video
|
107
|
+
unless @video
|
108
|
+
@video = Assets.fetch id, "video.flv", :video
|
109
|
+
end
|
104
110
|
|
105
|
-
|
106
|
-
unless @video
|
107
|
-
@video = Assets.fetch id, "video.flv", :video
|
111
|
+
@video
|
108
112
|
end
|
109
|
-
|
110
|
-
@video
|
111
113
|
end
|
112
114
|
end
|
@@ -1,29 +1,31 @@
|
|
1
|
-
module
|
1
|
+
module SauceWhisk
|
2
|
+
module RestRequestBuilder
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
def get(resource_to_fetch=nil)
|
5
|
+
resource_url = fully_qualified_resource
|
6
|
+
resource_url << "/#{resource_to_fetch}" if resource_to_fetch
|
7
|
+
RestClient::Request.execute({:method => :get, :url => resource_url}.merge auth_details)
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
def put(resource_id, body)
|
11
|
+
url = "#{fully_qualified_resource}/#{resource_id}"
|
12
|
+
length = body.length
|
13
|
+
headers = {"Content-Length" => length}
|
14
|
+
req_params = {
|
15
|
+
:method => :put,
|
16
|
+
:url => url,
|
17
|
+
:payload => body,
|
18
|
+
:content_type => "application/json"
|
19
|
+
}
|
20
|
+
RestClient::Request.execute(req_params.merge auth_details)
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
def auth_details
|
24
|
+
{:user => SauceWhisk.username, :password => SauceWhisk.password}
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
def fully_qualified_resource
|
28
|
+
"#{SauceWhisk.base_url}/#{resource}"
|
29
|
+
end
|
28
30
|
end
|
29
|
-
end
|
31
|
+
end
|
data/lib/sauce_whisk/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Asset do
|
3
|
+
describe SauceWhisk::Asset do
|
4
4
|
|
5
5
|
describe "#initialize" do
|
6
6
|
let(:data) {"DEDEDEDEDED"}
|
@@ -11,7 +11,7 @@ describe Asset do
|
|
11
11
|
before :each do
|
12
12
|
params = {:data => data, :name => name, :type => type, :job_id => job_id}
|
13
13
|
|
14
|
-
@asset = Asset.new params
|
14
|
+
@asset = SauceWhisk::Asset.new params
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should store the name" do
|
@@ -33,7 +33,7 @@ describe Asset do
|
|
33
33
|
|
34
34
|
describe "#type" do
|
35
35
|
it "should default to screenshot" do
|
36
|
-
Asset.new.asset_type.should eq :screenshot
|
36
|
+
SauceWhisk::Asset.new.asset_type.should eq :screenshot
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Assets do
|
3
|
+
describe SauceWhisk::Assets do
|
4
4
|
let(:auth) {"#{ENV["SAUCE_USERNAME"]}:#{ENV["SAUCE_ACCESS_KEY"]}"}
|
5
5
|
|
6
6
|
describe "#fetch", :vcr => {:cassette_name => "assets"} do
|
@@ -8,17 +8,17 @@ describe Assets do
|
|
8
8
|
let(:asset_name) {"0000screenshot.png"}
|
9
9
|
|
10
10
|
it "fetches an asset for the requested job" do
|
11
|
-
Assets.fetch job_id, asset_name
|
11
|
+
SauceWhisk::Assets.fetch job_id, asset_name
|
12
12
|
|
13
13
|
assert_requested :get, "https://#{auth}@saucelabs.com/rest/v1/dylanatsauce/jobs/#{job_id}/assets/#{asset_name}"
|
14
14
|
end
|
15
15
|
|
16
16
|
it "returns an asset" do
|
17
|
-
Assets.fetch(job_id, asset_name).should be_an_instance_of Asset
|
17
|
+
SauceWhisk::Assets.fetch(job_id, asset_name).should be_an_instance_of SauceWhisk::Asset
|
18
18
|
end
|
19
19
|
|
20
20
|
it "initializes the asset properly" do
|
21
|
-
asset = Assets.fetch job_id, asset_name
|
21
|
+
asset = SauceWhisk::Assets.fetch job_id, asset_name
|
22
22
|
asset.name.should eq asset_name
|
23
23
|
asset.job.should eq job_id
|
24
24
|
asset.asset_type.should eq :screenshot
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Job do
|
4
|
-
let(:job) {Job.new}
|
5
|
-
subject {Job.new}
|
3
|
+
describe SauceWhisk::Job do
|
4
|
+
let(:job) {SauceWhisk::Job.new}
|
5
|
+
subject {SauceWhisk::Job.new}
|
6
6
|
|
7
7
|
it {should respond_to :id}
|
8
8
|
|
@@ -26,7 +26,7 @@ describe Job do
|
|
26
26
|
"custom_data" => ""
|
27
27
|
}}
|
28
28
|
|
29
|
-
subject {Job.new(params)}
|
29
|
+
subject {SauceWhisk::Job.new(params)}
|
30
30
|
|
31
31
|
it "sets parameters at init" do
|
32
32
|
params.each do |k,v|
|
@@ -47,20 +47,20 @@ describe Job do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it "has empty updated_fields for new instances" do
|
50
|
-
new_job = Job.new(params)
|
50
|
+
new_job = SauceWhisk::Job.new(params)
|
51
51
|
new_job.updated_fields.should eq []
|
52
52
|
end
|
53
53
|
|
54
54
|
describe "#save" do
|
55
|
-
subject {Job.new(params)}
|
55
|
+
subject {SauceWhisk::Job.new(params)}
|
56
56
|
|
57
57
|
context "with changed values" do
|
58
58
|
before(:each) do
|
59
59
|
subject.name = "New_Name"
|
60
60
|
end
|
61
61
|
|
62
|
-
it "calls the save method of the Jobs object" do
|
63
|
-
Jobs.should_receive(:save).with(subject)
|
62
|
+
it "calls the save method of the SauceWhisk::Jobs object" do
|
63
|
+
SauceWhisk::Jobs.should_receive(:save).with(subject)
|
64
64
|
subject.save
|
65
65
|
end
|
66
66
|
end
|
@@ -90,7 +90,7 @@ describe Job do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
context "fetched from the API" do
|
93
|
-
subject {Jobs.fetch "bd9c43dd6b5549f1b942d1d581d98cac"}
|
93
|
+
subject {SauceWhisk::Jobs.fetch "bd9c43dd6b5549f1b942d1d581d98cac"}
|
94
94
|
|
95
95
|
describe "#screenshots", :vcr => {:cassette_name => "assets"} do
|
96
96
|
it "contains all the screenshots for that job" do
|
@@ -98,14 +98,14 @@ describe Job do
|
|
98
98
|
end
|
99
99
|
|
100
100
|
it "contains actual screenshots" do
|
101
|
-
subject.screenshots.first.should be_a_kind_of Asset
|
101
|
+
subject.screenshots.first.should be_a_kind_of SauceWhisk::Asset
|
102
102
|
subject.screenshots.first.asset_type.should eq :screenshot
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
describe "#video", :vcr => {:cassette_name => "assets"} do
|
107
107
|
it "should be a video asset" do
|
108
|
-
subject.video.should be_a_kind_of Asset
|
108
|
+
subject.video.should be_a_kind_of SauceWhisk::Asset
|
109
109
|
subject.video.asset_type.should eq :video
|
110
110
|
end
|
111
111
|
end
|
@@ -1,28 +1,28 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Jobs do
|
3
|
+
describe SauceWhisk::Jobs do
|
4
4
|
let(:auth) {"#{ENV["SAUCE_USERNAME"]}:#{ENV["SAUCE_ACCESS_KEY"]}"}
|
5
5
|
describe "#all", :vcr => {:cassette_name => 'jobs'} do
|
6
6
|
|
7
7
|
it "should return an enumerable" do
|
8
|
-
Jobs.all.should be_an Enumerable
|
8
|
+
SauceWhisk::Jobs.all.should be_an Enumerable
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should return a set of jobs" do
|
12
|
-
jobs_found = Jobs.all
|
13
|
-
jobs_found.each {|job| job.should be_a Job}
|
12
|
+
jobs_found = SauceWhisk::Jobs.all
|
13
|
+
jobs_found.each {|job| job.should be_a SauceWhisk::Job}
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
describe "##change_status", :vcr => {:cassette_name => "jobs"} do
|
18
18
|
let(:pass_string) {{:passed => true}.to_json}
|
19
19
|
it "exists" do
|
20
|
-
Jobs.respond_to? :change_status
|
20
|
+
SauceWhisk::Jobs.respond_to? :change_status
|
21
21
|
end
|
22
22
|
|
23
23
|
it "passes a test status to the REST api" do
|
24
24
|
job_id = "bd9c43dd6b5549f1b942d1d581d98cac"
|
25
|
-
Jobs.change_status job_id, true
|
25
|
+
SauceWhisk::Jobs.change_status job_id, true
|
26
26
|
assert_requested :put, "https://#{auth}@saucelabs.com/rest/v1/dylanatsauce/jobs/#{job_id}", :body => pass_string, :content_type => "application/json"
|
27
27
|
end
|
28
28
|
end
|
@@ -30,41 +30,41 @@ describe Jobs do
|
|
30
30
|
describe "##pass_job" do
|
31
31
|
it "Calls the API and passes the given job" do
|
32
32
|
job_id = "rerfreferf"
|
33
|
-
Jobs.should_receive(:change_status).with(job_id, true) {}
|
33
|
+
SauceWhisk::Jobs.should_receive(:change_status).with(job_id, true) {}
|
34
34
|
|
35
|
-
Jobs.pass_job job_id
|
35
|
+
SauceWhisk::Jobs.pass_job job_id
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
describe "##fail_job" do
|
40
40
|
it "Calls change_status to fail the job" do
|
41
41
|
job_id = "rcercer"
|
42
|
-
Jobs.should_receive(:change_status).with(job_id, false) {}
|
42
|
+
SauceWhisk::Jobs.should_receive(:change_status).with(job_id, false) {}
|
43
43
|
|
44
|
-
Jobs.fail_job job_id
|
44
|
+
SauceWhisk::Jobs.fail_job job_id
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "##save", :vcr => {:cassette_name => "jobs"} do
|
49
49
|
it "sends a put request" do
|
50
50
|
job_id = "bd9c43dd6b5549f1b942d1d581d98cac"
|
51
|
-
job = Job.new({:id => job_id})
|
52
|
-
Jobs.save (job)
|
51
|
+
job = SauceWhisk::Job.new({:id => job_id})
|
52
|
+
SauceWhisk::Jobs.save (job)
|
53
53
|
assert_requested :put, "https://#{auth}@saucelabs.com/rest/v1/dylanatsauce/jobs/#{job.id}", :body => anything, :content_type => "application/json"
|
54
54
|
end
|
55
55
|
|
56
56
|
it "only sends updated information" do
|
57
57
|
job_id = "bd9c43dd6b5549f1b942d1d581d98cac"
|
58
|
-
job = Job.new({:id => job_id})
|
58
|
+
job = SauceWhisk::Job.new({:id => job_id})
|
59
59
|
job.name = "Updated Name"
|
60
|
-
Jobs.save (job)
|
60
|
+
SauceWhisk::Jobs.save (job)
|
61
61
|
expected_body = {:name => "Updated Name"}.to_json
|
62
62
|
assert_requested :put, "https://#{auth}@saucelabs.com/rest/v1/dylanatsauce/jobs/#{job.id}", :body => expected_body, :content_type => "application/json"
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
describe "##fetch", :vcr => {:cassette_name => "jobs"} do
|
67
|
-
let(:job) {Jobs.fetch("bd9c43dd6b5549f1b942d1d581d98cac")}
|
67
|
+
let(:job) {SauceWhisk::Jobs.fetch("bd9c43dd6b5549f1b942d1d581d98cac")}
|
68
68
|
|
69
69
|
it "contains the list of screenshots for the job" do
|
70
70
|
job.screenshot_urls.should be_a_kind_of Enumerable
|
@@ -72,7 +72,7 @@ describe Jobs do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it "returns a job when a valid one is fetched" do
|
75
|
-
job.should be_an_instance_of Job
|
75
|
+
job.should be_an_instance_of SauceWhisk::Job
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "rest_client"
|
3
3
|
|
4
|
-
describe RestRequestBuilder do
|
4
|
+
describe SauceWhisk::RestRequestBuilder do
|
5
5
|
let(:dummy_client) {
|
6
6
|
Class.new do
|
7
|
-
extend RestRequestBuilder
|
7
|
+
extend SauceWhisk::RestRequestBuilder
|
8
8
|
|
9
9
|
def self.resource
|
10
10
|
"dummy"
|
@@ -20,7 +20,7 @@ describe SauceWhisk do
|
|
20
20
|
describe "##pass_job" do
|
21
21
|
it "should call #pass on the jobs object" do
|
22
22
|
job_id = "0418999"
|
23
|
-
Jobs.should_receive(:pass_job).with(job_id) {true}
|
23
|
+
SauceWhisk::Jobs.should_receive(:pass_job).with(job_id) {true}
|
24
24
|
SauceWhisk.pass_job job_id
|
25
25
|
end
|
26
26
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -16,8 +16,6 @@ VCR.configure do |config|
|
|
16
16
|
}
|
17
17
|
config.filter_sensitive_data("<SAUCE_USERNAME>") { ENV["SAUCE_USERNAME"] }
|
18
18
|
config.filter_sensitive_data("<SAUCE_ACCESS_KEY>") { ENV["SAUCE_ACCESS_KEY"] }
|
19
|
-
|
20
|
-
#config.debug_logger = STDOUT
|
21
19
|
end
|
22
20
|
|
23
21
|
RSpec.configure do |config|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sauce_whisk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Lacey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|