Skip to content

Commit

Permalink
Merge de73dd1 into d432d1c
Browse files Browse the repository at this point in the history
  • Loading branch information
petems committed Feb 16, 2016
2 parents d432d1c + de73dd1 commit 271c42a
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 8 deletions.
68 changes: 68 additions & 0 deletions features/cassettes/config/Array_of_SSH_Keys_in_Config.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions features/step_definitions/steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'erb'

Given(/^a '\.tugboat' config with data:$/) do |data_str|
data = ERB.new(data_str).result(binding)
File.write("#{Dir.pwd}/tmp/aruba/.tugboat", data)
end
35 changes: 33 additions & 2 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
require 'aruba/cucumber'
require 'aruba/in_process'
require 'aruba/spawn_process'
require 'vcr'
require 'webmock'
require 'tugboat'

Before do
VCR.configure do |c|
c.hook_into :webmock
c.cassette_library_dir = 'features/cassettes'
c.default_cassette_options = { :record => :new_episodes }
end

VCR.cucumber_tags do |t|
t.tag '@vcr', :use_scenario_name => true
end

After do
class VcrFriendlyMain
def initialize(argv, stdin, stdout, stderr, kernel)
@argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
end

def execute!
$stdin = @stdin
$stdout = @stdout
Tugboat::CLI.start(@argv)
end
end

Before('@vcr') do
Aruba::InProcess.main_class = VcrFriendlyMain
Aruba.process = Aruba::InProcess
end

After('@vcr') do
Aruba.process = Aruba::SpawnProcess
$stdin = STDIN
$stdout = STDOUT
VCR.eject_cassette
end
28 changes: 28 additions & 0 deletions features/tugboat/config_array_of_ssh_keys.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Feature: config
In order to have an easier time connecting to droplets
As a user
I should be able to supply an array of ssh keys for a machine

@vcr
Scenario: Array of SSH Keys in Config
Given a '.tugboat' config with data:
"""
---
authentication:
access_token: f8sazukxeh729ggxh9gjavvzw5cabdpq95txpzhz6ep6jvtquxztfkf2chyejcsg5
ssh:
ssh_user: bobby_sousa
ssh_key_path: "~/.ssh/id_rsa"
ssh_port: '22'
defaults:
region: nyc2
image: ubuntu-14-04-x64
size: 512mb
ssh_key: ['1234','5678']
private_networking: 'false'
backups_enabled: 'false'
ip6: 'false'
"""
When I run `tugboat create droplet-with-array-of-keys`
Then the exit status should not be 1
And the output should contain "Queueing creation of droplet 'droplet-with-array-of-keys'...Droplet created!"
2 changes: 1 addition & 1 deletion features/tugboat/config_current_directory.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Feature: config
As a user
I should be able to load tugboat config from a .tugboat in the current directory

Scenario:
Scenario: Read config from current directory
Given a file named ".tugboat" with:
"""
---
Expand Down
9 changes: 5 additions & 4 deletions lib/tugboat/middleware/create_droplet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ def call(env)
droplet_backups_enabled = env["create_droplet_backups_enabled"] :
droplet_backups_enabled = env["config"].default_backups_enabled

droplet_key_array = droplet_ssh_key_ids.split(',')

droplet_key_array = nil if [droplet_key_array].empty?

if droplet_ssh_key_ids.kind_of?(Array)
droplet_key_array = droplet_ssh_key_ids
else
droplet_key_array = droplet_ssh_key_ids.split(',')
end

create_opts = {
:name => env["create_droplet_name"],
Expand Down
3 changes: 2 additions & 1 deletion tugboat.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'simplecov', '0.10'
gem.add_development_dependency 'simplecov-console', '0.2.0'
gem.add_development_dependency 'coveralls', '~> 0.6.7'
gem.add_development_dependency 'aruba', '~> 0.6.2'
gem.add_development_dependency 'aruba', '0.7.4'
gem.add_development_dependency 'pry'
gem.add_development_dependency 'vcr', '2.9.3'

gem.post_install_message = '***************************************'
gem.post_install_message = ' . o .. '
Expand Down

0 comments on commit 271c42a

Please sign in to comment.