subordinate 0.5.0 → 0.5.1
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.
data/lib/subordinate/client.rb
CHANGED
@@ -35,7 +35,9 @@ module Subordinate
|
|
35
35
|
def build_endpoint
|
36
36
|
endpoint = ssl ? "https://" : "http://"
|
37
37
|
endpoint << "#{self.username}:#{self.api_token}@" if self.authenticated?
|
38
|
-
endpoint << "#{self.subdomain}
|
38
|
+
endpoint << "#{self.subdomain}." if self.subdomain
|
39
|
+
endpoint << "#{self.domain}" if self.domain
|
40
|
+
endpoint << ":#{self.port}" if self.port
|
39
41
|
self.api_endpoint = endpoint
|
40
42
|
end
|
41
43
|
|
data/lib/subordinate/version.rb
CHANGED
@@ -74,7 +74,7 @@ describe Subordinate::Client do
|
|
74
74
|
|
75
75
|
describe "#add_job_to_view" do
|
76
76
|
it "responds with a success" do
|
77
|
-
stub_request(:post, "#{subordinate.api_endpoint}/view/#{ENV["VIEW"]}/addJobToView").
|
77
|
+
stub_request(:post, "#{subordinate.api_endpoint}/view/#{ENV["VIEW"]}/addJobToView?name=#{ENV['JOB']}").
|
78
78
|
to_return(:status => 200, :body => "", :headers => {})
|
79
79
|
|
80
80
|
subordinate.add_job_to_view(ENV["VIEW"], ENV["JOB"]).status.should == 200
|
@@ -83,7 +83,7 @@ describe Subordinate::Client do
|
|
83
83
|
|
84
84
|
describe "#remove_job_from_view" do
|
85
85
|
it "responds with a success" do
|
86
|
-
stub_request(:post, "#{subordinate.api_endpoint}/view/#{ENV["VIEW"]}/removeJobFromView").
|
86
|
+
stub_request(:post, "#{subordinate.api_endpoint}/view/#{ENV["VIEW"]}/removeJobFromView?name=#{ENV['JOB']}").
|
87
87
|
to_return(:status => 200, :body => "", :headers => {})
|
88
88
|
|
89
89
|
subordinate.remove_job_from_view(ENV["VIEW"], ENV["JOB"]).status.should == 200
|
@@ -13,6 +13,11 @@ describe Subordinate::Client do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#initialize" do
|
16
|
+
let(:domain) { "woofound.com" }
|
17
|
+
let(:subdomain) { "awesome" }
|
18
|
+
let(:port) { 2000 }
|
19
|
+
let(:ssl) { false }
|
20
|
+
|
16
21
|
it "can be initialized" do
|
17
22
|
Subordinate::Client.new.class.should == Subordinate::Client
|
18
23
|
end
|
@@ -27,26 +32,27 @@ describe Subordinate::Client do
|
|
27
32
|
raise_exception
|
28
33
|
end
|
29
34
|
|
35
|
+
it "generates an endpoint without username and api token" do
|
36
|
+
client = Subordinate::Client.new(:api_key => ENV["API_KEY"] )
|
37
|
+
client.api_endpoint.should_not include("#{ENV["USERNAME"]}:#{ENV["API_KEY"]}")
|
38
|
+
end
|
39
|
+
|
30
40
|
it "can be configured to use a new domain via options" do
|
31
|
-
domain = "woofound.com"
|
32
41
|
client = Subordinate::Client.new(:api_key => ENV["API_KEY"], :domain => domain )
|
33
42
|
client.domain.should == domain
|
34
43
|
end
|
35
44
|
|
36
45
|
it "can be configured to use a new subdomain via options" do
|
37
|
-
subdomain = "awesome"
|
38
46
|
client = Subordinate::Client.new(:api_key => ENV["API_KEY"], :subdomain => subdomain )
|
39
47
|
client.subdomain.should == subdomain
|
40
48
|
end
|
41
49
|
|
42
50
|
it "can be configured to use a new port via options" do
|
43
|
-
port = 2000
|
44
51
|
client = Subordinate::Client.new(:api_key => ENV["API_KEY"], :port => port )
|
45
52
|
client.port.should == port
|
46
53
|
end
|
47
54
|
|
48
55
|
it "can be configured to use a different ssl option via options" do
|
49
|
-
ssl = false
|
50
56
|
client = Subordinate::Client.new(:api_key => ENV["API_KEY"], :ssl => ssl )
|
51
57
|
client.ssl.should == ssl
|
52
58
|
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
# Configuration Spec
|
4
|
+
describe Subordinate::Client do
|
5
|
+
before do
|
6
|
+
Subordinate.reset!
|
7
|
+
Subordinate.configure do |c|
|
8
|
+
c.subdomain = ENV["SUBDOMAIN"]
|
9
|
+
c.domain = ENV["DOMAIN"]
|
10
|
+
c.port = ENV["PORT"]
|
11
|
+
c.ssl = false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "configuration" do
|
16
|
+
let(:domain) { "woofound.com" }
|
17
|
+
let(:subdomain) { "awesome" }
|
18
|
+
let(:port) { 2000 }
|
19
|
+
let(:ssl) { false }
|
20
|
+
|
21
|
+
describe "with a domain" do
|
22
|
+
before do
|
23
|
+
Subordinate.reset!
|
24
|
+
Subordinate.configure do |c|
|
25
|
+
c.domain = domain
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:client) { Subordinate.new }
|
30
|
+
|
31
|
+
it "sets the domain for the client" do
|
32
|
+
client.domain.should == domain
|
33
|
+
end
|
34
|
+
|
35
|
+
it "builds an endpoint with the domain" do
|
36
|
+
client.api_endpoint.should include(domain)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# SUBDOMAIN
|
41
|
+
describe "with a subdomain" do
|
42
|
+
before do
|
43
|
+
Subordinate.reset!
|
44
|
+
Subordinate.configure do |c|
|
45
|
+
c.subdomain = subdomain
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
let(:client) { Subordinate.new }
|
50
|
+
|
51
|
+
it "sets the subdomain for the client" do
|
52
|
+
client.subdomain.should == subdomain
|
53
|
+
end
|
54
|
+
|
55
|
+
it "builds an endpoint with the subdomain" do
|
56
|
+
client.api_endpoint.should include(subdomain)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "without a subdomain" do
|
61
|
+
it "builds an endpoint without a subdomain" do
|
62
|
+
client = Subordinate.new(:subdomain => nil)
|
63
|
+
client.api_endpoint.should == "http://#{ENV["DOMAIN"]}:#{ENV["PORT"]}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# PORT
|
68
|
+
describe "with a port" do
|
69
|
+
before do
|
70
|
+
Subordinate.reset!
|
71
|
+
Subordinate.configure do |c|
|
72
|
+
c.port = port
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
let(:client) { Subordinate.new }
|
77
|
+
|
78
|
+
it "sets the port for the client" do
|
79
|
+
client.port.should == port
|
80
|
+
end
|
81
|
+
|
82
|
+
it "builds an endpoint with the port" do
|
83
|
+
client.api_endpoint.should include("#{port}")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "without a port" do
|
88
|
+
it "builds an endpoint without a port" do
|
89
|
+
client = Subordinate.new(:port => nil)
|
90
|
+
client.api_endpoint.should == "http://#{ENV["SUBDOMAIN"]}.#{ENV["DOMAIN"]}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# SSL
|
95
|
+
describe "with a ssl" do
|
96
|
+
before do
|
97
|
+
Subordinate.reset!
|
98
|
+
Subordinate.configure do |c|
|
99
|
+
c.ssl = ssl
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
let(:client) { Subordinate.new }
|
104
|
+
|
105
|
+
it "sets the ssl for the client" do
|
106
|
+
client.ssl.should == ssl
|
107
|
+
end
|
108
|
+
|
109
|
+
it "builds an endpoint with the ssl set to false" do
|
110
|
+
client.api_endpoint.should include("http://")
|
111
|
+
end
|
112
|
+
|
113
|
+
it "builds an endpoint with the ssl set to true" do
|
114
|
+
client = Subordinate.new(:ssl => true)
|
115
|
+
client.api_endpoint.should include("https://")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subordinate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -258,6 +258,7 @@ files:
|
|
258
258
|
- spec/subordinate/client/system_spec.rb
|
259
259
|
- spec/subordinate/client/view_spec.rb
|
260
260
|
- spec/subordinate/client_spec.rb
|
261
|
+
- spec/subordinate/configuration_spec.rb
|
261
262
|
- subordinate.gemspec
|
262
263
|
homepage: https://github.com/jasontruluck/subordinate
|
263
264
|
licenses: []
|
@@ -273,7 +274,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
273
274
|
version: '0'
|
274
275
|
segments:
|
275
276
|
- 0
|
276
|
-
hash:
|
277
|
+
hash: -1675897956094488163
|
277
278
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
278
279
|
none: false
|
279
280
|
requirements:
|
@@ -282,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
282
283
|
version: '0'
|
283
284
|
segments:
|
284
285
|
- 0
|
285
|
-
hash:
|
286
|
+
hash: -1675897956094488163
|
286
287
|
requirements: []
|
287
288
|
rubyforge_project:
|
288
289
|
rubygems_version: 1.8.24
|
@@ -301,4 +302,5 @@ test_files:
|
|
301
302
|
- spec/subordinate/client/system_spec.rb
|
302
303
|
- spec/subordinate/client/view_spec.rb
|
303
304
|
- spec/subordinate/client_spec.rb
|
305
|
+
- spec/subordinate/configuration_spec.rb
|
304
306
|
has_rdoc:
|