tddium-preview 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +11 -4
- data/bin/tddium +4 -0
- data/features/account_command.feature +5 -0
- data/features/activate_command.feature +91 -0
- data/features/login_command.feature +6 -0
- data/features/step_definitions/account_steps.rb +5 -5
- data/features/step_definitions/activate_steps.rb +7 -0
- data/features/step_definitions/login_steps.rb +4 -4
- data/features/step_definitions/mimic_steps.rb +6 -1
- data/features/step_definitions/suite_steps.rb +12 -3
- data/features/suite_command.feature +30 -6
- data/features/support/mimic.rb +8 -132
- data/lib/tddium.rb +55 -24
- data/lib/tddium/constant.rb +20 -0
- data/lib/tddium/version.rb +1 -1
- data/spec/tddium_spec.rb +0 -237
- metadata +5 -5
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tddium-preview (0.
|
4
|
+
tddium-preview (0.9.0)
|
5
5
|
bundler
|
6
6
|
highline
|
7
7
|
json
|
@@ -12,6 +12,12 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: http://rubygems.org/
|
14
14
|
specs:
|
15
|
+
antilles (0.1.3)
|
16
|
+
bundler
|
17
|
+
daemons
|
18
|
+
httparty
|
19
|
+
json
|
20
|
+
mimic
|
15
21
|
aruba (0.4.6)
|
16
22
|
bcat (>= 0.6.1)
|
17
23
|
childprocess (>= 0.2.0)
|
@@ -34,12 +40,12 @@ GEM
|
|
34
40
|
diff-lcs (1.1.3)
|
35
41
|
fakefs (0.3.2)
|
36
42
|
ffi (1.0.9)
|
37
|
-
gherkin (2.4.
|
43
|
+
gherkin (2.4.21)
|
38
44
|
json (>= 1.4.6)
|
39
45
|
highline (1.6.2)
|
40
46
|
httparty (0.7.8)
|
41
47
|
crack (= 0.1.8)
|
42
|
-
json (1.
|
48
|
+
json (1.6.1)
|
43
49
|
mimic (0.4.3)
|
44
50
|
json
|
45
51
|
plist
|
@@ -69,7 +75,7 @@ GEM
|
|
69
75
|
tddium_client (0.0.10)
|
70
76
|
httparty
|
71
77
|
json
|
72
|
-
tddium_reporting (0.0.
|
78
|
+
tddium_reporting (0.0.4)
|
73
79
|
term-ansicolor (1.0.6)
|
74
80
|
thor (0.14.6)
|
75
81
|
tilt (1.3.3)
|
@@ -78,6 +84,7 @@ PLATFORMS
|
|
78
84
|
ruby
|
79
85
|
|
80
86
|
DEPENDENCIES
|
87
|
+
antilles
|
81
88
|
aruba
|
82
89
|
daemons
|
83
90
|
fakefs
|
data/bin/tddium
CHANGED
@@ -23,6 +23,11 @@ Feature: Account command
|
|
23
23
|
[admin] admin@example.com
|
24
24
|
"""
|
25
25
|
|
26
|
+
Scenario: Fail if user isn't logged in
|
27
|
+
When I run `tddium account`
|
28
|
+
Then the exit status should not be 0
|
29
|
+
And the output should contain "tddium login"
|
30
|
+
|
26
31
|
Scenario: Add member to account successfully
|
27
32
|
Given the user is logged in
|
28
33
|
And adding a member to the account will succeed
|
@@ -0,0 +1,91 @@
|
|
1
|
+
@mimic
|
2
|
+
Feature: Activate command
|
3
|
+
As a Tddium user
|
4
|
+
In order to use an invitation code
|
5
|
+
I want to activate my account and upload an ssh key
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given the command is "tddium activate"
|
9
|
+
|
10
|
+
Scenario: Try to activate when logged in
|
11
|
+
Given the user is logged in
|
12
|
+
When I run `tddium activate`
|
13
|
+
Then the exit status should not be 0
|
14
|
+
And the output should contain "You are logged in."
|
15
|
+
|
16
|
+
Scenario: Activate for the first time
|
17
|
+
Given "abcdef" is a valid invitation token
|
18
|
+
And a file named "ssh_public_key" with:
|
19
|
+
"""
|
20
|
+
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAkbX/gEl+anbWCMG1qbliaIrI2mcoDk0qPkHFnrlHVCn00zFSY8nHzJoTzkCvBW43iPjagfhHz2mYzChXdbNesf2fxxrvXQbDRrpEyQzw42Iak0OiscomVUkVDyG4J+yR2QH8FiIvx9n2Umow1BLCB/b8socBkyJekMk7NzLf+7/RIOWCgdbj2qY3S8uDNzAVse+lpwkClb+dTLIsy8nYQHnKuG9pLNeTwca5Wu+3+BkgS/Ub6H7m1uaeCxnDz6MiN42uWxwAzWHWd3tZO/cVitTgGpGqDut+E0qbUpg+p8/KNQLYRBb2Mm6DhV4bUVGOJ6/s6bgqr/LjB9WFz4Qjww== moorthi@localhost
|
21
|
+
"""
|
22
|
+
When I run `tddium activate` interactively
|
23
|
+
And I respond to "token" with "abcdef"
|
24
|
+
And I respond to "Enter password" with "password"
|
25
|
+
And I respond to "Confirm your password" with "password"
|
26
|
+
And I respond to "Enter your ssh key" with "ssh_public_key"
|
27
|
+
And I respond to "accept the license" with "I AGREE"
|
28
|
+
Then the output from "tddium activate" should contain "Creating account"
|
29
|
+
When the console session ends
|
30
|
+
Then the exit status should be 0
|
31
|
+
|
32
|
+
Scenario: Activate fails with no ssh key
|
33
|
+
Given "abcdef" is a valid invitation token
|
34
|
+
When I run `tddium activate` interactively
|
35
|
+
And I respond to "token" with "abcdef"
|
36
|
+
And I respond to "Enter password" with "password"
|
37
|
+
And I respond to "Confirm your password" with "password"
|
38
|
+
And I respond to "Enter your ssh key" with "ssh_public_key"
|
39
|
+
Then the output from "tddium activate" should contain "not accessible"
|
40
|
+
And the output from "tddium activate" should not contain "accept the license"
|
41
|
+
And the output from "tddium activate" should not contain "Creating account"
|
42
|
+
When the console session ends
|
43
|
+
Then the exit status should not be 0
|
44
|
+
|
45
|
+
Scenario: Activate fails with bad invite token
|
46
|
+
Given "abcdef" is not a valid invitation token
|
47
|
+
And a file named "ssh_public_key" with:
|
48
|
+
"""
|
49
|
+
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAkbX/gEl+anbWCMG1qbliaIrI2mcoDk0qPkHFnrlHVCn00zFSY8nHzJoTzkCvBW43iPjagfhHz2mYzChXdbNesf2fxxrvXQbDRrpEyQzw42Iak0OiscomVUkVDyG4J+yR2QH8FiIvx9n2Umow1BLCB/b8socBkyJekMk7NzLf+7/RIOWCgdbj2qY3S8uDNzAVse+lpwkClb+dTLIsy8nYQHnKuG9pLNeTwca5Wu+3+BkgS/Ub6H7m1uaeCxnDz6MiN42uWxwAzWHWd3tZO/cVitTgGpGqDut+E0qbUpg+p8/KNQLYRBb2Mm6DhV4bUVGOJ6/s6bgqr/LjB9WFz4Qjww== moorthi@localhost
|
50
|
+
"""
|
51
|
+
When I run `tddium activate` interactively
|
52
|
+
And I respond to "token" with "abcdef"
|
53
|
+
And I respond to "Enter password" with "password"
|
54
|
+
And I respond to "Confirm your password" with "password"
|
55
|
+
And I respond to "Enter your ssh key" with "ssh_public_key"
|
56
|
+
And I respond to "accept the license" with "I AGREE"
|
57
|
+
Then the output from "tddium activate" should contain "Creating account"
|
58
|
+
And the output from "tddium activate" should contain "409"
|
59
|
+
When the console session ends
|
60
|
+
Then the exit status should not be 0
|
61
|
+
|
62
|
+
Scenario: Activate fails if license isn't accepted
|
63
|
+
Given "abcdef" is not a valid invitation token
|
64
|
+
And a file named "ssh_public_key" with:
|
65
|
+
"""
|
66
|
+
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAkbX/gEl+anbWCMG1qbliaIrI2mcoDk0qPkHFnrlHVCn00zFSY8nHzJoTzkCvBW43iPjagfhHz2mYzChXdbNesf2fxxrvXQbDRrpEyQzw42Iak0OiscomVUkVDyG4J+yR2QH8FiIvx9n2Umow1BLCB/b8socBkyJekMk7NzLf+7/RIOWCgdbj2qY3S8uDNzAVse+lpwkClb+dTLIsy8nYQHnKuG9pLNeTwca5Wu+3+BkgS/Ub6H7m1uaeCxnDz6MiN42uWxwAzWHWd3tZO/cVitTgGpGqDut+E0qbUpg+p8/KNQLYRBb2Mm6DhV4bUVGOJ6/s6bgqr/LjB9WFz4Qjww== moorthi@localhost
|
67
|
+
"""
|
68
|
+
When I run `tddium activate` interactively
|
69
|
+
And I respond to "token" with "abcdef"
|
70
|
+
And I respond to "Enter password" with "password"
|
71
|
+
And I respond to "Confirm your password" with "password"
|
72
|
+
And I respond to "Enter your ssh key" with "ssh_public_key"
|
73
|
+
And I respond to "accept the license" with "NO WAY"
|
74
|
+
Then the output from "tddium activate" should not contain "Creating account"
|
75
|
+
When the console session ends
|
76
|
+
Then the exit status should not be 0
|
77
|
+
|
78
|
+
Scenario: Activate fails with password mismatch
|
79
|
+
Given "abcdef" is a valid invitation token
|
80
|
+
And a file named "ssh_public_key" with:
|
81
|
+
"""
|
82
|
+
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAkbX/gEl+anbWCMG1qbliaIrI2mcoDk0qPkHFnrlHVCn00zFSY8nHzJoTzkCvBW43iPjagfhHz2mYzChXdbNesf2fxxrvXQbDRrpEyQzw42Iak0OiscomVUkVDyG4J+yR2QH8FiIvx9n2Umow1BLCB/b8socBkyJekMk7NzLf+7/RIOWCgdbj2qY3S8uDNzAVse+lpwkClb+dTLIsy8nYQHnKuG9pLNeTwca5Wu+3+BkgS/Ub6H7m1uaeCxnDz6MiN42uWxwAzWHWd3tZO/cVitTgGpGqDut+E0qbUpg+p8/KNQLYRBb2Mm6DhV4bUVGOJ6/s6bgqr/LjB9WFz4Qjww== moorthi@localhost
|
83
|
+
"""
|
84
|
+
When I run `tddium activate` interactively
|
85
|
+
And I respond to "token" with "abcdef"
|
86
|
+
And I respond to "Enter password" with "password"
|
87
|
+
And I respond to "Confirm your password" with "wordpass"
|
88
|
+
Then the output from "tddium activate" should contain "confirmation incorrect"
|
89
|
+
And the output from "tddium activate" should not contain "Creating account"
|
90
|
+
When the console session ends
|
91
|
+
Then the exit status should not be 0
|
@@ -14,6 +14,12 @@ Feature: Login command
|
|
14
14
|
And the exit status should be 0
|
15
15
|
And dotfiles should be updated
|
16
16
|
|
17
|
+
Scenario: Already logged in
|
18
|
+
Given the user is logged in
|
19
|
+
When I run `tddium login`
|
20
|
+
Then the output should contain "already"
|
21
|
+
And the exit status should be 0
|
22
|
+
|
17
23
|
Scenario: Non-interactively log in successfully
|
18
24
|
Given the user can log in and gets API key "apikey"
|
19
25
|
When I run `tddium login --email=foo@example.com --password=barbarbar`
|
@@ -1,5 +1,5 @@
|
|
1
1
|
Given /^the user has the following memberships in his account:$/ do |table|
|
2
|
-
|
2
|
+
Antilles.install(:get, "/1/memberships", {:status=>0, :memberships=>table.hashes})
|
3
3
|
@memberships = {}
|
4
4
|
table.hashes.each do |row|
|
5
5
|
@memberships[row['email']]=row
|
@@ -7,18 +7,18 @@ Given /^the user has the following memberships in his account:$/ do |table|
|
|
7
7
|
end
|
8
8
|
|
9
9
|
Given /^adding a member to the account will succeed$/ do
|
10
|
-
|
10
|
+
Antilles.install(:post, "/1/memberships", {:status=>0}, :code=>201)
|
11
11
|
end
|
12
12
|
|
13
13
|
Given /^adding a member to the account will fail with error "([^"]*)"$/ do |error|
|
14
|
-
|
14
|
+
Antilles.install(:post, "/1/memberships", {:status=>1, :explanation=>error}, :code=>409)
|
15
15
|
end
|
16
16
|
|
17
17
|
Given /^removing "([^"]*)" from the account will succeed$/ do |member|
|
18
|
-
|
18
|
+
Antilles.install(:delete, "/1/memberships/#{member}", {:status=>0}, :code=>200)
|
19
19
|
end
|
20
20
|
|
21
21
|
Given /^removing "([^"]*)" from the account will fail with error "([^"]*)"$/ do |member, error|
|
22
|
-
|
22
|
+
Antilles.install(:delete, "/1/memberships/#{member}", {:status=>1, :explanation=>error}, :code=>409)
|
23
23
|
end
|
24
24
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Given /^"([^"]*)" is a valid invitation token$/ do |arg1|
|
2
|
+
Antilles.install(:post, "/1/users", SAMPLE_USER_RESPONSE, :code=>201)
|
3
|
+
end
|
4
|
+
|
5
|
+
Given /^"([^"]*)" is not a valid invitation token$/ do |arg1|
|
6
|
+
Antilles.install(:post, "/1/users", {:status=>1, :explanation=>"unrecognized"}, :code=>409)
|
7
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Given /^the user is logged in$/ do
|
2
2
|
@api_key = "abcdef"
|
3
|
-
|
4
|
-
|
3
|
+
Antilles.install(:get, "/1/users", SAMPLE_USER_RESPONSE)
|
4
|
+
Antilles.install(:get, "/1/accounts/usage", SAMPLE_ACCOUNT_USAGE)
|
5
5
|
steps %Q{
|
6
6
|
Given a file named ".tddium.mimic" with:
|
7
7
|
"""
|
@@ -11,11 +11,11 @@ Given /^the user is logged in$/ do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
Given /^the user can log in and gets API key "([^"]*)"$/ do |apikey|
|
14
|
-
|
14
|
+
Antilles.install(:post, "/1/users/sign_in", {:status=>0, :api_key=>apikey})
|
15
15
|
end
|
16
16
|
|
17
17
|
Given /^the user cannot log in$/ do
|
18
|
-
|
18
|
+
Antilles.install(:post, "/1/users/sign_in", {:status=>1, :explanation=>"Access Denied."}, :code=>403)
|
19
19
|
end
|
20
20
|
|
21
21
|
Then /^dotfiles should be updated$/ do
|
@@ -1,6 +1,11 @@
|
|
1
|
+
Given /^the command is "([^"]*)"$/ do |command|
|
2
|
+
@command = command
|
3
|
+
end
|
4
|
+
|
1
5
|
When /^I respond to "([^"]*)" with "([^"]*)"$/ do |expect, response|
|
6
|
+
cmd = @command || "tddium suite"
|
2
7
|
steps %Q{
|
3
|
-
Then the output from "
|
8
|
+
Then the output from "#{cmd}" should contain "#{expect}"
|
4
9
|
When I type "#{response}"
|
5
10
|
}
|
6
11
|
end
|
@@ -7,15 +7,15 @@ def make_suite_response(name, branch)
|
|
7
7
|
end
|
8
8
|
|
9
9
|
Given /^the user has a suite for "([^"]*)" on "([^"]*)"$/ do |name, branch|
|
10
|
-
|
10
|
+
Antilles.install(:get, "/1/suites", {:status=>0, :suites=>[make_suite_response(name, branch)]})
|
11
11
|
end
|
12
12
|
|
13
13
|
Given /^the user has no suites/ do
|
14
|
-
|
14
|
+
Antilles.install(:get, "/1/suites", {:status=>0, :suites=>[]})
|
15
15
|
end
|
16
16
|
|
17
17
|
Given /^the user can create a suite named "([^"]*)" on branch "([^"]*)"$/ do |name, branch|
|
18
|
-
|
18
|
+
Antilles.install(:post, "/1/suites", {:status=>0, :suite=>make_suite_response(name, branch)}, :code=>201)
|
19
19
|
end
|
20
20
|
|
21
21
|
Given /^the destination repo exists$/ do
|
@@ -41,3 +41,12 @@ Given /^a git repo is initialized on branch "([^"]*)"$/ do |branch|
|
|
41
41
|
And I successfully run `git checkout -b #{branch}`
|
42
42
|
}
|
43
43
|
end
|
44
|
+
|
45
|
+
Given /^I choose defaults for test pattern, CI and campfire settings$/ do
|
46
|
+
steps %Q{
|
47
|
+
And I respond to "test pattern" with ""
|
48
|
+
And I respond to "URL to pull from" with "disable"
|
49
|
+
And I respond to "URL to push to" with "disable"
|
50
|
+
And I respond to "Campfire subdomain" with "disable"
|
51
|
+
}
|
52
|
+
end
|
@@ -4,6 +4,9 @@ Feature: suite command
|
|
4
4
|
In order to interact with Tddium
|
5
5
|
I want to configure a test suite
|
6
6
|
|
7
|
+
Background:
|
8
|
+
Given the command is "tddium suite"
|
9
|
+
|
7
10
|
Scenario: Configure a new suite with a complex branch
|
8
11
|
Given the destination repo exists
|
9
12
|
And a git repo is initialized on branch "test/foobar"
|
@@ -11,14 +14,35 @@ Feature: suite command
|
|
11
14
|
And the user has no suites
|
12
15
|
And the user can create a suite named "beta" on branch "test/foobar"
|
13
16
|
When I run `tddium suite` interactively
|
17
|
+
Then the output from "tddium suite" should contain "Looks like"
|
18
|
+
And I respond to "repo name" with "beta"
|
19
|
+
Then the output from "tddium suite" should contain "Detected branch test/foobar"
|
20
|
+
When I choose defaults for test pattern, CI and campfire settings
|
21
|
+
Then the output from "tddium suite" should contain "Created suite..."
|
22
|
+
When the console session ends
|
23
|
+
Then the exit status should be 0
|
24
|
+
|
25
|
+
Scenario: Configure new suite with ruby from tddium.yml
|
26
|
+
Given the destination repo exists
|
27
|
+
And a git repo is initialized on branch "test/foobar"
|
28
|
+
And the user is logged in
|
29
|
+
And the user has no suites
|
30
|
+
And the user can create a suite named "beta" on branch "test/foobar"
|
31
|
+
And a file named "config/tddium.yml" with:
|
32
|
+
"""
|
33
|
+
---
|
34
|
+
:tddium:
|
35
|
+
:ruby_version: ruby-1.9.2-p290-psych
|
36
|
+
"""
|
37
|
+
When I run `tddium suite` interactively
|
38
|
+
Then the output from "tddium suite" should contain "Looks like"
|
14
39
|
And I respond to "repo name" with "beta"
|
15
40
|
Then the output from "tddium suite" should contain "Detected branch test/foobar"
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
And I respond to "Campfire subdomain" with "disable"
|
20
|
-
Then the output from "tddium suite" should contain "Pushing changes to Tddium..."
|
21
|
-
And the output from "tddium suite" should contain "Created suite..."
|
41
|
+
Then the output from "tddium suite" should contain "Configured ruby ruby-1.9.2-p290-psych from tddium.yml"
|
42
|
+
When I choose defaults for test pattern, CI and campfire settings
|
43
|
+
Then the output from "tddium suite" should contain "Created suite..."
|
22
44
|
When the console session ends
|
23
45
|
Then the exit status should be 0
|
24
46
|
|
47
|
+
|
48
|
+
|
data/features/support/mimic.rb
CHANGED
@@ -1,137 +1,13 @@
|
|
1
1
|
# Copyright (c) 2011 Solano Labs All Rights Reserved
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'timeout'
|
5
|
-
require 'daemons'
|
6
|
-
require 'httparty'
|
3
|
+
require 'antilles/cucumber'
|
7
4
|
|
8
|
-
|
9
|
-
|
5
|
+
tid = ENV['TDDIUM_TID'] || 0
|
6
|
+
port = 8500 + tid.to_i
|
7
|
+
ENV['TDDIUM_CLIENT_PORT'] = port.to_s
|
8
|
+
ENV['TDDIUM_CLIENT_ENVIRONMENT'] = 'mimic'
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
@log = log
|
15
|
-
end
|
16
|
-
|
17
|
-
def start
|
18
|
-
pid = Kernel.fork
|
19
|
-
if pid.nil? then
|
20
|
-
args = {:fork => false,
|
21
|
-
:host => 'localhost',
|
22
|
-
:port => @port,
|
23
|
-
:remote_configuration_path => '/api'}
|
24
|
-
args[:log] = @log if @log
|
25
|
-
Mimic.mimic(args) do
|
26
|
-
[:INT, :TERM].each { |sig| trap(sig) { Kernel.exit!(0) } }
|
27
|
-
end
|
28
|
-
Kernel.exit!(0)
|
29
|
-
end
|
30
|
-
@pid_list.push(pid)
|
31
|
-
wait
|
32
|
-
end
|
33
|
-
|
34
|
-
def stop
|
35
|
-
@pid_list.each do |pid|
|
36
|
-
Process.kill("TERM", pid)
|
37
|
-
end
|
38
|
-
@pid_list = []
|
39
|
-
end
|
40
|
-
|
41
|
-
def wait
|
42
|
-
(0...5).each do |i|
|
43
|
-
if ping then
|
44
|
-
break
|
45
|
-
end
|
46
|
-
Kernel.sleep(0.1)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def ping
|
51
|
-
begin
|
52
|
-
http = call_api(:get, '/api/ping')
|
53
|
-
rescue Exception, Timeout::Error
|
54
|
-
return false
|
55
|
-
end
|
56
|
-
return http.code == 200
|
57
|
-
end
|
58
|
-
|
59
|
-
def clear
|
60
|
-
http = call_api(:post, '/api/clear')
|
61
|
-
return http
|
62
|
-
end
|
63
|
-
|
64
|
-
def install(verb, path, body, options={})
|
65
|
-
api_headers = options.delete(:api_headers)
|
66
|
-
params = { 'path' => path, 'body' => body.to_json }.merge(options)
|
67
|
-
http = call_api(:post, "/api/#{verb}", params.to_json, api_headers)
|
68
|
-
return http
|
69
|
-
end
|
70
|
-
|
71
|
-
def call_api(method, path, params = {}, headers = {})
|
72
|
-
tries = 0
|
73
|
-
retries = 7
|
74
|
-
done = false
|
75
|
-
while (tries <= retries) && !done
|
76
|
-
begin
|
77
|
-
http = HTTParty.send(method, "http://localhost:#{@port}#{path}",
|
78
|
-
:body => params, :headers => headers)
|
79
|
-
done = true
|
80
|
-
rescue SystemCallError
|
81
|
-
Kernel.sleep(0.5)
|
82
|
-
rescue Timeout::Error
|
83
|
-
Kernel.sleep(0.5)
|
84
|
-
ensure
|
85
|
-
tries += 1
|
86
|
-
end
|
87
|
-
end
|
88
|
-
raise Timeout::Error if tries > retries && retries >= 0
|
89
|
-
return http
|
90
|
-
end
|
91
|
-
|
92
|
-
class << self
|
93
|
-
def test
|
94
|
-
mimic = MimicServer.start
|
95
|
-
mimic.clear
|
96
|
-
mimic.stop
|
97
|
-
end
|
98
|
-
|
99
|
-
def start(port=nil, log=nil)
|
100
|
-
return @server if @server
|
101
|
-
@server = MimicServer.new(port, log || @log)
|
102
|
-
@server.start
|
103
|
-
@server
|
104
|
-
end
|
105
|
-
|
106
|
-
def server
|
107
|
-
@server
|
108
|
-
end
|
109
|
-
|
110
|
-
def clear
|
111
|
-
@server.clear rescue nil
|
112
|
-
end
|
113
|
-
|
114
|
-
def log=(log)
|
115
|
-
@log = log
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
MimicServer.log = STDOUT
|
121
|
-
|
122
|
-
Before('@mimic') do
|
123
|
-
tid = ENV['TDDIUM_TID'] || 0
|
124
|
-
port = 8500 + tid.to_i
|
125
|
-
ENV['TDDIUM_CLIENT_PORT'] = port.to_s
|
126
|
-
ENV['TDDIUM_CLIENT_ENVIRONMENT'] = 'mimic'
|
127
|
-
MimicServer.start(port)
|
128
|
-
end
|
129
|
-
|
130
|
-
After('@mimic') do
|
131
|
-
MimicServer.clear
|
132
|
-
end
|
133
|
-
|
134
|
-
at_exit do
|
135
|
-
server = MimicServer.server
|
136
|
-
server.stop if server
|
10
|
+
Antilles.configure do |server|
|
11
|
+
server.log = STDOUT
|
12
|
+
server.port = port
|
137
13
|
end
|
data/lib/tddium.rb
CHANGED
@@ -40,16 +40,27 @@ class Tddium < Thor
|
|
40
40
|
class_option :environment, :type => :string, :default => nil
|
41
41
|
class_option :port, :type => :numeric, :default => nil
|
42
42
|
|
43
|
-
desc "account", "View
|
43
|
+
desc "account", "View account information"
|
44
|
+
def account
|
45
|
+
set_shell
|
46
|
+
set_default_environment
|
47
|
+
if user_details = user_logged_in?(true, true)
|
48
|
+
# User is already logged in, so just display the info
|
49
|
+
show_user_details(user_details)
|
50
|
+
else
|
51
|
+
exit_failure Text::Error::USE_ACTIVATE
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "activate", "Activate an account with an invitation token"
|
44
56
|
method_option :email, :type => :string, :default => nil
|
45
57
|
method_option :password, :type => :string, :default => nil
|
46
58
|
method_option :ssh_key_file, :type => :string, :default => nil
|
47
|
-
def
|
59
|
+
def activate
|
48
60
|
set_shell
|
49
61
|
set_default_environment
|
50
62
|
if user_details = user_logged_in?
|
51
|
-
|
52
|
-
show_user_details(user_details)
|
63
|
+
exit_failure Text::Error::ACTIVATE_LOGGED_IN
|
53
64
|
else
|
54
65
|
params = get_user_credentials(options.merge(:invited => true))
|
55
66
|
|
@@ -73,7 +84,7 @@ class Tddium < Thor
|
|
73
84
|
end
|
74
85
|
say content
|
75
86
|
license_accepted = ask(Text::Prompt::LICENSE_AGREEMENT)
|
76
|
-
|
87
|
+
exit_failure unless license_accepted.downcase == Text::Prompt::Response::AGREE_TO_LICENSE.downcase
|
77
88
|
|
78
89
|
begin
|
79
90
|
say Text::Process::STARTING_ACCOUNT_CREATION
|
@@ -86,9 +97,9 @@ class Tddium < Thor
|
|
86
97
|
say Text::Process::ACCOUNT_ADDED % [new_user["user"]["email"], new_user["user"]["account_role"], new_user["user"]["account"]]
|
87
98
|
end
|
88
99
|
rescue TddiumClient::Error::API => e
|
89
|
-
|
100
|
+
exit_failure ((e.status == Api::ErrorCode::INVALID_INVITATION) ? Text::Error::INVALID_INVITATION : e.message)
|
90
101
|
rescue TddiumClient::Error::Base => e
|
91
|
-
say e.message
|
102
|
+
exit_failure say e.message
|
92
103
|
end
|
93
104
|
end
|
94
105
|
end
|
@@ -208,6 +219,9 @@ class Tddium < Thor
|
|
208
219
|
say Text::Process::LOGGED_OUT_SUCCESSFULLY
|
209
220
|
end
|
210
221
|
|
222
|
+
map "cucumber" => :spec
|
223
|
+
map "test" => :spec
|
224
|
+
map "run" => :spec
|
211
225
|
desc "spec", "Run the test suite"
|
212
226
|
method_option :user_data_file, :type => :string, :default => nil
|
213
227
|
method_option :max_parallelism, :type => :numeric, :default => nil
|
@@ -248,7 +262,7 @@ class Tddium < Thor
|
|
248
262
|
suite_details = call_api(:get, current_suite_path)
|
249
263
|
|
250
264
|
# Push the latest code to git
|
251
|
-
exit_failure unless update_git_remote_and_push(suite_details)
|
265
|
+
exit_failure Text::Error::GIT_PUSH_FAILED unless update_git_remote_and_push(suite_details)
|
252
266
|
|
253
267
|
# Create a session
|
254
268
|
new_session = call_api(:post, Api::Path::SESSIONS)
|
@@ -350,7 +364,7 @@ class Tddium < Thor
|
|
350
364
|
end
|
351
365
|
end
|
352
366
|
|
353
|
-
desc "suite", "Register the
|
367
|
+
desc "suite", "Register the current repo/branch, view/edit CI repos & deploy keys"
|
354
368
|
method_option :edit, :type => :boolean, :default => false
|
355
369
|
method_option :name, :type => :string, :default => nil
|
356
370
|
method_option :pull_url, :type => :string, :default => nil
|
@@ -376,6 +390,8 @@ class Tddium < Thor
|
|
376
390
|
default_suite_name = File.basename(Dir.pwd)
|
377
391
|
params[:repo_name] = options[:name] || default_suite_name
|
378
392
|
|
393
|
+
say Text::Process::NO_CONFIGURED_SUITE % [params[:repo_name], params[:branch]]
|
394
|
+
|
379
395
|
use_existing_suite, existing_suite = resolve_suite_name(options, params, default_suite_name)
|
380
396
|
|
381
397
|
if use_existing_suite
|
@@ -397,9 +413,6 @@ class Tddium < Thor
|
|
397
413
|
# Save the created suite
|
398
414
|
write_suite(new_suite["suite"])
|
399
415
|
|
400
|
-
# Manage git
|
401
|
-
exit_failure("Failed to push repo to Tddium!") unless update_git_remote_and_push(new_suite)
|
402
|
-
|
403
416
|
say Text::Process::CREATED_SUITE % format_suite_details(new_suite["suite"])
|
404
417
|
end
|
405
418
|
rescue TddiumClient::Error::Base
|
@@ -465,6 +478,20 @@ class Tddium < Thor
|
|
465
478
|
end
|
466
479
|
end
|
467
480
|
|
481
|
+
def tool_version(tool)
|
482
|
+
key = "#{tool}_version".to_sym
|
483
|
+
result = tddium_config[key]
|
484
|
+
|
485
|
+
if result
|
486
|
+
say Text::Process::CONFIGURED_VERSION % [tool, result]
|
487
|
+
return result
|
488
|
+
end
|
489
|
+
|
490
|
+
result = `#{tool} -v`.strip
|
491
|
+
say Text::Process::DEPENDENCY_VERSION % [tool, result]
|
492
|
+
result
|
493
|
+
end
|
494
|
+
|
468
495
|
def current_git_branch
|
469
496
|
@current_git_branch ||= `git symbolic-ref HEAD`.gsub("\n", "").split("/")[2..-1].join("/")
|
470
497
|
end
|
@@ -483,12 +510,6 @@ class Tddium < Thor
|
|
483
510
|
"#{Api::Path::SUITES}/#{current_suite_id}"
|
484
511
|
end
|
485
512
|
|
486
|
-
def dependency_version(command)
|
487
|
-
result = `#{command} -v`.strip
|
488
|
-
say Text::Process::DEPENDENCY_VERSION % [command, result]
|
489
|
-
result
|
490
|
-
end
|
491
|
-
|
492
513
|
def display_attributes(names_to_display, attributes)
|
493
514
|
names_to_display.each do |attr|
|
494
515
|
say Text::Status::ATTRIBUTE_DETAIL % [attr.gsub("_", " ").capitalize, attributes[attr]] if attributes[attr]
|
@@ -618,7 +639,13 @@ class Tddium < Thor
|
|
618
639
|
def prompt_ssh_key(current)
|
619
640
|
# Prompt for ssh-key file
|
620
641
|
ssh_file = prompt(Text::Prompt::SSH_KEY, options[:ssh_key_file], Default::SSH_FILE)
|
621
|
-
|
642
|
+
|
643
|
+
begin
|
644
|
+
data = File.open(File.expand_path(ssh_file)) {|file| file.read}
|
645
|
+
rescue Errno::ENOENT => e
|
646
|
+
raise TddiumError.new(Text::Error::INACCESSIBLE_SSH_PUBLIC_KEY % [ssh_file, e])
|
647
|
+
end
|
648
|
+
|
622
649
|
if data =~ /^-+BEGIN [DR]SA PRIVATE KEY-+/ then
|
623
650
|
raise TddiumError.new(Text::Error::INVALID_SSH_PUBLIC_KEY % ssh_file)
|
624
651
|
end
|
@@ -630,9 +657,9 @@ class Tddium < Thor
|
|
630
657
|
|
631
658
|
def prompt_suite_params(options, params, current={})
|
632
659
|
say Text::Process::DETECTED_BRANCH % params[:branch] if params[:branch]
|
633
|
-
params[:ruby_version] =
|
634
|
-
params[:bundler_version] =
|
635
|
-
params[:rubygems_version] =
|
660
|
+
params[:ruby_version] = tool_version(:ruby)
|
661
|
+
params[:bundler_version] = tool_version(:bundle)
|
662
|
+
params[:rubygems_version] = tool_version(:gem)
|
636
663
|
|
637
664
|
ask_or_update = lambda do |key, text, default|
|
638
665
|
params[key] = prompt(text, options[key], current.fetch(key.to_s, default))
|
@@ -794,6 +821,10 @@ puts "EXN: #{e.inspect}"
|
|
794
821
|
@tddium_client ||= TddiumClient::Client.new
|
795
822
|
end
|
796
823
|
|
824
|
+
def tddium_config
|
825
|
+
YAML.load(File.read(Config::CONFIG_PATH))[:tddium] rescue {}
|
826
|
+
end
|
827
|
+
|
797
828
|
def tddium_file_name
|
798
829
|
extension = ".#{environment}" unless environment == :production
|
799
830
|
".tddium#{extension}"
|
@@ -803,10 +834,10 @@ puts "EXN: #{e.inspect}"
|
|
803
834
|
options[:fail_with_message] = true unless options[:fail_with_message] == false
|
804
835
|
if @tddium_settings.nil? || options[:force_reload]
|
805
836
|
if File.exists?(tddium_file_name)
|
806
|
-
|
837
|
+
settings_file = File.open(tddium_file_name) do |file|
|
807
838
|
file.read
|
808
839
|
end
|
809
|
-
@tddium_settings = JSON.parse(
|
840
|
+
@tddium_settings = JSON.parse(settings_file) rescue nil
|
810
841
|
say (Text::Error::INVALID_TDDIUM_FILE % environment) if @tddium_settings.nil? && options[:fail_with_message]
|
811
842
|
else
|
812
843
|
say Text::Error::NOT_INITIALIZED if options[:fail_with_message]
|
data/lib/tddium/constant.rb
CHANGED
@@ -15,6 +15,10 @@ module TddiumConstant
|
|
15
15
|
SUITE_TEST_PATTERN = "features/*.feature, spec/**/*_spec.rb, test/**/*_test.rb"
|
16
16
|
end
|
17
17
|
|
18
|
+
module Config
|
19
|
+
CONFIG_PATH = "config/tddium.yml"
|
20
|
+
end
|
21
|
+
|
18
22
|
module Git
|
19
23
|
REMOTE_NAME = "tddium"
|
20
24
|
GITIGNORE = ".gitignore"
|
@@ -74,6 +78,7 @@ module TddiumConstant
|
|
74
78
|
end
|
75
79
|
|
76
80
|
module Process
|
81
|
+
NO_CONFIGURED_SUITE = "Looks like you haven't set up a suite on this computer for %s/%s..."
|
77
82
|
TERMINATE_INSTRUCTION = "Press Ctrl-C to stop waiting. Tests will continue running."
|
78
83
|
INTERRUPT = "Interrupted"
|
79
84
|
GIT_PUSH = "Pushing changes to Tddium..."
|
@@ -134,6 +139,7 @@ with Tddium.
|
|
134
139
|
"
|
135
140
|
UPDATED_SUITE = "Updated suite successfully."
|
136
141
|
DEPENDENCY_VERSION = "Detected %s %s"
|
142
|
+
CONFIGURED_VERSION = "Configured %s %s from tddium.yml"
|
137
143
|
DETECTED_BRANCH = "Detected branch %s"
|
138
144
|
SETUP_CI_FIRST_TIME =<<EOF;
|
139
145
|
|
@@ -295,7 +301,19 @@ EOF
|
|
295
301
|
end
|
296
302
|
|
297
303
|
module Error
|
304
|
+
GIT_PUSH_FAILED = <<EOF;
|
305
|
+
|
306
|
+
The git push to Tddium failed.
|
307
|
+
|
308
|
+
SSH may not be configured to authenticate with the keypair you provided when you set up your account.
|
309
|
+
|
310
|
+
See this URL for SSH configuration instructions:
|
311
|
+
|
312
|
+
https://www.tddium.com/support/faq#othersshkey
|
313
|
+
|
314
|
+
EOF
|
298
315
|
INVALID_SSH_PUBLIC_KEY = '%s does not appear to be a valid SSH public key'
|
316
|
+
INACCESSIBLE_SSH_PUBLIC_KEY = '%s is not accessible: %s'
|
299
317
|
GIT_CHANGES_NOT_COMMITTED =<<EOF
|
300
318
|
There are uncommitted changes in the local git repository.
|
301
319
|
|
@@ -351,6 +369,8 @@ EOF
|
|
351
369
|
end
|
352
370
|
ADD_MEMBER_ERROR = "Error adding %s: %s"
|
353
371
|
REMOVE_MEMBER_ERROR = "Error removing %s: %s"
|
372
|
+
ACTIVATE_LOGGED_IN = "You are logged in. Use 'tddium account' for account information"
|
373
|
+
USE_ACTIVATE = "Use 'tddium activate' to accept an invitation token"
|
354
374
|
end
|
355
375
|
end
|
356
376
|
|
data/lib/tddium/version.rb
CHANGED
data/spec/tddium_spec.rb
CHANGED
@@ -307,23 +307,6 @@ describe Tddium do
|
|
307
307
|
end
|
308
308
|
end
|
309
309
|
|
310
|
-
shared_examples_for "a password prompt" do
|
311
|
-
context "--password was not passed in" do
|
312
|
-
it "should prompt for a password or confirmation" do
|
313
|
-
highline = mock(HighLine)
|
314
|
-
HighLine.should_receive(:ask).with(password_prompt).and_yield(highline)
|
315
|
-
highline.should_receive(:echo=).with("*")
|
316
|
-
run(tddium)
|
317
|
-
end
|
318
|
-
end
|
319
|
-
context "--password was passed in" do
|
320
|
-
it "should not prompt for a password or confirmation" do
|
321
|
-
HighLine.should_not_receive(:ask).with(password_prompt)
|
322
|
-
run(tddium, :password => SAMPLE_PASSWORD)
|
323
|
-
end
|
324
|
-
end
|
325
|
-
end
|
326
|
-
|
327
310
|
shared_examples_for "an unsuccessful api call" do
|
328
311
|
it "should show the error" do
|
329
312
|
tddium_client.stub(:call_api).and_raise(TddiumClient::Error::Base)
|
@@ -508,28 +491,6 @@ describe Tddium do
|
|
508
491
|
end
|
509
492
|
end
|
510
493
|
|
511
|
-
|
512
|
-
shared_examples_for "show account usage" do
|
513
|
-
it "should send a 'GET' request to '#{Tddium::Api::Path::ACCOUNT_USAGE}'" do
|
514
|
-
call_api_should_receive(:method => :get, :path => Tddium::Api::Path::ACCOUNT_USAGE)
|
515
|
-
run(tddium)
|
516
|
-
end
|
517
|
-
|
518
|
-
context "'GET #{Tddium::Api::Path::SUITES}' is successful" do
|
519
|
-
before { stub_call_api_response(:get, Tddium::Api::Path::ACCOUNT_USAGE, {"usage" => "something"}) }
|
520
|
-
|
521
|
-
it "should display the account usage" do
|
522
|
-
tddium.should_receive(:say).with("something")
|
523
|
-
run(tddium)
|
524
|
-
end
|
525
|
-
|
526
|
-
it "should show all suites" do
|
527
|
-
tddium.should_receive(:say).with(Tddium::Text::Status::ALL_SUITES % SAMPLE_APP_NAME)
|
528
|
-
run(tddium)
|
529
|
-
end
|
530
|
-
end
|
531
|
-
end
|
532
|
-
|
533
494
|
describe "#password" do
|
534
495
|
before do
|
535
496
|
stub_defaults
|
@@ -739,204 +700,6 @@ describe Tddium do
|
|
739
700
|
end
|
740
701
|
end
|
741
702
|
|
742
|
-
|
743
|
-
describe "#account" do
|
744
|
-
before do
|
745
|
-
stub_defaults
|
746
|
-
tddium.stub(:ask).and_return("")
|
747
|
-
HighLine.stub(:ask).and_return("")
|
748
|
-
create_file(File.join(File.dirname(__FILE__), "..", Tddium::License::FILE_NAME), SAMPLE_LICENSE_TEXT)
|
749
|
-
create_file(Tddium::Default::SSH_FILE, SAMPLE_SSH_PUBKEY)
|
750
|
-
HerokuConfig.stub(:read_config).and_return(nil)
|
751
|
-
end
|
752
|
-
|
753
|
-
it_should_behave_like "set the default environment"
|
754
|
-
|
755
|
-
context "the user is already logged in" do
|
756
|
-
before do
|
757
|
-
stub_config_file(:api_key => SAMPLE_API_KEY)
|
758
|
-
stub_call_api_response(:get, Tddium::Api::Path::USERS, SAMPLE_USER_RESPONSE)
|
759
|
-
stub_call_api_response(:get, Tddium::Api::Path::SUITES, {"suites" => []})
|
760
|
-
stub_call_api_response(:get, Tddium::Api::Path::ACCOUNT_USAGE, {"usage" => "something"})
|
761
|
-
end
|
762
|
-
|
763
|
-
it "should show the user's email address" do
|
764
|
-
tddium.should_receive(:say).with(/#{SAMPLE_EMAIL}/)
|
765
|
-
run_account(tddium)
|
766
|
-
end
|
767
|
-
|
768
|
-
it "should show the user's account creation date" do
|
769
|
-
tddium.should_receive(:say).with(/#{SAMPLE_DATE_TIME}/)
|
770
|
-
run_account(tddium)
|
771
|
-
end
|
772
|
-
|
773
|
-
it "should show the user's recurly account url" do
|
774
|
-
tddium.should_receive(:say).with(/#{SAMPLE_RECURLY_URL}/)
|
775
|
-
run_account(tddium)
|
776
|
-
end
|
777
|
-
|
778
|
-
# it_should_behave_like "show account usage"
|
779
|
-
end
|
780
|
-
|
781
|
-
context "the user is not already logged in" do
|
782
|
-
let(:call_api_result) {[403, "Forbidden"]}
|
783
|
-
|
784
|
-
it_should_behave_like "a password prompt" do
|
785
|
-
let(:password_prompt) {Tddium::Text::Prompt::PASSWORD_CONFIRMATION}
|
786
|
-
end
|
787
|
-
|
788
|
-
context "the user does not confirm their password correctly" do
|
789
|
-
before {HighLine.stub(:ask).with(Tddium::Text::Prompt::PASSWORD_CONFIRMATION).and_return("wrong confirmation")}
|
790
|
-
it "should tell the user '#{Tddium::Text::Process::PASSWORD_CONFIRMATION_INCORRECT}'" do
|
791
|
-
account_should_fail(tddium) do
|
792
|
-
tddium.should_receive(:exit_failure).with(Tddium::Text::Process::PASSWORD_CONFIRMATION_INCORRECT)
|
793
|
-
end
|
794
|
-
end
|
795
|
-
end
|
796
|
-
|
797
|
-
context "the user confirms their password correctly" do
|
798
|
-
before do
|
799
|
-
HighLine.stub(:ask).with(Tddium::Text::Prompt::PASSWORD).and_return(SAMPLE_PASSWORD)
|
800
|
-
HighLine.stub(:ask).with(Tddium::Text::Prompt::PASSWORD_CONFIRMATION).and_return(SAMPLE_PASSWORD)
|
801
|
-
end
|
802
|
-
|
803
|
-
it_behaves_like "prompt for ssh key"
|
804
|
-
|
805
|
-
it "should show the user the license" do
|
806
|
-
tddium.should_receive(:say).with(SAMPLE_LICENSE_TEXT)
|
807
|
-
run_account(tddium)
|
808
|
-
end
|
809
|
-
|
810
|
-
it "should ask the user to accept the license" do
|
811
|
-
tddium.should_receive(:ask).with(Tddium::Text::Prompt::LICENSE_AGREEMENT)
|
812
|
-
run_account(tddium)
|
813
|
-
end
|
814
|
-
|
815
|
-
context "accepting the license" do
|
816
|
-
before do
|
817
|
-
tddium.stub(:ask).with(Tddium::Text::Prompt::LICENSE_AGREEMENT).and_return(Tddium::Text::Prompt::Response::AGREE_TO_LICENSE)
|
818
|
-
tddium.stub(:ask).with(Tddium::Text::Prompt::INVITATION_TOKEN).and_return(SAMPLE_INVITATION_TOKEN)
|
819
|
-
create_file(Tddium::Default::SSH_FILE, "ssh-rsa 1234")
|
820
|
-
end
|
821
|
-
|
822
|
-
it "should send a 'POST' request to '#{Tddium::Api::Path::USERS}' with the user's invitation token, password and ssh key" do
|
823
|
-
call_api_should_receive(:method => :post, :path => /#{Tddium::Api::Path::USERS}$/, :params => {:user => {:invitation_token => SAMPLE_INVITATION_TOKEN, :password => SAMPLE_PASSWORD, :user_git_pubkey => "ssh-rsa 1234"}}, :api_key => false)
|
824
|
-
run_account(tddium)
|
825
|
-
end
|
826
|
-
|
827
|
-
context "'POST #{Tddium::Api::Path::USERS}' succeeds in creating a new account" do
|
828
|
-
before{stub_call_api_response(:post, Tddium::Api::Path::USERS, SAMPLE_USER_RESPONSE)}
|
829
|
-
|
830
|
-
it_should_behave_like "writing the api key to the .tddium file"
|
831
|
-
|
832
|
-
it "should show the user '#{Tddium::Text::Process::ACCOUNT_CREATED % [SAMPLE_EMAIL, SAMPLE_RECURLY_URL]}'" do
|
833
|
-
tddium.should_receive(:say).with(Tddium::Text::Process::ACCOUNT_CREATED % [SAMPLE_EMAIL, SAMPLE_RECURLY_URL])
|
834
|
-
run_account(tddium)
|
835
|
-
end
|
836
|
-
end
|
837
|
-
|
838
|
-
context "'POST #{Tddium::Api::Path::USERS}' succeeds in adding a new account" do
|
839
|
-
before{stub_call_api_response(:post, Tddium::Api::Path::USERS, SAMPLE_ADDED_USER_RESPONSE)}
|
840
|
-
|
841
|
-
it_should_behave_like "writing the api key to the .tddium file"
|
842
|
-
|
843
|
-
it "should show the user '#{Tddium::Text::Process::ACCOUNT_ADDED % [SAMPLE_EMAIL, SAMPLE_ROLE, SAMPLE_ACCOUNT_NAME]}'" do
|
844
|
-
tddium.should_receive(:say).with(Tddium::Text::Process::ACCOUNT_ADDED % [SAMPLE_EMAIL, SAMPLE_ROLE, SAMPLE_ACCOUNT_NAME])
|
845
|
-
run_account(tddium)
|
846
|
-
end
|
847
|
-
end
|
848
|
-
context "'POST #{Tddium::Api::Path::USERS}' is unsuccessful" do
|
849
|
-
|
850
|
-
it_should_behave_like "an unsuccessful api call"
|
851
|
-
|
852
|
-
context "because the invitation is invalid" do
|
853
|
-
before { stub_call_api_response(:post, Tddium::Api::Path::USERS, {"status" => Tddium::Api::ErrorCode::INVALID_INVITATION}) }
|
854
|
-
it "should show the user: '#{Tddium::Text::Error::INVALID_INVITATION}'" do
|
855
|
-
tddium.should_receive(:say).with(Tddium::Text::Error::INVALID_INVITATION)
|
856
|
-
run_account(tddium)
|
857
|
-
end
|
858
|
-
end
|
859
|
-
end
|
860
|
-
end
|
861
|
-
end
|
862
|
-
end
|
863
|
-
end
|
864
|
-
|
865
|
-
describe "#login" do
|
866
|
-
before do
|
867
|
-
stub_defaults
|
868
|
-
tddium.stub(:ask).and_return("")
|
869
|
-
HighLine.stub(:ask).and_return("")
|
870
|
-
end
|
871
|
-
|
872
|
-
it_should_behave_like "set the default environment"
|
873
|
-
|
874
|
-
context "there is a tddium config file with an api key" do
|
875
|
-
before {stub_config_file(:api_key => "some api key")}
|
876
|
-
|
877
|
-
it "should send a 'GET' request to '#{Tddium::Api::Path::USERS}'" do
|
878
|
-
call_api_should_receive(:method => :get, :path => /#{Tddium::Api::Path::USERS}$/)
|
879
|
-
run(tddium)
|
880
|
-
end
|
881
|
-
end
|
882
|
-
|
883
|
-
context "the tddium config file is missing or corrupt or the api key is invalid" do
|
884
|
-
context "--email was not passed in" do
|
885
|
-
it "should prompt for the user's email address" do
|
886
|
-
tddium.should_receive(:ask).with(Tddium::Text::Prompt::EMAIL)
|
887
|
-
run(tddium)
|
888
|
-
end
|
889
|
-
end
|
890
|
-
|
891
|
-
context "--email was passed in" do
|
892
|
-
it "should not prompt for the user's email address" do
|
893
|
-
tddium.should_not_receive(:ask).with(Tddium::Text::Prompt::EMAIL)
|
894
|
-
run(tddium, :email => SAMPLE_EMAIL)
|
895
|
-
end
|
896
|
-
end
|
897
|
-
|
898
|
-
it_should_behave_like "a password prompt" do
|
899
|
-
let(:password_prompt) {Tddium::Text::Prompt::PASSWORD}
|
900
|
-
end
|
901
|
-
|
902
|
-
it "should try to sign in the user with their email & password" do
|
903
|
-
tddium.stub(:ask).with(Tddium::Text::Prompt::EMAIL).and_return(SAMPLE_EMAIL)
|
904
|
-
HighLine.stub(:ask).with(Tddium::Text::Prompt::PASSWORD).and_return(SAMPLE_PASSWORD)
|
905
|
-
call_api_should_receive(:method => :post, :path => /#{Tddium::Api::Path::SIGN_IN}$/, :params => {:user => {:email => SAMPLE_EMAIL, :password => SAMPLE_PASSWORD}}, :api_key => false)
|
906
|
-
run(tddium)
|
907
|
-
end
|
908
|
-
|
909
|
-
context "the user logs in successfully with their email and password" do
|
910
|
-
before{stub_call_api_response(:post, Tddium::Api::Path::SIGN_IN, {"api_key" => SAMPLE_API_KEY})}
|
911
|
-
it_should_behave_like "writing the api key to the .tddium file"
|
912
|
-
end
|
913
|
-
end
|
914
|
-
|
915
|
-
context "user is already logged in" do
|
916
|
-
before do
|
917
|
-
stub_config_file(:api_key => SAMPLE_API_KEY)
|
918
|
-
stub_call_api_response(:get, Tddium::Api::Path::USERS)
|
919
|
-
end
|
920
|
-
|
921
|
-
it "should show the user: '#{Tddium::Text::Process::ALREADY_LOGGED_IN}'" do
|
922
|
-
tddium.should_receive(:say).with(Tddium::Text::Process::ALREADY_LOGGED_IN)
|
923
|
-
run_login(tddium)
|
924
|
-
end
|
925
|
-
end
|
926
|
-
|
927
|
-
context "the user logs in successfully" do
|
928
|
-
before{ stub_call_api_response(:post, Tddium::Api::Path::SIGN_IN, {"api_key" => SAMPLE_API_KEY})}
|
929
|
-
it "should show the user: '#{Tddium::Text::Process::LOGGED_IN_SUCCESSFULLY}'" do
|
930
|
-
tddium.should_receive(:say).with(Tddium::Text::Process::LOGGED_IN_SUCCESSFULLY)
|
931
|
-
run_login(tddium)
|
932
|
-
end
|
933
|
-
end
|
934
|
-
|
935
|
-
context "the user does not sign in successfully" do
|
936
|
-
it_should_behave_like "an unsuccessful api call"
|
937
|
-
end
|
938
|
-
end
|
939
|
-
|
940
703
|
describe "#spec" do
|
941
704
|
before do
|
942
705
|
stub_defaults
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: tddium-preview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.9.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Solano Labs
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-09-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-09-22 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: thor
|
@@ -152,9 +151,11 @@ files:
|
|
152
151
|
- Rakefile
|
153
152
|
- bin/tddium
|
154
153
|
- features/account_command.feature
|
154
|
+
- features/activate_command.feature
|
155
155
|
- features/login_command.feature
|
156
156
|
- features/logout_command.feature
|
157
157
|
- features/step_definitions/account_steps.rb
|
158
|
+
- features/step_definitions/activate_steps.rb
|
158
159
|
- features/step_definitions/aruba_steps.rb
|
159
160
|
- features/step_definitions/login_steps.rb
|
160
161
|
- features/step_definitions/mimic_steps.rb
|
@@ -172,7 +173,6 @@ files:
|
|
172
173
|
- spec/spec_helper.rb
|
173
174
|
- spec/tddium_spec.rb
|
174
175
|
- tddium.gemspec
|
175
|
-
has_rdoc: true
|
176
176
|
homepage: http://www.tddium.com/
|
177
177
|
licenses: []
|
178
178
|
|
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
196
|
requirements: []
|
197
197
|
|
198
198
|
rubyforge_project: tddium
|
199
|
-
rubygems_version: 1.
|
199
|
+
rubygems_version: 1.8.10
|
200
200
|
signing_key:
|
201
201
|
specification_version: 3
|
202
202
|
summary: tddium Hosted Ruby Testing
|