subordinate 0.6.1 → 0.6.2

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2EzZTBlYzBhZDM0MmQwN2RjMjhhYTg0MGQ4YTliOGJkNmU4NDgwNg==
4
+ YmNjYmE1MjYzMTFhYWJmMmRiNGZlNTY3ZTA3YzNjNzJlYTlmZjBlMw==
5
5
  data.tar.gz: !binary |-
6
- MjI0ODExMWQ1MjdlOGI1NjhlN2VkNzk4MDZhZWI0MDQ3Y2E4YzAxMg==
6
+ Y2EwZGZiM2QwMTVlZmIxN2MwMGQ2ZmQxZTEyZDYzNmU5MDg1ZTEyMg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZDVhYzdkZTg2ZTdkMjM1OGIyNDVlYTBjODJhYzY5ODRiZGZhNTRiOTlkNzg0
10
- ODRhMmZmMmQxZTM3ZTUwMGIxYzhkY2Q3YmVmNmRlNzA4NTBlNzU2NmIzOGZl
11
- MWQ1ZmEwYWM4OGFhN2Y5OTY3NGVhMmFkM2MyZGRkMTkzNWMyMmY=
9
+ MTExMzMxNjYwNzkxMzM1ZDQ0YzJhYmNjYWVmNTYzNzlhZDI0YjE4YTgwOWVh
10
+ OGM5NWUxZTZhYzFkNjRmNDAwOGIyNzhhZjhhYWU5MWQxYjcxOTAxMzRlZTFl
11
+ YmIyOTBhNjg1MmE3N2RjZDA1ZTk1M2U3MjRiY2Q2ODhjZjYwZWM=
12
12
  data.tar.gz: !binary |-
13
- ZDBhZWFlMjJlZThhZDY2MzhjNTMzOTBhMmFmNmI0NjFmNjBkNDFiYjEyZWY1
14
- NWIxZjNiZDA3NWU4NzRjNjQ1YmRjMDdhNmE0Y2YzYTRmMThmYmQ2ZTUyNzE5
15
- OTM1MGUxZTNkM2Q0MDY5ZWIyNjgzOTE2YmY0ZjRhNTU3ZmQ5MGU=
13
+ ZTJiMzcwOWE2NDJhMjg4ZDRkNTU4ZGRmOGU4OGI1YzQ4NTE3N2NkODRhNDk4
14
+ MjU2MTUwMjViOWYwY2E2MTlhYzk3MDBmYTlhMThhOGY3Y2MwYmNmMWYyZGE4
15
+ M2Q3MGMzM2RkMTkwOWE1NzBmODljNTU4OGYyNzRlMjIxODljNmI=
data/.travis.yml CHANGED
@@ -6,41 +6,4 @@ rvm:
6
6
  - rbx-19mode
7
7
  - 1.9.2
8
8
  - 1.9.3
9
- - 2.0.0
10
- env:
11
- global:
12
- - secure: ! 'JyUmtS/9TPcO177P0YpIgt9aHU6Be40uhG8zM4x0IFT7/z0824iJFCNr4k86
13
-
14
- CJnvF4ykHqQJPNmVQibmJjXFclYQcJbs6fXRWz0Bbiu7awO+W3/ZGOqzaG4W
15
-
16
- 0VNJPprWIjVRD9MtlBfruCVlEDz06Ssr/PSCzEAO0ozePM7LCak='
17
- - secure: ! 'MKerFaIev3SZZr1kcZfQTH8B6WOv+a0ir0t9A8GcJRcFVOclOEEy55lwXLbF
18
-
19
- 1Sa2ol6i+ADV92GnZ/MvavgbUUuc34ylV+kgBkJ8nbuOE1xtT6bSEqYeLbSE
20
-
21
- 82zWEo2FSvenOc7qaVuqf7lR7S7acVAWP0tuyG06pA6myEHfptM='
22
- - secure: ! 'GKejLb0DLwZV9gvVpDJry5BD8LNURZfq3U97Zf4aGl1+bb8lFteNHTclDLzL
23
-
24
- sd4ELwq+Ek5aO2ZdhnGiyhBkVX4dqxMRGH8OYoUEUMX887UaWrME4T0ch1W4
25
-
26
- 8y6V+NTOl+LlWjhzeOA+vxhB7YRd4lzjNFLsJmuQieymBbdZAwo='
27
- - secure: ! 'D8jIL+eWzjUDzUiJci9OFMvxqGvWSmY2PhjawYUcuwDsmC1HbIxsIf2PKSBY
28
-
29
- TyE18KwCp+KcRrn6zQjpdkUgMaMYK9rVyGD5NQhOhNjns31zJmON5LPhTehf
30
-
31
- 5Rrn6UevypPdqhOLJzDp4Jo15UY1Q95glU5Q49I6+k3VR2jlxAM='
32
- - secure: ! 'YjYOzWTAJnZqjqjxAO2tTKKCDh3dd7B4kAhc2i3v2uprL2z2WzgrQUKZRsZh
33
-
34
- eaOxManOwD26oTk2F44tnSs/prLUG/6gLg+hw4FU04v+p9H5xcm1/q56btar
35
-
36
- cr9suABpV7MIvOlBd4Pb2LJdyFlzTvw94xmJYTYg1jGwcKrYBF0='
37
- - secure: ! 'GsmIF1EIKv/k7r59I4N1Bdbi+dsXWH97SPWHl/Gaat+zN8yXEwVmQuO0P6Nb
38
-
39
- hzFTkvHJSE/aOAnQPxKs9qKV76/ERYPt1YZ1kUmQflCtgwWfx9K1MnGR6Ssy
40
-
41
- 4rXDbL14ERUm8DokrM4q2rjceg/Z75HSmBHUYtOb62XEzu2kpwg='
42
- - secure: ! 'QP9gVy6BBC/fV43hGDChNE2ln5Zi0MdNYMUnLq40bfBwreo1B+gLWH5I3ZAj
43
-
44
- RcMf+gLst3LMFu1hWtuCnRYH9L/ph8nwawkqNQoF22TJUCRFCGPUqrTJpzNg
45
-
46
- yz6vt+XrtRZk1whJwJcRWwLX9gybVv5sB6qGQu8swsgLrNDvsrE='
9
+ - 2.0.0
data/README.md CHANGED
@@ -147,27 +147,6 @@ A note from Jenkins: for array-type properties (such as jobs in this example), t
147
147
 
148
148
  Please see the [docs](https://ci.jenkins-ci.org/api/) for more info on tree parameters
149
149
 
150
- ## Testing
151
-
152
- This gem uses VCR to record requests to the api so you must test using a valid Jenkins server and credentails to test
153
-
154
- Add a sample authentications file to your `spec/fixtures` directory:
155
-
156
- ```ruby
157
- #spec/fixtures/authentications.yml
158
- USERNAME: jasontruluck # Your Username
159
- TOKEN: 12345678901234567890 # Your Jenkins Token (found at jenkins-server/user/your-user-name/configure)
160
- DOMAIN: mydomain.com # The domain of your Jenkins server
161
- PORT: 8080 # The port of your Jenkins Server
162
- SUBDOMAIN: jenkins # The subdomain of your Jenkins Server
163
- JOB: My-Jenkins-Job # The job that you want to run tests on
164
- VIEW: My-awesome-view # The view that you want to run tests on
165
- ```
166
-
167
- A sample is included in the [source](https://github.com/jasontruluck/subordinate/blob/master/spec/fixtures/authentications.yml.sample).
168
-
169
- *Note: for tests concerning disabling, deleting, restarting, etc they are mocked explicitly with webmock and will not effect your server*
170
-
171
150
  ## Contributing
172
151
 
173
152
  1. Fork it
@@ -1,3 +1,3 @@
1
1
  module Subordinate
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,6 @@ require 'rubygems'
2
2
  require 'coveralls'
3
3
  Coveralls.wear!
4
4
 
5
- # This file is copied to spec/ when you run 'rails generate rspec:install'
6
5
  ENV["RAILS_ENV"] ||= 'test'
7
6
 
8
7
  if ENV['RAILS_ENV'] == 'test'
@@ -20,26 +19,7 @@ if ENV['RAILS_ENV'] == 'test'
20
19
  end
21
20
 
22
21
  require 'subordinate'
23
- require 'vcr'
24
22
  require "webmock/rspec"
25
- require "mocha/api"
26
-
27
- authentications = File.expand_path("../fixtures/authentications.yml", __FILE__)
28
- if File.exists?(authentications)
29
- ENV.update YAML::load(File.open(authentications))
30
- end
31
-
32
- VCR.configure do |c|
33
- c.cassette_library_dir = 'spec/cassettes'
34
- c.hook_into :faraday
35
- c.ignore_localhost = true
36
- # Uncomment if you need to log VCR
37
- # c.debug_logger = File.open(Rails.root.join("log","vcr_debugger.log"), 'w')
38
- c.configure_rspec_metadata!
39
- c.allow_http_connections_when_no_cassette = true
40
- end
41
-
42
- WebMock.allow_net_connect!
43
23
 
44
24
  Dir[File.expand_path("spec/support/**/*.rb", __FILE__)].each {|f| require f}
45
25
 
@@ -47,3 +27,10 @@ RSpec.configure do |config|
47
27
  config.treat_symbols_as_metadata_keys_with_true_values = true
48
28
  config.order = "random"
49
29
  end
30
+
31
+ def stub_jenkins(http_method = :any, endpoint = "/", status = 200, content_type = "application/json", response)
32
+ stub_request(http_method, "http://someusername:sometoken@jenkins.example.com:8080#{endpoint}").
33
+ to_return(:status => status,
34
+ :body => File.read(File.expand_path("../support/mocks/#{response}", __FILE__)),
35
+ :headers =>{'Accept' => content_type, 'Content-type' => content_type})
36
+ end
@@ -1,22 +1,23 @@
1
+ # Build Spec
1
2
  require "spec_helper"
2
3
 
3
-
4
-
5
- # Client Spec
6
4
  describe Subordinate::Client do
7
- before do
5
+ before(:each) do
8
6
  Subordinate.reset!
9
7
  Subordinate.configure do |c|
10
- c.subdomain = ENV["SUBDOMAIN"]
11
- c.domain = ENV["DOMAIN"]
12
- c.port = ENV["PORT"]
8
+ c.subdomain = "jenkins"
9
+ c.domain = "example.com"
10
+ c.port = 8080
13
11
  c.ssl = false
14
12
  end
15
13
  end
16
- let(:subordinate) { Subordinate::Client.new(:username => ENV["USERNAME"], :api_token => ENV["TOKEN"]) }
17
14
 
18
- describe "#build", :vcr do
19
- let(:current_response) { subordinate.build(ENV["JOB"], 1) }
15
+ let(:subordinate) { Subordinate::Client.new(:username => "someusername", :api_token => "sometoken") }
16
+
17
+ describe "#build" do
18
+ before(:each) {stub_jenkins(:get, "/job/Some-Job/1/api/json", "build.json") }
19
+
20
+ let(:current_response) { subordinate.build("Some-Job", 1) }
20
21
 
21
22
  it "returns the job response" do
22
23
  current_response.should_not be_nil
@@ -95,45 +96,60 @@ describe Subordinate::Client do
95
96
 
96
97
  describe "#build_timestamp" do
97
98
  it "returns the timestamp of the specified build" do
98
- stub_request(:get, "#{subordinate.api_endpoint}/job/#{ENV["JOB"]}/1/buildTimestamp").
99
- to_return(:status => 302, :body => "3/25/13 3:30 AM", :headers => {})
99
+ stub_jenkins(:get, "/job/Some-Job/1/buildTimestamp", 302, "text/plain", "build_timestamp.txt")
100
100
 
101
-
102
- subordinate.build_timestamp(ENV["JOB"], 1).should == "3/25/13 3:30 AM"
101
+ subordinate.build_timestamp("Some-Job", 1).should == "9/9/13 9:32 PM"
103
102
  end
104
103
 
105
104
  it "returns the timestamp in the specified format" do
106
- stub_request(:get, "#{subordinate.api_endpoint}/job/#{ENV["JOB"]}/1/buildTimestamp?format=yyyy/MM/dd").
107
- to_return(:status => 302, :body => "2013/03/25", :headers => {})
105
+ stub_jenkins(:get, "/job/Some-Job/1/buildTimestamp?format=yyyy/MM/dd", 302, "text/plain", "build_timestamp_formatted.txt")
108
106
 
109
- subordinate.build_timestamp(ENV["JOB"], 1, "yyyy/MM/dd").should == "2013/03/25"
107
+ subordinate.build_timestamp("Some-Job", 1, "yyyy/MM/dd").should == "2013/03/25"
110
108
  end
111
109
  end
112
110
 
113
- describe "#console_output_for_build", :vcr do
114
- it "returns the console output for a complete build" do
115
- response = subordinate.console_output_for_build(ENV["JOB"], 1)
116
- response.should_not be_nil
117
- response.should_not include("javax.servlet.ServletException:")
111
+ describe "#console_output_for_build" do
112
+ context "complete console output" do
113
+ before(:each) { stub_jenkins(:get, "/job/Some-Job/1/logText/progressiveText?start=0", 200, "text/plain", "console_output.txt") }
114
+ let(:response) { subordinate.console_output_for_build("Some-Job", 1) }
115
+
116
+ it "returns the console output for a complete build" do
117
+ response.should_not be_nil
118
+ end
119
+
120
+ it "is not an error" do
121
+ response.should_not include("javax.servlet.ServletException:")
122
+ end
118
123
  end
119
124
 
120
- it "returns pre-formatted output" do
121
- response = subordinate.console_output_for_build(ENV["JOB"], 1, nil, true)
122
- response.should_not be_nil
123
- response.should_not include("javax.servlet.ServletException:")
125
+ context "preformatted console output" do
126
+ before(:each) { stub_jenkins(:get, "/job/Some-Job/1/logText/progressiveHtml?start=0", 200, "text/html", "console_output_pre.html") }
127
+ let(:response) { subordinate.console_output_for_build("Some-Job", 1, nil, true) }
128
+
129
+ it "returns the console output for a complete build" do
130
+ response.should_not be_nil
131
+ end
132
+
133
+ it "is not an error" do
134
+ response.should_not include("javax.servlet.ServletException:")
135
+ end
124
136
  end
125
137
 
126
- context "byte size arguement" do
138
+ context "offset console output" do
139
+ before(:each) {
140
+ stub_jenkins(:get, "/job/Some-Job/1/logText/progressiveText?start=0", 200, "text/plain", "console_output.txt")
141
+ stub_jenkins(:get, "/job/Some-Job/1/logText/progressiveText?start=2000", 200, "text/plain", "console_output_offset.txt")
142
+ }
143
+ let(:output1) {subordinate.console_output_for_build("Some-Job", 1, 2000) }
144
+ let(:output2) {subordinate.console_output_for_build("Some-Job", 1, 0) }
145
+
127
146
  it "returns data at byte 2000" do
128
- subordinate.console_output_for_build(ENV["JOB"], 1, 2000).should_not be_nil
147
+ output1.should_not be_nil
129
148
  end
130
149
 
131
150
  it "when passed an offset of 2000 it is offset by 2000 bytes" do
132
- output1 = subordinate.console_output_for_build(ENV["JOB"], 1, 2000)
133
- output2 = subordinate.console_output_for_build(ENV["JOB"], 1, 0)
134
-
135
151
  output1.bytesize.should < output2.bytesize
136
152
  end
137
153
  end
138
154
  end
139
- end
155
+ end
@@ -1,19 +1,24 @@
1
+ # Build Executor Spec
1
2
  require "spec_helper"
2
3
 
3
- # Build Executor Spec
4
4
  describe Subordinate::Client do
5
5
  before do
6
6
  Subordinate.reset!
7
7
  Subordinate.configure do |c|
8
- c.subdomain = ENV["SUBDOMAIN"]
9
- c.domain = ENV["DOMAIN"]
10
- c.port = ENV["PORT"]
8
+ c.subdomain = "jenkins"
9
+ c.domain = "example.com"
10
+ c.port = 8080
11
11
  c.ssl = false
12
12
  end
13
13
  end
14
- let(:subordinate) { Subordinate::Client.new(:username => ENV["USERNAME"], :api_token => ENV["TOKEN"]) }
15
14
 
16
- describe "#build_executor", :vcr do
15
+ let(:subordinate) { Subordinate::Client.new(:username => "someusername", :api_token => "sometoken") }
16
+
17
+ describe "#build_executor" do
18
+ before(:each) do
19
+ stub_jenkins(:get, "/computer/api/json", "computer.json")
20
+ end
21
+
17
22
  let(:current_response) { subordinate.build_executor }
18
23
 
19
24
  it "returns the build_executor response" do
@@ -104,4 +109,4 @@ describe Subordinate::Client do
104
109
  end
105
110
  end
106
111
  end
107
- end
112
+ end
@@ -1,22 +1,23 @@
1
+ # Job Spec
1
2
  require "spec_helper"
2
3
 
3
-
4
-
5
- # Client Spec
6
4
  describe Subordinate::Client do
7
5
  before do
8
6
  Subordinate.reset!
9
7
  Subordinate.configure do |c|
10
- c.subdomain = ENV["SUBDOMAIN"]
11
- c.domain = ENV["DOMAIN"]
12
- c.port = ENV["PORT"]
8
+ c.subdomain = "jenkins"
9
+ c.domain = "example.com"
10
+ c.port = 8080
13
11
  c.ssl = false
14
12
  end
15
13
  end
16
- let(:subordinate) { Subordinate::Client.new(:username => ENV["USERNAME"], :api_token => ENV["TOKEN"]) }
17
14
 
18
- describe "#job", :vcr do
19
- let(:current_response) { subordinate.job(ENV["JOB"]) }
15
+ let(:subordinate) { Subordinate::Client.new(:username => "someusername", :api_token => "sometoken") }
16
+
17
+ describe "#job" do
18
+ before(:each) { stub_jenkins(:get, "/job/Some-Job/api/json", "job.json") }
19
+
20
+ let(:current_response) { subordinate.job("Some-Job") }
20
21
 
21
22
  it "should return the job response" do
22
23
  current_response.should_not be_nil
@@ -135,46 +136,41 @@ describe Subordinate::Client do
135
136
 
136
137
  describe "#build_job" do
137
138
  it "builds the job specified" do
138
- stub_request(:post, "#{subordinate.api_endpoint}/job/#{ENV["JOB"]}/build").
139
- to_return(:status => 302, :body => "", :headers => {})
139
+ stub_jenkins(:post, "/job/Some-Job/build", 302, "empty.json")
140
140
 
141
- subordinate.build_job(ENV["JOB"]).should == 302
141
+ subordinate.build_job("Some-Job").should == 302
142
142
  end
143
143
  end
144
144
 
145
145
  describe "#build_job_with_params" do
146
146
  it "builds the job specified with the parameters specified" do
147
- stub_request(:post, "#{subordinate.api_endpoint}/job/#{ENV["JOB"]}/buildWithParameters").
148
- to_return(:status => 302, :body => "", :headers => {})
147
+ stub_jenkins(:post, "/job/Some-Job/buildWithParameters", 302, "empty.json")
149
148
 
150
- subordinate.build_job_with_params(ENV["JOB"]).should == 302
149
+ subordinate.build_job_with_params("Some-Job").should == 302
151
150
  end
152
151
  end
153
152
 
154
153
  describe "#disable_job" do
155
154
  it "disables the specified job" do
156
- stub_request(:post, "#{subordinate.api_endpoint}/job/#{ENV["JOB"]}/disable").
157
- to_return(:status => 302, :body => "", :headers => {})
155
+ stub_jenkins(:post, "/job/Some-Job/disable", 302, "empty.json")
158
156
 
159
- subordinate.disable_job(ENV["JOB"]).should == 302
157
+ subordinate.disable_job("Some-Job").should == 302
160
158
  end
161
159
  end
162
160
 
163
161
  describe "#enable_job" do
164
162
  it "enables the specified job" do
165
- stub_request(:post, "#{subordinate.api_endpoint}/job/#{ENV["JOB"]}/enable").
166
- to_return(:status => 302, :body => "", :headers => {})
163
+ stub_jenkins(:post, "/job/Some-Job/enable", 302, "empty.json")
167
164
 
168
- subordinate.enable_job(ENV["JOB"]).should == 302
165
+ subordinate.enable_job("Some-Job").should == 302
169
166
  end
170
167
  end
171
168
 
172
169
  describe "#delete_job" do
173
170
  it "deletes the specified job" do
174
- stub_request(:post, "#{subordinate.api_endpoint}/job/#{ENV["JOB"]}/delete").
175
- to_return(:status => 302, :body => "", :headers => {})
171
+ stub_jenkins(:post, "/job/Some-Job/delete", 302, "empty.json")
176
172
 
177
- subordinate.delete_job(ENV["JOB"]).should == 302
173
+ subordinate.delete_job("Some-Job").should == 302
178
174
  end
179
175
  end
180
176
  end
@@ -5,15 +5,18 @@ describe Subordinate::Client do
5
5
  before do
6
6
  Subordinate.reset!
7
7
  Subordinate.configure do |c|
8
- c.subdomain = ENV["SUBDOMAIN"]
9
- c.domain = ENV["DOMAIN"]
10
- c.port = ENV["PORT"]
8
+ c.subdomain = "jenkins"
9
+ c.domain = "example.com"
10
+ c.port = 8080
11
11
  c.ssl = false
12
12
  end
13
13
  end
14
- let(:subordinate) { Subordinate::Client.new(:username => ENV["USERNAME"], :api_token => ENV["TOKEN"]) }
15
14
 
16
- describe "#load_statistics", :vcr do
15
+ let(:subordinate) { Subordinate::Client.new(:username => "someusername", :api_token => "sometoken") }
16
+
17
+ describe "#load_statistics" do
18
+ before(:each) { stub_jenkins(:get, "/overallLoad/api/json", "load_statistics.json") }
19
+
17
20
  let(:current_response) { subordinate.load_statistics }
18
21
 
19
22
  it "returns the load statistics response" do
@@ -38,4 +41,4 @@ describe Subordinate::Client do
38
41
  end
39
42
  end
40
43
  end
41
- end
44
+ end
@@ -1,19 +1,22 @@
1
+ # Queue Spec
1
2
  require "spec_helper"
2
3
 
3
- # Queue Spec
4
4
  describe Subordinate::Client do
5
5
  before do
6
6
  Subordinate.reset!
7
7
  Subordinate.configure do |c|
8
- c.subdomain = ENV["SUBDOMAIN"]
9
- c.domain = ENV["DOMAIN"]
10
- c.port = ENV["PORT"]
8
+ c.subdomain = "jenkins"
9
+ c.domain = "example.com"
10
+ c.port = 8080
11
11
  c.ssl = false
12
12
  end
13
13
  end
14
- let(:subordinate) { Subordinate::Client.new(:username => ENV["USERNAME"], :api_token => ENV["TOKEN"]) }
15
14
 
16
- describe "#people", :vcr do
15
+ let(:subordinate) { Subordinate::Client.new(:username => "someusername", :api_token => "sometoken") }
16
+
17
+ describe "#people" do
18
+ before(:each) { stub_jenkins(:get, "/asynchPeople/api/json", "people.json") }
19
+
17
20
  let(:current_response) { subordinate.people }
18
21
 
19
22
  it "returns the users response" do
@@ -61,4 +64,4 @@ describe Subordinate::Client do
61
64
  end
62
65
  end
63
66
  end
64
- end
67
+ end