Start implmenting a `heroku sauce:configure` command

Aruba is nifty
This commit is contained in:
R. Tyler Croy 2012-10-31 22:48:48 -07:00
parent f9a9e856d5
commit ae06bae465
2 changed files with 92 additions and 0 deletions

View File

@ -0,0 +1,50 @@
Feature: Configure the Sauce credentials
In order to get started quickly with the Sauce Heroku CLI
As a heroku user
I should be able to configure my Sauce credentials through the CLI plugin
Scenario: Display configure help
When I run `heroku sauce:configure -h`
Then the output should contain:
"""
Usage: heroku sauce:configure
Configure the Sauce CLI plugin with your username and API key
This command can be used interactively, or all the arguments can be passed on the command line.
Interactively: `heroku sauce:configure`
CLI options:
-u, --user USERNAME # Your Sauce Labs username
-k, --apikey APIKEY # Your Sauce Labs API key
"""
Scenario: Interactive configuration
When I run `heroku sauce:configure` interactively
And I type "cucumber"
And I type "cucumberapikey"
Then the output should contain:
"""
Sauce CLI plugin configured with:
Username: cucumber
API key : cucumberapikey
If you would like to change this later, update "ondemand.yml" in your current directory
"""
And a file named "ondemand.yml" should exist
@wip
Scenario: Interactive configuration without valueis
When I run `heroku sauce:configure` interactively
And I type ""
And I type ""
Then the output should contain:
"""
Whoops! I think you forgot to give me a valid username and API key
"""

View File

@ -11,6 +11,48 @@ module Heroku
def help
display 'Sauce for Heroku Help'
end
# sauce:configure
#
# Configure the Sauce CLI plugin with your username and API key
#
# This command can be used interactively, or all the arguments can be passed on the command line.
#
# Interactively: `heroku sauce:configure`
#
# CLI options:
#
# -u, --user USERNAME # Your Sauce Labs username
# -k, --apikey APIKEY # Your Sauce Labs API key
def configure
username = options[:user]
apikey = options[:apikey]
if username.nil? && apikey.nil?
# Let's go interactive!
display "Sauce username: ", false
username = ask
display "Sauce API key: ", false
apikey = ask
display ''
end
display 'Sauce CLI plugin configured with:'
display ''
display "Username: #{username}"
display "API key : #{apikey}"
display ''
display 'If you would like to change this later, update "ondemand.yml" in your current directory'
File.open('ondemand.yml', 'w+') do |f|
f.write("""
---
username: #{username}
access_key: #{apikey}
""")
end
end
end
end
end