Clean-up things to make the specs pass again now that most methods are private

This commit is contained in:
R. Tyler Croy 2012-12-09 21:30:36 -08:00
parent 65158b32c3
commit 84f8ede917
3 changed files with 19 additions and 31 deletions

View File

@ -1,9 +0,0 @@
Feature: Display help information
Scenario: Display help
When I run `heroku sauce:help`
Then the output should contain:
"""
Sauce for Heroku Help
"""

View File

@ -8,19 +8,9 @@ require 'yaml'
module Heroku
module Command
class Sauce < BaseWithApp
attr_accessor :config
def index
display 'Lol'
display 'Please run `heroku help sauce` for more details'
end
# sauce:help
#
# Display this help message
def help
display 'Sauce for Heroku Help'
end
# sauce:configure
#
# Configure the Sauce CLI plugin with your username and API key
@ -101,9 +91,6 @@ access_key: #{apikey}
return
end
username = config['username']
apikey = config['access_key']
response = HTTParty.post(scout_url,
:body => {
:os => "Windows 2003",
@ -111,11 +98,13 @@ access_key: #{apikey}
:'browser-version' => '7',
:url => 'http://hello-internet.org'}.to_json,
:basic_auth => {:username => username,
:password => apikey},
:password => access_key},
:headers => {'Content-Type' => 'application/json'})
return unless (response && response.code == 200)
response = JSON.parse(response.body)
if response['embed']
launchy('Firing up Scout in your browser!', response['embed'])
end
@ -123,9 +112,18 @@ access_key: #{apikey}
def scout_url
return nil unless configured?
username = config['username']
"https://saucelabs.com/rest/v1/users/#{username}/scout"
end
def username
return unless configured?
@config['username']
end
def access_key
return unless configured?
@config['access_key']
end
end
end
end

View File

@ -15,7 +15,9 @@ describe Heroku::Command::Sauce do
File.expand_path('~/.sauce/ondemand.yml')).and_return(false)
end
it { command.should_not be_configured }
it 'should return false' do
command.send(:configured?).should_not be_true
end
end
context 'configured with a local ondemand.yml' do
@ -33,7 +35,7 @@ describe Heroku::Command::Sauce do
it { command.should be_configured }
it 'should return the configuration' do
result = command.configured?
result = command.send(:configured?)
result.should be_instance_of(Hash)
expect(result['username']).to eql(config['username'])
@ -44,19 +46,16 @@ describe Heroku::Command::Sauce do
describe '#scoutup!' do
it { should respond_to :scoutup! }
context 'when configured' do
let(:scouturl) { 'http://fakeurl' }
before :each do
command.should_receive(:configured?).and_return(true)
command.stub(:scout_url).and_return(scouturl)
end
it 'should post to Sauce Labs' do
HTTParty.should_receive(:post).with(scouturl,
hash_including(:headers => {'Content-Type' => 'application/json'}))
command.scoutup!
command.send(:scoutup!)
end
end
end