module CoreHelper def boot_environment(core_client) account = create_accounts(core_client).first environment = account.environments.create(name: SecureRandom.hex(4)) application = account.applications.create(name: SecureRandom.hex(4)) provider = create_provider(account) cluster = environment.clusters.create(name: SecureRandom.hex(4), location: "us-west-2", provider: provider) app_component = core_client.components.first(name: "default_deployer") www_cluster_component = cluster.cluster_components.create!(component: app_component, configuration: { application: application.id}) cluster.slots.create(quantity: 1) [account, environment, application] end def create_accounts(core_client, quantity: 1) quantity.times.map do |iteration| core_client.accounts.create(name: SecureRandom.hex(4)) end end def create_provider(account) attributes = {type: :aws, provisioned_id: SecureRandom.hex(8)} attributes[:credentials] ||= { :instance_aws_secret_id => SecureRandom.hex(6), :instance_aws_secret_key => SecureRandom.hex(6), :aws_secret_id => SecureRandom.hex(6), :aws_secret_key => SecureRandom.hex(6), :aws_login => FFaker::Internet.email, :aws_pass => SecureRandom.hex(6), } account.providers.create!(attributes).resource! end def create_core_credentials subject.class.core_file = @tempfile allow(subject).to receive(:ask) { FFaker::Internet.email } output = capture(:stdout) { subject.login } expect(read_yaml(@tempfile)).to have_key("https://api.engineyard.com/") end end RSpec.configure do |config| config.include(CoreHelper) end