dawn-api 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -4
- data/lib/dawn/api/authenticate.rb +33 -7
- data/lib/dawn/api/base_api.rb +52 -6
- data/lib/dawn/api/health_check.rb +14 -0
- data/lib/dawn/api/hosts.rb +16 -3
- data/lib/dawn/api/models/account.rb +44 -15
- data/lib/dawn/api/models/app/domains.rb +30 -6
- data/lib/dawn/api/models/app/drains.rb +30 -6
- data/lib/dawn/api/models/app/env.rb +19 -5
- data/lib/dawn/api/models/app/gears.rb +31 -7
- data/lib/dawn/api/models/app/releases.rb +28 -8
- data/lib/dawn/api/models/app.rb +93 -16
- data/lib/dawn/api/models/domain.rb +36 -11
- data/lib/dawn/api/models/drain.rb +33 -19
- data/lib/dawn/api/models/gear.rb +45 -25
- data/lib/dawn/api/models/key.rb +33 -15
- data/lib/dawn/api/models/login.rb +5 -4
- data/lib/dawn/api/models/release.rb +32 -14
- data/lib/dawn/api/safe/base_api.rb +3 -3
- data/lib/dawn/api/safe/safe_extension.rb +20 -5
- data/lib/dawn/api/version.rb +5 -5
- data/lib/dawn/api.rb +1 -1
- data/spec/api/account_spec.rb +21 -0
- data/spec/api/app/domains_spec.rb +30 -0
- data/spec/api/app/drains_spec.rb +30 -0
- data/spec/api/app/gears_spec.rb +38 -0
- data/spec/api/app/releases_spec.rb +30 -0
- data/spec/api/app_spec.rb +166 -0
- data/spec/api/domain_spec.rb +54 -0
- data/spec/api/drain_spec.rb +54 -0
- data/spec/api/gear_spec.rb +65 -0
- data/spec/api/key_spec.rb +54 -0
- data/spec/api/release_spec.rb +13 -0
- data/spec/api_spec_helper.rb +18 -0
- data/spec/references/data.yml +16 -0
- data/spec/seed.rb +70 -0
- data/spec/seedlog.log +1454 -0
- data/spec/support/vcr.rb +11 -0
- data/spec/vcr/Dawn_Account/_current/should_retrieve_current_user_account.yml +51 -0
- data/spec/vcr/Dawn_Account/_update/should_update_an_account.yml +99 -0
- data/spec/vcr/Dawn_App/_all/should_only_have_an_array_of_apps.yml +62 -0
- data/spec/vcr/Dawn_App/_all/should_retrieve_all_user_apps.yml +62 -0
- data/spec/vcr/Dawn_App/_create/should_create_a_new_app_given_a_name.yml +51 -0
- data/spec/vcr/Dawn_App/_create/should_raise_an_Excon_Errors_UnprocessableEntity_when_an_invalid_name_is_given.yml +49 -0
- data/spec/vcr/Dawn_App/_destroy/should_destroy_1_app.yml +49 -0
- data/spec/vcr/Dawn_App/_destroy/should_fail_to_destroy_non-existant_app.yml +48 -0
- data/spec/vcr/Dawn_App/_domains/should_have_domains.yml +51 -0
- data/spec/vcr/Dawn_App/_domains/should_retrieve_domains.yml +98 -0
- data/spec/vcr/Dawn_App/_drains/should_have_drains.yml +51 -0
- data/spec/vcr/Dawn_App/_find/should_fail_to_find_a_non_existant_app.yml +48 -0
- data/spec/vcr/Dawn_App/_find/should_retrieve_1_app_by_id.yml +111 -0
- data/spec/vcr/Dawn_App/_find/should_retrieve_1_app_by_name.yml +51 -0
- data/spec/vcr/Dawn_App/_gears/should_have_gears.yml +51 -0
- data/spec/vcr/Dawn_App/_gears/should_restart_gears.yml +98 -0
- data/spec/vcr/Dawn_App/_gears/should_retrieve_gears.yml +98 -0
- data/spec/vcr/Dawn_App/_logs/should_fail_to_retrieve_logs_uri_for_a_non_existant_app.yml +48 -0
- data/spec/vcr/Dawn_App/_logs/should_retrieve_logs_url_for_app.yml +98 -0
- data/spec/vcr/Dawn_App/_releases/should_have_releases.yml +51 -0
- data/spec/vcr/Dawn_App/_releases/should_retrieve_releases.yml +98 -0
- data/spec/vcr/Dawn_App/_restart/should_fail_to_restart_a_non_existant_app.yml +48 -0
- data/spec/vcr/Dawn_App/_scale/should_have_updated_formation.yml +51 -0
- data/spec/vcr/Dawn_App/_scale/should_raise_an_IndexError_if_app_key_is_missing.yml +51 -0
- data/spec/vcr/Dawn_App/_scale/should_scale_app.yml +98 -0
- data/spec/vcr/Dawn_App/_update/should_fail_to_update_non-existant_app.yml +48 -0
- data/spec/vcr/Dawn_App_Domains/_all/should_have_only_domains.yml +98 -0
- data/spec/vcr/Dawn_App_Domains/_all/should_return_all_domains.yml +98 -0
- data/spec/vcr/Dawn_App_Domains/_create/should_create_a_new_domain.yml +99 -0
- data/spec/vcr/Dawn_App_Drains/_all/should_have_only_drains.yml +98 -0
- data/spec/vcr/Dawn_App_Drains/_all/should_return_all_drains.yml +98 -0
- data/spec/vcr/Dawn_App_Drains/_create/should_create_a_new_drain.yml +99 -0
- data/spec/vcr/Dawn_App_Gears/_all/should_return_all_gears.yml +98 -0
- data/spec/vcr/Dawn_App_Releases/_all/should_return_all_releases.yml +98 -0
- data/spec/vcr/Dawn_App_Releases/_create/should_create_a_new_release.yml +423 -0
- data/spec/vcr/Dawn_Key/_all/should_retrieve_all_user_keys.yml +52 -0
- data/spec/vcr/Dawn_Key/_create/should_create_a_new_sshkey.yml +51 -0
- data/spec/vcr/Dawn_Key/_create/should_fail_if_sshkey_is_invalid.yml +49 -0
- data/spec/vcr/Dawn_Key/_destroy/should_404_if_key_does_not_exist.yml +48 -0
- data/spec/vcr/Dawn_Key/_destroy/should_remove_a_key_by_id.yml +98 -0
- data/spec/vcr/Dawn_Key/_find/should_404_if_key_does_not_exist.yml +48 -0
- data/spec/vcr/Dawn_Key/_find/should_find_a_key_by_id.yml +99 -0
- data/spec/vcr/Dawn_Release/_find/should_find_1_release_by_id.yml +48 -0
- metadata +62 -3
- data/lib/dawn/api/safe.rb +0 -2
@@ -1,37 +1,52 @@
|
|
1
1
|
require 'dawn/api/base_api'
|
2
2
|
|
3
|
-
module Dawn
|
4
|
-
class Release
|
5
|
-
|
3
|
+
module Dawn #:nodoc:
|
4
|
+
class Release #:nodoc:
|
6
5
|
include BaseApi
|
7
6
|
|
8
|
-
|
7
|
+
# @type [Dawn::App]
|
9
8
|
attr_writer :app
|
9
|
+
# @type [String]
|
10
|
+
data_key :id, write: false
|
11
|
+
# @type [Integer]
|
12
|
+
data_key :created_at, write: false
|
13
|
+
# @type [Integer]
|
14
|
+
data_key :updated_at, write: false
|
15
|
+
# @type [String]
|
16
|
+
data_key :image, write: false
|
17
|
+
# @type [String]
|
18
|
+
data_key :app_id, path: "app/id", write: false
|
10
19
|
|
20
|
+
###
|
21
|
+
# @param [Hash] data
|
22
|
+
###
|
11
23
|
def initialize(data)
|
12
24
|
@app = nil
|
13
25
|
@data = data
|
14
26
|
end
|
15
27
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
data_key :image
|
20
|
-
data_key :app_id, "app/id"
|
21
|
-
|
28
|
+
###
|
29
|
+
# @return [Dawn::App]
|
30
|
+
###
|
22
31
|
def app
|
23
32
|
@app ||= App.find(id: app_id)
|
24
33
|
end
|
25
34
|
|
35
|
+
###
|
36
|
+
# @return [self]
|
37
|
+
###
|
26
38
|
def refresh
|
27
|
-
@data =
|
28
|
-
expects: 200,
|
29
|
-
method: :get,
|
39
|
+
@data = get(
|
30
40
|
path: "/releases/#{id}",
|
31
41
|
query: options
|
32
42
|
)["release"]
|
43
|
+
self
|
33
44
|
end
|
34
45
|
|
46
|
+
###
|
47
|
+
# @param [Hash] options
|
48
|
+
# @return [Array<Dawn::Release>]
|
49
|
+
###
|
35
50
|
def self.all(options={})
|
36
51
|
get(
|
37
52
|
path: "/releases",
|
@@ -39,6 +54,10 @@ module Dawn
|
|
39
54
|
).map { |hsh| new hsh["release"] }
|
40
55
|
end
|
41
56
|
|
57
|
+
###
|
58
|
+
# @param [Hash] options
|
59
|
+
# @return [Dawn::Release]
|
60
|
+
###
|
42
61
|
def self.find(options={})
|
43
62
|
id = id_param(options)
|
44
63
|
|
@@ -47,6 +66,5 @@ module Dawn
|
|
47
66
|
query: options
|
48
67
|
)["release"]
|
49
68
|
end
|
50
|
-
|
51
69
|
end
|
52
70
|
end
|
@@ -1,19 +1,25 @@
|
|
1
|
-
module Dawn
|
2
|
-
module SafeExtension
|
3
|
-
class SafeContext
|
1
|
+
module Dawn #:nodoc:
|
2
|
+
module SafeExtension #:nodoc:
|
3
|
+
class SafeContext #:nodoc:
|
4
|
+
# @type [Exception]
|
4
5
|
attr_accessor :last_exception
|
5
6
|
|
7
|
+
###
|
8
|
+
# @param [Object] obj
|
9
|
+
###
|
6
10
|
def initialize(obj)
|
7
11
|
@obj = obj
|
8
12
|
@last_exception = nil
|
9
13
|
end
|
10
14
|
|
15
|
+
# :nodoc:
|
11
16
|
def method_missing(sym, *args, &block)
|
12
17
|
if @obj.respond_to?(sym)
|
13
18
|
begin
|
14
19
|
@obj.send sym, *args, &block
|
15
20
|
rescue => ex
|
16
21
|
self.last_exception = ex
|
22
|
+
false
|
17
23
|
end
|
18
24
|
else
|
19
25
|
@obj.method_missing sym, *args, &block
|
@@ -21,8 +27,17 @@ module Dawn
|
|
21
27
|
end
|
22
28
|
end
|
23
29
|
|
24
|
-
|
25
|
-
|
30
|
+
###
|
31
|
+
# @overload safe
|
32
|
+
# Creates a new SafeContext for the object
|
33
|
+
# @return [SafeContext]
|
34
|
+
# @overload safe(symbol, *args, &block)
|
35
|
+
# @return [Object] result from method invocation
|
36
|
+
###
|
37
|
+
def safe(*args, &block)
|
38
|
+
context = SafeContext.new(self)
|
39
|
+
return context.send(*args, &block) unless args.empty?
|
40
|
+
context
|
26
41
|
end
|
27
42
|
end
|
28
43
|
end
|
data/lib/dawn/api/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
module Dawn
|
2
|
-
module API
|
3
|
-
module Version
|
1
|
+
module Dawn #:nodoc:
|
2
|
+
module API #:nodoc:
|
3
|
+
module Version #:nodoc:
|
4
4
|
MAJOR = 0
|
5
|
-
MINOR =
|
6
|
-
PATCH =
|
5
|
+
MINOR = 11
|
6
|
+
PATCH = 0
|
7
7
|
BUILD = nil
|
8
8
|
STRING = [[MAJOR, MINOR, PATCH].compact.join("."), BUILD].compact.join("-").freeze
|
9
9
|
end
|
data/lib/dawn/api.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'api_spec_helper'
|
2
|
+
|
3
|
+
describe Dawn::Account, :vcr do
|
4
|
+
subject { Dawn::Account }
|
5
|
+
|
6
|
+
it { should be_a Class }
|
7
|
+
|
8
|
+
describe ".current" do
|
9
|
+
it "should retrieve current user account" do
|
10
|
+
Dawn::Account.current
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#update" do
|
15
|
+
subject { Dawn::Account.current }
|
16
|
+
|
17
|
+
it "should update an account" do
|
18
|
+
subject.update(account: { username: "MyNameIs" })
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'api_spec_helper'
|
2
|
+
|
3
|
+
describe Dawn::App::Domains, :vcr do
|
4
|
+
subject { Dawn::App::Domains }
|
5
|
+
|
6
|
+
let(:app) { Dawn::App.find(name: "domains-test") }
|
7
|
+
|
8
|
+
it { should be_a Class }
|
9
|
+
|
10
|
+
###
|
11
|
+
context "#all" do
|
12
|
+
subject { app.domains }
|
13
|
+
|
14
|
+
it "should return all domains" do
|
15
|
+
subject.all
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have only domains" do
|
19
|
+
subject.all.all? { |domain| expect(domain).to be_an_instance_of(Dawn::Domain) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "#create" do
|
24
|
+
subject { app.domains }
|
25
|
+
|
26
|
+
it "should create a new domain" do
|
27
|
+
subject.create(domain: { url: "http://wearepeople.io" })
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'api_spec_helper'
|
2
|
+
|
3
|
+
describe Dawn::App::Drains, :vcr do
|
4
|
+
subject { Dawn::App::Drains }
|
5
|
+
|
6
|
+
let(:app) { Dawn::App.find(name: "drains-test") }
|
7
|
+
|
8
|
+
it { should be_a Class }
|
9
|
+
|
10
|
+
###
|
11
|
+
context "#all" do
|
12
|
+
subject { app.drains }
|
13
|
+
|
14
|
+
it "should return all drains" do
|
15
|
+
subject.all
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have only drains" do
|
19
|
+
subject.all.all? { |drain| expect(drain).to be_an_instance_of(Dawn::Drain) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "#create" do
|
24
|
+
subject { app.drains }
|
25
|
+
|
26
|
+
it "should create a new drain" do
|
27
|
+
subject.create(drain: { url: "http://flush.it" })
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'api_spec_helper'
|
2
|
+
|
3
|
+
describe Dawn::App::Gears, :vcr do
|
4
|
+
subject { Dawn::App::Gears }
|
5
|
+
|
6
|
+
let(:app) { Dawn::App.find(name: "gears-test") }
|
7
|
+
|
8
|
+
it { should be_a Class }
|
9
|
+
|
10
|
+
###
|
11
|
+
context "#all" do
|
12
|
+
subject { app.gears }
|
13
|
+
|
14
|
+
it "should return all gears" do
|
15
|
+
subject.all
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have only gears" do
|
19
|
+
subject.all.all? { |gear| expect(gear).to be_an_instance_of(Dawn::Gear) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "#restart" do
|
24
|
+
subject { app.gears }
|
25
|
+
|
26
|
+
it "should restart all gears" do
|
27
|
+
subject.restart
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "#create" do
|
32
|
+
subject { app.gears }
|
33
|
+
|
34
|
+
it "should create a new gear" do
|
35
|
+
subject.create
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'api_spec_helper'
|
2
|
+
|
3
|
+
describe Dawn::App::Releases, :vcr do
|
4
|
+
subject { Dawn::App::Releases }
|
5
|
+
|
6
|
+
let(:app) { Dawn::App.find(name: "releases-test") }
|
7
|
+
|
8
|
+
it { should be_a Class }
|
9
|
+
|
10
|
+
###
|
11
|
+
context "#all" do
|
12
|
+
subject { app.releases }
|
13
|
+
|
14
|
+
it "should return all releases" do
|
15
|
+
subject.all
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have only releases" do
|
19
|
+
subject.all.all? { |release| expect(release).to be_an_instance_of(Dawn::Release) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "#create" do
|
24
|
+
subject { app.releases }
|
25
|
+
|
26
|
+
it "should create a new release" do
|
27
|
+
subject.create
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'api_spec_helper'
|
2
|
+
|
3
|
+
describe Dawn::App, :vcr do
|
4
|
+
subject { Dawn::App }
|
5
|
+
|
6
|
+
let(:app_name1) { "cookie-crushers" }
|
7
|
+
let(:app_name2) { "cookie-crushers2" }
|
8
|
+
let(:app_name3) { "some-app" }
|
9
|
+
let(:app_name4) { "some-app-thing" }
|
10
|
+
let(:invalid_app_name) { "ThaTunaCorps" }
|
11
|
+
|
12
|
+
let(:app) { Dawn::App.find(name: app_name1) }
|
13
|
+
|
14
|
+
it { should be_a Class }
|
15
|
+
|
16
|
+
describe ".all" do
|
17
|
+
it "should retrieve all user apps" do
|
18
|
+
subject.all
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should only have an array of apps" do
|
22
|
+
subject.all.all? { |o| expect(o).to be_an_instance_of(Dawn::App) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".create" do
|
27
|
+
it "should raise an IndexError if app key is missing" do
|
28
|
+
expect { subject.create(blurp: { name: app_name1 }) }.to raise_error(IndexError)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should create a new app, given a name" do
|
32
|
+
subject.create(app: { name: app_name1 })
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should raise an Excon::Errors::UnprocessableEntity when an invalid name is given" do
|
36
|
+
expect { subject.create(app: { name: invalid_app_name }) }.to raise_error(Excon::Errors::UnprocessableEntity)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe ".find" do
|
41
|
+
it "should retrieve 1 app by id" do
|
42
|
+
app = subject.all.first
|
43
|
+
subject.find(id: app.id)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should retrieve 1 app by name" do
|
47
|
+
subject.find(name: app_name1)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should fail to find a non existant app" do
|
51
|
+
expect { subject.find(id: -1) }.to raise_error(Excon::Errors::NotFound)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe ".update" do
|
56
|
+
it "should raise an IndexError if app key is missing" do
|
57
|
+
expect { subject.update(name: app_name1, blurp: { name: app_name2 }) }.to raise_error(IndexError)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should fail to update non-existant app" do
|
61
|
+
expect { subject.update(name: app_name3, app: { name: app_name4 }) }.to raise_error(Excon::Errors::NotFound)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe ".destroy" do
|
66
|
+
it "should fail to destroy non-existant app" do
|
67
|
+
expect { subject.destroy(name: app_name3) }.to raise_error(Excon::Errors::NotFound)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe ".restart" do
|
72
|
+
it "should fail to restart a non existant app" do
|
73
|
+
expect { subject.restart(id: -1) }.to raise_error(Excon::Errors::NotFound)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe ".logs" do
|
78
|
+
it "should fail to retrieve logs uri for a non existant app" do
|
79
|
+
expect { subject.logs(id: -1) }.to raise_error(Excon::Errors::NotFound)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#restart" do
|
84
|
+
it "should restart the the app" do
|
85
|
+
app.restart
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#logs" do
|
90
|
+
it "should retrieve logs url for app" do
|
91
|
+
app.logs
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "#scale" do
|
96
|
+
it "should raise an IndexError if app key is missing" do
|
97
|
+
expect { app.scale blurp: { formation: { web: 2 } } }.to raise_error(IndexError)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should scale app" do
|
101
|
+
app.scale app: { formation: { web: 2 } }
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should have updated formation" do
|
105
|
+
app.formation["web"].should eq("2")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "#gears" do
|
110
|
+
it "should have gears" do
|
111
|
+
expect(app.gears).to be_an_instance_of(Dawn::App::Gears)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should retrieve gears" do
|
115
|
+
app.gears.all
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should restart gears" do
|
119
|
+
app.gears.restart
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "#drains" do
|
124
|
+
it "should have drains" do
|
125
|
+
expect(app.drains).to be_an_instance_of(Dawn::App::Drains)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should retrieve drains" do
|
129
|
+
app.drains.all
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "#domains" do
|
134
|
+
it "should have domains" do
|
135
|
+
expect(app.domains).to be_an_instance_of(Dawn::App::Domains)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should retrieve domains" do
|
139
|
+
app.domains.all
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "#releases" do
|
144
|
+
it "should have releases" do
|
145
|
+
expect(app.releases).to be_an_instance_of(Dawn::App::Releases)
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should retrieve releases" do
|
149
|
+
app.releases.all
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe "#update" do
|
154
|
+
it "should update 1 app" do
|
155
|
+
app = subject.find(name: "cookie-crushers")
|
156
|
+
app.update(app: { name: "bread-crushers" })
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe "#destroy" do
|
161
|
+
it "should destroy 1 app" do
|
162
|
+
app = subject.find(name: "bread-crushers")
|
163
|
+
app.destroy(name: "bread-crushers")
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'api_spec_helper'
|
2
|
+
|
3
|
+
describe Dawn::Domain, :vcr do
|
4
|
+
subject { Dawn::Domain }
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
$test_store.test_domain_app ||= Dawn::App.find(id: $test_store.ref["apps"]["domain-test"])
|
8
|
+
$test_store.test_domain1 ||= Dawn::Domain.find(id: $test_store.ref["domains"]["cc-rushers.io"])
|
9
|
+
$test_store.test_domain2 ||= Dawn::Domain.find(id: $test_store.ref["domains"]["cookiecrushers.com"])
|
10
|
+
$test_store.test_domain3 ||= Dawn::Domain.find(id: $test_store.ref["domains"]["cookie-crusher.net"])
|
11
|
+
end
|
12
|
+
|
13
|
+
after :all do
|
14
|
+
$test_store.delete_field(:test_domain1) rescue nil
|
15
|
+
$test_store.delete_field(:test_domain2) rescue nil
|
16
|
+
$test_store.delete_field(:test_domain3) rescue nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it { should be_a Class }
|
20
|
+
|
21
|
+
describe ".find" do
|
22
|
+
it "should raise an Excon::Errors::NotFound when Domain cannot be found" do
|
23
|
+
expect { subject.find(id: -1) }.to raise_error(Excon::Errors::NotFound)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should find 1 domain by id" do
|
27
|
+
subject.find(id: $test_store.test_domain1.id)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should find 1 domain by url" do
|
31
|
+
subject.find(url: $test_store.test_domain2.url)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".destroy" do
|
36
|
+
it "should raise an Excon::Errors::NotFound when Domain cannot be found" do
|
37
|
+
expect { subject.destroy(id: -1) }.to raise_error(Excon::Errors::NotFound)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should destroy 1 domain by id" do
|
41
|
+
subject.destroy(id: $test_store.test_domain1.id)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should destroy 1 domain by url" do
|
45
|
+
subject.destroy(url: $test_store.test_domain2.url)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#destroy" do
|
50
|
+
it "should destroy the domain" do
|
51
|
+
$test_store.test_domain3.destroy
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'api_spec_helper'
|
2
|
+
|
3
|
+
describe Dawn::Drain, :vcr do
|
4
|
+
subject { Dawn::Drain }
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
$test_store.test_drain_app ||= Dawn::App.find(id: $test_store.ref["apps"]["drain-test"])
|
8
|
+
$test_store.test_drain1 ||= Dawn::Drain.find(id: $test_store.ref["drains"]["flushme.io"])
|
9
|
+
$test_store.test_drain2 ||= Dawn::Drain.find(id: $test_store.ref["drains"]["toil.com"])
|
10
|
+
$test_store.test_drain3 ||= Dawn::Drain.find(id: $test_store.ref["drains"]["downthedrain.net"])
|
11
|
+
end
|
12
|
+
|
13
|
+
after :all do
|
14
|
+
$test_store.delete_field(:test_drain1) rescue nil
|
15
|
+
$test_store.delete_field(:test_drain2) rescue nil
|
16
|
+
$test_store.delete_field(:test_drain3) rescue nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it { should be_a Class }
|
20
|
+
|
21
|
+
describe ".find" do
|
22
|
+
it "should raise an Excon::Errors::NotFound when Drain cannot be found" do
|
23
|
+
expect { subject.find(id: -1) }.to raise_error(Excon::Errors::NotFound)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should find 1 drain by id" do
|
27
|
+
subject.find id: $test_store.test_drain1.id
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should find 1 drain by url" do
|
31
|
+
subject.find url: $test_store.test_drain2.url
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".destroy" do
|
36
|
+
it "should raise an Excon::Errors::NotFound when Drain cannot be found" do
|
37
|
+
expect { subject.destroy(id: -1) }.to raise_error(Excon::Errors::NotFound)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should destroy 1 drain by id" do
|
41
|
+
subject.destroy(id: $test_store.test_drain1.id)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should destroy 1 drain by url" do
|
45
|
+
subject.destroy(url: $test_store.test_drain2.url)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#destroy" do
|
50
|
+
it "should destroy the drain" do
|
51
|
+
$test_store.test_drain3.destroy
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'api_spec_helper'
|
2
|
+
|
3
|
+
describe Dawn::Gear, :vcr do
|
4
|
+
subject { Dawn::Gear }
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
$test_store.test_gear_app ||= Dawn::App.find(id: $test_store.ref["apps"]["gear-test"])
|
8
|
+
$test_store.test_gear1 ||= Dawn::Gear.find(id: $test_store.ref["gears"][0])
|
9
|
+
$test_store.test_gear2 ||= Dawn::Gear.find(id: $test_store.ref["gears"][1])
|
10
|
+
$test_store.test_gear3 ||= Dawn::Gear.find(id: $test_store.ref["gears"][2])
|
11
|
+
end
|
12
|
+
|
13
|
+
after :all do
|
14
|
+
STDERR.puts "cleaning up"
|
15
|
+
$test_store.delete_field(:test_gear1) rescue nil
|
16
|
+
$test_store.delete_field(:test_gear2) rescue nil
|
17
|
+
$test_store.delete_field(:test_gear3) rescue nil
|
18
|
+
end
|
19
|
+
|
20
|
+
it { should be_a Class }
|
21
|
+
|
22
|
+
describe ".find" do
|
23
|
+
it "should raise an Excon::Errors::NotFound when Gear cannot be found" do
|
24
|
+
expect { subject.find(id: -1) }.to raise_error(Excon::Errors::NotFound)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should find 1 gear by id" do
|
28
|
+
subject.find(id: $test_store.test_gear1.id)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should find 1 gear by url" do
|
32
|
+
subject.find(url: $test_store.test_gear2.url)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe ".destroy" do
|
37
|
+
it "should raise an Excon::Errors::NotFound when Gear cannot be found" do
|
38
|
+
expect { subject.destroy(id: -1) }.to raise_error(Excon::Errors::NotFound)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should destroy 1 gear by id" do
|
42
|
+
subject.destroy(id: $test_store.test_gear1.id)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should destroy 1 gear by url" do
|
46
|
+
subject.destroy(url: $test_store.test_gear2.url)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe ".restart" do
|
51
|
+
it "should restart 1 gear by id" do
|
52
|
+
subject.restart(id: 1)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should 404 if gear does not exist" do
|
56
|
+
expect { subject.restart(id: -1) }.to raise_error(Excon::Errors::NotFound)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#destroy" do
|
61
|
+
it "should destroy the gear" do
|
62
|
+
$test_store.test_gear3.destroy
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|