ey-core 3.4.2 → 3.6.3

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.
Files changed (95) hide show
  1. checksums.yaml +5 -5
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +1 -0
  4. data/CHANGELOG.md +27 -5
  5. data/Gemfile +1 -2
  6. data/README.md +65 -8
  7. data/ey-core.gemspec +6 -5
  8. data/features/docker_registry_credentials.feature +21 -0
  9. data/features/environment_variables.feature +54 -0
  10. data/features/step_definitions/accounts_steps.rb +14 -0
  11. data/features/step_definitions/applications_steps.rb +7 -14
  12. data/features/step_definitions/docker_registry_credentials_steps.rb +3 -0
  13. data/features/step_definitions/environment_variables_steps.rb +51 -0
  14. data/features/step_definitions/environments_steps.rb +15 -0
  15. data/features/support/environment_variable_helpers.rb +20 -0
  16. data/features/support/mock_api.rb +0 -1
  17. data/features/support/resource_helpers.rb +12 -0
  18. data/lib/ey-core/cli/deploy.rb +14 -11
  19. data/lib/ey-core/cli/docker_registry_login.rb +29 -0
  20. data/lib/ey-core/cli/environment_variables.rb +71 -0
  21. data/lib/ey-core/cli/helpers/chef.rb +1 -1
  22. data/lib/ey-core/cli/helpers/core.rb +32 -3
  23. data/lib/ey-core/cli/helpers/server_sieve.rb +7 -0
  24. data/lib/ey-core/cli/main.rb +5 -4
  25. data/lib/ey-core/cli/servers.rb +35 -17
  26. data/lib/ey-core/cli/ssh.rb +7 -1
  27. data/lib/ey-core/client/mock.rb +5 -0
  28. data/lib/ey-core/client.rb +35 -0
  29. data/lib/ey-core/collections/auto_scaling_alarms.rb +8 -0
  30. data/lib/ey-core/collections/auto_scaling_groups.rb +8 -0
  31. data/lib/ey-core/collections/auto_scaling_policies.rb +33 -0
  32. data/lib/ey-core/collections/container_clusters.rb +9 -0
  33. data/lib/ey-core/collections/container_service_deployments.rb +17 -0
  34. data/lib/ey-core/collections/environment_variables.rb +8 -0
  35. data/lib/ey-core/collections/servers.rb +4 -0
  36. data/lib/ey-core/models/account.rb +10 -0
  37. data/lib/ey-core/models/address.rb +2 -0
  38. data/lib/ey-core/models/application.rb +1 -0
  39. data/lib/ey-core/models/auto_scaling_alarm.rb +54 -0
  40. data/lib/ey-core/models/auto_scaling_group.rb +75 -0
  41. data/lib/ey-core/models/base_auto_scaling_policy.rb +61 -0
  42. data/lib/ey-core/models/container_service_deployment.rb +17 -0
  43. data/lib/ey-core/models/deployment.rb +1 -0
  44. data/lib/ey-core/models/environment.rb +57 -45
  45. data/lib/ey-core/models/environment_variable.rb +29 -0
  46. data/lib/ey-core/models/request.rb +6 -0
  47. data/lib/ey-core/models/server.rb +2 -0
  48. data/lib/ey-core/models/simple_auto_scaling_policy.rb +24 -0
  49. data/lib/ey-core/models/step_auto_scaling_policy.rb +24 -0
  50. data/lib/ey-core/models/target_auto_scaling_policy.rb +24 -0
  51. data/lib/ey-core/requests/create_account.rb +5 -0
  52. data/lib/ey-core/requests/create_address.rb +1 -0
  53. data/lib/ey-core/requests/create_application.rb +8 -7
  54. data/lib/ey-core/requests/create_auto_scaling_alarm.rb +69 -0
  55. data/lib/ey-core/requests/create_auto_scaling_group.rb +62 -0
  56. data/lib/ey-core/requests/create_auto_scaling_policy.rb +68 -0
  57. data/lib/ey-core/requests/create_environment.rb +2 -0
  58. data/lib/ey-core/requests/create_environment_variable.rb +39 -0
  59. data/lib/ey-core/requests/create_user.rb +8 -6
  60. data/lib/ey-core/requests/deploy_environment_application.rb +1 -0
  61. data/lib/ey-core/requests/destroy_auto_scaling_alarm.rb +49 -0
  62. data/lib/ey-core/requests/destroy_auto_scaling_group.rb +44 -0
  63. data/lib/ey-core/requests/destroy_auto_scaling_policy.rb +49 -0
  64. data/lib/ey-core/requests/discover_container_service_deployments.rb +71 -0
  65. data/lib/ey-core/requests/discover_server.rb +60 -0
  66. data/lib/ey-core/requests/get_applications.rb +1 -1
  67. data/lib/ey-core/requests/get_auto_scaling_alarm.rb +27 -0
  68. data/lib/ey-core/requests/get_auto_scaling_alarms.rb +34 -0
  69. data/lib/ey-core/requests/get_auto_scaling_group.rb +21 -0
  70. data/lib/ey-core/requests/get_auto_scaling_groups.rb +29 -0
  71. data/lib/ey-core/requests/get_auto_scaling_policies.rb +46 -0
  72. data/lib/ey-core/requests/get_auto_scaling_policy.rb +27 -0
  73. data/lib/ey-core/requests/get_deployments.rb +1 -1
  74. data/lib/ey-core/requests/get_environment_variable.rb +19 -0
  75. data/lib/ey-core/requests/get_environment_variables.rb +29 -0
  76. data/lib/ey-core/requests/get_environments.rb +1 -1
  77. data/lib/ey-core/requests/get_ssl_certificate.rb +1 -1
  78. data/lib/ey-core/requests/retrieve_docker_registry_credentials.rb +24 -0
  79. data/lib/ey-core/requests/update_auto_scaling_alarm.rb +45 -0
  80. data/lib/ey-core/requests/update_auto_scaling_group.rb +45 -0
  81. data/lib/ey-core/requests/update_auto_scaling_policy.rb +46 -0
  82. data/lib/ey-core/requests/update_environment_variable.rb +25 -0
  83. data/lib/ey-core/test_helpers/auto_scaling_helpers.rb +35 -0
  84. data/lib/ey-core/test_helpers.rb +2 -0
  85. data/lib/ey-core/version.rb +1 -1
  86. data/spec/addresses_spec.rb +2 -1
  87. data/spec/auto_scaling_alarms_spec.rb +40 -0
  88. data/spec/auto_scaling_groups_spec.rb +28 -0
  89. data/spec/auto_scaling_policies_spec.rb +94 -0
  90. data/spec/docker_registry_credentials_spec.rb +16 -0
  91. data/spec/environments_spec.rb +18 -0
  92. data/spec/servers_spec.rb +8 -0
  93. data/spec/spec_helper.rb +7 -0
  94. data/spec/support/core.rb +0 -2
  95. metadata +88 -18
@@ -0,0 +1,29 @@
1
+ class Ey::Core::Client
2
+ class Real
3
+ def get_environment_variables(params={})
4
+ query = Ey::Core.paging_parameters(params)
5
+ url = params.delete("url")
6
+
7
+ request(
8
+ :params => params,
9
+ :path => "/environment_variables",
10
+ :query => params,
11
+ :url => url,
12
+ )
13
+ end
14
+ end
15
+
16
+ class Mock
17
+ def get_environment_variables(params={})
18
+ extract_url_params!(params)
19
+
20
+ headers, environment_variables_page = search_and_page(params, :environment_variables, search_keys: %w(environment application))
21
+
22
+ response(
23
+ :body => {"environment_variables" => environment_variables_page},
24
+ :status => 200,
25
+ :headers => headers
26
+ )
27
+ end
28
+ end
29
+ end
@@ -17,7 +17,7 @@ class Ey::Core::Client
17
17
  def get_environments(params={})
18
18
  extract_url_params!(params)
19
19
 
20
- headers, environments_page = search_and_page(params, :environments, search_keys: %w[account name])
20
+ headers, environments_page = search_and_page(params, :environments, search_keys: %w[id account name])
21
21
 
22
22
  response(
23
23
  :body => {"environments" => environments_page},
@@ -5,7 +5,7 @@ class Ey::Core::Client
5
5
  url = params["url"]
6
6
 
7
7
  request(
8
- :path => "ssl_certificates/#{id}",
8
+ :path => "ssl-certificates/#{id}",
9
9
  :url => url,
10
10
  )
11
11
  end
@@ -0,0 +1,24 @@
1
+ class Ey::Core::Client
2
+ class Real
3
+ def retrieve_docker_registry_credentials(account_id, location_id)
4
+ request(
5
+ :path => "/accounts/#{account_id}/docker-registry/#{location_id}/credentials"
6
+ )
7
+ end
8
+ end
9
+
10
+ class Mock
11
+ def retrieve_docker_registry_credentials(account_id, location_id)
12
+ response(
13
+ :body => {
14
+ 'docker_registry_credentials' => {
15
+ 'username' => 'foo',
16
+ 'password' => 'bar',
17
+ 'registry_endpoint' => "https://012345678901.dkr.ecr.#{location_id}.amazonaws.com",
18
+ 'expires_at' => (Time.now + 8 * 3600).to_i
19
+ }
20
+ }
21
+ )
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,45 @@
1
+ class Ey::Core::Client
2
+ class Real
3
+ def update_auto_scaling_alarm(params = {})
4
+ id = params.delete("id")
5
+
6
+ request(
7
+ :method => :put,
8
+ :path => "/auto_scaling_alarms/#{id}",
9
+ :body => { "auto_scaling_alarm" => params.fetch("auto_scaling_alarm") },
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def update_auto_scaling_alarm(params = {})
16
+ resource_id = params.delete("id")
17
+ now = Time.now
18
+ resource = find(:auto_scaling_alarms, resource_id)
19
+ .merge(params["auto_scaling_alarm"])
20
+ .merge("updated_at" => now)
21
+ resource.merge!(params)
22
+
23
+ request = {
24
+ "id" => self.uuid,
25
+ "type" => "update_auto_scaling_alarm",
26
+ "successful" => true,
27
+ "created_at" => now - 5,
28
+ "started_at" => now - 3,
29
+ "finished_at" => now,
30
+ "updated_at" => now,
31
+ "message" => nil,
32
+ "read_channel" => nil,
33
+ "resource" => [:auto_scaling_alarms, resource_id, resource],
34
+ "resource_url" => url_for("/auto_scaling_alarms/#{resource_id}")
35
+ }
36
+
37
+ self.data[:requests][request["id"]] = request
38
+
39
+ response(
40
+ body: { "request" => request },
41
+ status: 200
42
+ )
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,45 @@
1
+ class Ey::Core::Client
2
+ class Real
3
+ def update_auto_scaling_group(params = {})
4
+ id = params.delete("id")
5
+
6
+ request(
7
+ :method => :put,
8
+ :path => "/auto_scaling_groups/#{id}",
9
+ :body => { "auto_scaling_group" => params.fetch("auto_scaling_group") },
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def update_auto_scaling_group(params = {})
16
+ url = params.delete("url")
17
+
18
+ resource_id = params.delete("id")
19
+ resource = find(:auto_scaling_groups, resource_id).merge(params["auto_scaling_group"])
20
+
21
+ now = Time.now
22
+
23
+ request = {
24
+ "id" => self.uuid,
25
+ "type" => "update_auto_scaling_group",
26
+ "successful" => true,
27
+ "created_at" => now - 5,
28
+ "updated_at" => now,
29
+ "started_at" => now - 3,
30
+ "finished_at" => now,
31
+ "message" => nil,
32
+ "read_channel" => nil,
33
+ "resource" => [:auto_scaling_groups, resource_id, resource],
34
+ "resource_url" => url_for("/auto_scaling_groups/#{resource_id}")
35
+ }
36
+
37
+ self.data[:requests][request["id"]] = request
38
+
39
+ response(
40
+ :body => {"request" => request},
41
+ :status => 200
42
+ )
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,46 @@
1
+ class Ey::Core::Client
2
+ class Real
3
+ def update_auto_scaling_policy(params = {})
4
+ id = params.delete("id")
5
+
6
+ request(
7
+ :method => :put,
8
+ :path => "/auto_scaling_policies/#{id}",
9
+ :body => { "auto_scaling_policy" => params.fetch("auto_scaling_policy") },
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def update_auto_scaling_policy(params = {})
16
+ resource_id = params.delete("id")
17
+ now = Time.now
18
+
19
+ resource = find(:auto_scaling_policies, resource_id)
20
+ .merge(params["auto_scaling_policy"])
21
+ .merge("updated_at" => now)
22
+ resource.merge!(params)
23
+
24
+ request = {
25
+ "id" => self.uuid,
26
+ "type" => "update_auto_scaling_policy",
27
+ "successful" => true,
28
+ "created_at" => now - 5,
29
+ "updated_at" => now,
30
+ "started_at" => now - 3,
31
+ "finished_at" => now,
32
+ "message" => nil,
33
+ "read_channel" => nil,
34
+ "resource" => [:auto_scaling_policies, resource_id, resource],
35
+ "resource_url" => url_for("/auto_scaling_policies/#{resource_id}")
36
+ }
37
+
38
+ self.data[:requests][request["id"]] = request
39
+
40
+ response(
41
+ body: { "request" => request },
42
+ status: 200
43
+ )
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,25 @@
1
+ class Ey::Core::Client
2
+ class Real
3
+ def update_environment_variable(_params={})
4
+ params = Cistern::Hash.stringify_keys(_params)
5
+ id = params.delete("id")
6
+ body = { environment_variable: params }
7
+
8
+ request(
9
+ :method => :put,
10
+ :path => "/environment_variables/#{id}",
11
+ :body => body
12
+ )
13
+ end
14
+ end
15
+
16
+ class Mock
17
+ def update_environment_variable(_params={})
18
+ params = Cistern::Hash.stringify_keys(_params).merge!("updated_at" => Time.now)
19
+ environment_variable = find(:environment_variables, params.delete("id"))
20
+ environment_variable.merge!(params)
21
+
22
+ response(:body => { "environment_variable" => environment_variable })
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ module Ey
2
+ module Core
3
+ module TestHelpers
4
+ module AutoScalingHelpers
5
+ def create_auto_scaling_group(options = {})
6
+ environment = options[:environment] || create_environment
7
+
8
+ groups = client.auto_scaling_groups
9
+
10
+ groups.create!(
11
+ minimum_size: 2,
12
+ maximum_size: 6,
13
+ environment: environment
14
+ ).resource!
15
+ end
16
+
17
+ def create_auto_scaling_policy(options = {})
18
+ group = options.delete(:auto_scaling_group) || create_auto_scaling_group
19
+ policies = client.auto_scaling_policies
20
+
21
+ policies.create!(
22
+ {
23
+ auto_scaling_group_id: group.id,
24
+ action_value: 2,
25
+ action_unit: "instances",
26
+ action_type: "add",
27
+ name: SecureRandom.hex(16),
28
+ type: "simple"
29
+ }.merge(options)
30
+ ).resource!
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -2,6 +2,7 @@ require 'ey-core/test_helpers/account_helpers'
2
2
  require 'ey-core/test_helpers/alert_helpers'
3
3
  require 'ey-core/test_helpers/client_helpers'
4
4
  require 'ey-core/test_helpers/resource_helpers'
5
+ require 'ey-core/test_helpers/auto_scaling_helpers'
5
6
 
6
7
  module Ey
7
8
  module Core
@@ -10,6 +11,7 @@ module Ey
10
11
  include AlertHelpers
11
12
  include ClientHelpers
12
13
  include ResourceHelpers
14
+ include AutoScalingHelpers
13
15
  end
14
16
  end
15
17
  end
@@ -1,5 +1,5 @@
1
1
  module Ey
2
2
  module Core
3
- VERSION = "3.4.2"
3
+ VERSION = "3.6.3"
4
4
  end
5
5
  end
@@ -6,12 +6,13 @@ describe 'addresses' do
6
6
  let!(:provider) { create_provider(account: account) }
7
7
 
8
8
  it "creates an address" do
9
- request = client.addresses.create!(provider: provider, location: "us-west-2")
9
+ request = client.addresses.create!(provider: provider, location: "us-west-2", scope: "vpc")
10
10
  address = request.resource!
11
11
  expect(address.id).not_to be_nil
12
12
  expect(address.ip_address).not_to be_nil
13
13
  expect(address.provisioned_id).not_to be_nil
14
14
  expect(address.provider).to eq(provider)
15
+ expect(address.scope).to eq("vpc")
15
16
  end
16
17
 
17
18
  context "with an address" do
@@ -0,0 +1,40 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Auto scaling alarms" do
4
+ let!(:client) { create_client }
5
+ let!(:account) { create_account(client: client) }
6
+ let(:policy) { create_auto_scaling_policy }
7
+
8
+ let(:params) do
9
+ {
10
+ "name" => SecureRandom.hex(16),
11
+ "aggregation_type" => "avg",
12
+ "metric_type" => "cpu",
13
+ "operand" => "gt",
14
+ "trigger_value" => 0.5,
15
+ "number_of_periods" => 1,
16
+ "period_length" => 30,
17
+ "auto_scaling_policy_id" => policy.id
18
+ }
19
+ end
20
+
21
+ let!(:alarm) { client.auto_scaling_alarms.create!(params).resource! }
22
+
23
+ it "creates a new alarm for an auto scaling policy" do
24
+ expect(alarm).not_to be_nil
25
+ expect(policy.auto_scaling_alarms).not_to be_empty
26
+ expect(client.auto_scaling_alarms).not_to be_empty
27
+ end
28
+
29
+ it "updates an alarm" do
30
+ expect do
31
+ alarm.update("name" => "new name")
32
+ end.to change { alarm.name }.to("new name")
33
+ end
34
+
35
+ it "destroys auto scalig alarm by it's id" do
36
+ expect do
37
+ alarm.destroy!
38
+ end.to change { policy.reload.auto_scaling_alarms.count }.from(1).to(0)
39
+ end
40
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'as a user' do
4
+ let!(:client) { create_client }
5
+
6
+ context "with an environment" do
7
+ let!(:account) { create_account(client: client) }
8
+ let!(:provider) { create_provider(account: account) }
9
+ let!(:app) { create_application(account: account, client: client) }
10
+ let!(:environment) { create_environment(client: client, account: account, application: app, configuration: { type: "production"}) }
11
+
12
+ it "adds an auto scaling group" do
13
+ expect {
14
+ client.auto_scaling_groups.create!(minimum_size: 2, maximum_size: 6, environment: environment).resource!
15
+ }.to change { environment.reload.auto_scaling_group }.from(nil).and change { client.auto_scaling_groups.count }.by(1)
16
+ end
17
+
18
+ context "with an auto scaling group" do
19
+ let!(:group) { client.auto_scaling_groups.create!(minimum_size: 2, maximum_size: 6, environment: environment).resource! }
20
+
21
+ it "destroys the auto scaling group" do
22
+ expect {
23
+ group.destroy.ready!
24
+ }.to change { group.reload.deleted_at }.from(nil).and change { client.environments.get(environment.id).auto_scaling_group }.to(nil)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,94 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Auto scaling policies" do
4
+ let!(:client) { create_client }
5
+ let!(:account) { create_account(client: client) }
6
+ let!(:environment) { create_environment(account: account) }
7
+ let(:auto_scaling_group) { create_auto_scaling_group(environment: environment.id) }
8
+ let(:simple_policy_params) do
9
+ {
10
+ name: SecureRandom.hex(16),
11
+ action_value: 2,
12
+ action_type: "add",
13
+ action_unit: "instances",
14
+ auto_scaling_group_id: auto_scaling_group.id,
15
+ type: "simple"
16
+ }
17
+ end
18
+
19
+ describe "common requests for all policy types" do
20
+ let!(:policy) { client.auto_scaling_policies.create!(simple_policy_params).resource! }
21
+
22
+ it "is able to retrieve auto scaling policy by it's id" do
23
+ found_policy = client.auto_scaling_policies.get(policy.id)
24
+ expect(found_policy).not_to be_nil
25
+ expect(found_policy.id).to eq(policy.id)
26
+ end
27
+
28
+ it "updates auto scaling policy" do
29
+ expect do
30
+ policy.update(name: "new name")
31
+ end.to change { policy.name }.to("new name")
32
+ end
33
+
34
+ it "destroys a policy by it's id" do
35
+ expect do
36
+ policy.destroy!
37
+ end.to change { auto_scaling_group.reload.simple_auto_scaling_policies.count }.from(1).to(0)
38
+ end
39
+ end
40
+
41
+ context "simple autoscaling policy" do
42
+ it "adds one to autoscaling group" do
43
+ expect {
44
+ client.auto_scaling_policies.create!(simple_policy_params)
45
+ }.to change { auto_scaling_group.reload.simple_auto_scaling_policies.count }.from(0).to(1)
46
+ .and not_change { auto_scaling_group.reload.step_auto_scaling_policies.count }
47
+ .and not_change { auto_scaling_group.reload.target_auto_scaling_policies.count }
48
+ end
49
+ end
50
+
51
+ context "target tracking auto scaling policy" do
52
+ let(:params) do
53
+ {
54
+ auto_scaling_group_id: auto_scaling_group.id,
55
+ name: SecureRandom.hex(16),
56
+ target_value: 0.7,
57
+ estimated_warmup: 200,
58
+ metric_type: "avg_cup",
59
+ disable_scale_in: false,
60
+ type: "target"
61
+ }
62
+ end
63
+
64
+ it "adds one to autoscaling group" do
65
+ expect {
66
+ client.auto_scaling_policies.create!(params)
67
+ }.to change { auto_scaling_group.reload.target_auto_scaling_policies.count }.from(0).to(1)
68
+ .and not_change { auto_scaling_group.reload.simple_auto_scaling_policies.count }
69
+ .and not_change { auto_scaling_group.reload.step_auto_scaling_policies.count }
70
+ end
71
+ end
72
+
73
+ context "step auto scaling policy" do
74
+ let(:params) do
75
+ {
76
+ auto_scaling_group_id: auto_scaling_group.id,
77
+ name: SecureRandom.hex(16),
78
+ estimated_warmup: 200,
79
+ action_unit: "instances",
80
+ action_type: "add",
81
+ steps: [{ metric_from: 50, metric_to: nil, action_value: 1 }],
82
+ type: "step"
83
+ }
84
+ end
85
+
86
+ it "adds one to autoscaling group" do
87
+ expect {
88
+ client.auto_scaling_policies.create!(params)
89
+ }.to change { auto_scaling_group.reload.step_auto_scaling_policies.count }.from(0).to(1)
90
+ .and not_change { auto_scaling_group.reload.simple_auto_scaling_policies.count }
91
+ .and not_change { auto_scaling_group.reload.target_auto_scaling_policies.count }
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'as a user' do
4
+ let(:client) { create_client }
5
+ let(:location) { 'us-east-1' }
6
+ let!(:account) { create_account(client: client) }
7
+
8
+ it 'returns a valid docker registry credentials' do
9
+ credentials = account.retrieve_docker_registry_credentials(location)
10
+
11
+ expect(credentials.username).to be
12
+ expect(credentials.password).to be
13
+ expect(credentials.registry_endpoint).to match(/#{location}/)
14
+ expect(credentials.expires_at).to be > (Time.now + 6 * 3600).to_i
15
+ end
16
+ end
@@ -173,6 +173,24 @@ describe 'as a user' do
173
173
  expect(account.environments.all.map(&:identity)).to contain_exactly(environment.identity)
174
174
  end
175
175
 
176
+ it 'gets the environment attributes' do
177
+ expect(client.environments.get(environment.id)).to have_attributes(
178
+ "account" => account,
179
+ "classic" => true,
180
+ "custom_recipes" => nil,
181
+ "database_stack" => "postgres9_4",
182
+ "deployments_url" => client.url_for("/environments/#{environment.id}/deployments"),
183
+ "id" => environment.id,
184
+ "keypairs" => environment.keypairs,
185
+ "logical_databases_url" => client.url_for("/environments/#{environment.id}/logical-databases"),
186
+ "release_label" => "stable-v4-2.0.101",
187
+ "servers" => environment.servers,
188
+ "stack_name" => "nginx_passenger4",
189
+ "username" => "deploy",
190
+ "service_level" => "default"
191
+ )
192
+ end
193
+
176
194
  it "adds a keypair" do
177
195
  client.keypairs.create(name: SecureRandom.hex(6), public_key: SSHKey.generate.ssh_public_key)
178
196
  end
data/spec/servers_spec.rb CHANGED
@@ -10,6 +10,14 @@ describe 'servers' do
10
10
  let!(:environment) { create_environment(account: account, application: application, name: Faker::Name.first_name) }
11
11
  let!(:server) { environment.servers.first }
12
12
 
13
+ context "discovering" do
14
+ it "discovers a server that it knows nothing about" do
15
+ expect {
16
+ client.servers.discover(provider: account.providers.first.identity, environment: environment.identity, server: {location: "us-east-1b", provisioned_id: "i-newserver"}).resource!
17
+ }.to change { client.servers.count }.by(1)
18
+ end
19
+ end
20
+
13
21
  context "with a second account" do
14
22
  let(:account2) { create_account(client: client) }
15
23
  let(:app2) { create_application(account: account2) }
data/spec/spec_helper.rb CHANGED
@@ -17,4 +17,11 @@ RSpec.configure do |config|
17
17
  $stdin = STDIN
18
18
  $stderr = STDERR
19
19
  end
20
+
21
+ #
22
+ # This allows to have not_change matcher, i.e.
23
+ #
24
+ # expect { something }.to change { other_thing }
25
+ # .and not_change { completely_other_things }
26
+ RSpec::Matchers.define_negated_matcher :not_change, :change
20
27
  end
data/spec/support/core.rb CHANGED
@@ -1,5 +1,3 @@
1
- Cistern.formatter = Cistern::Formatter::AwesomePrint
2
-
3
1
  if ENV['MOCK_CORE'] == 'true'
4
2
  Ey::Core::Client.mock!
5
3
  end