tddium-preview 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tddium.rb +32 -17
- data/lib/tddium/constant.rb +9 -6
- data/lib/tddium/heroku.rb +1 -0
- data/lib/tddium/version.rb +1 -1
- data/spec/tddium_spec.rb +43 -18
- metadata +2 -2
data/lib/tddium.rb
CHANGED
@@ -307,7 +307,7 @@ class Tddium < Thor
|
|
307
307
|
current_suite = call_api(:get, current_suite_path)["suite"]
|
308
308
|
|
309
309
|
say Text::Process::EXISTING_SUITE % format_suite_details(current_suite)
|
310
|
-
|
310
|
+
prompt_update_suite(current_suite, options)
|
311
311
|
else
|
312
312
|
params[:branch] = current_git_branch
|
313
313
|
default_suite_name = File.basename(Dir.pwd)
|
@@ -319,14 +319,9 @@ class Tddium < Thor
|
|
319
319
|
# Write to file and exit when using the existing suite
|
320
320
|
write_suite(existing_suite["id"])
|
321
321
|
say Text::Status::USING_SUITE % format_suite_details(existing_suite)
|
322
|
-
#prompt_update_suite(existing_suite, options)
|
323
322
|
return
|
324
323
|
end
|
325
324
|
|
326
|
-
params[:ruby_version] = dependency_version(:ruby)
|
327
|
-
params[:bundler_version] = dependency_version(:bundle)
|
328
|
-
params[:rubygems_version] = dependency_version(:gem)
|
329
|
-
|
330
325
|
prompt_suite_params(options, params)
|
331
326
|
|
332
327
|
# Create new suite if it does not exist yet
|
@@ -452,6 +447,7 @@ class Tddium < Thor
|
|
452
447
|
say Text::Process::HEROKU_WELCOME % heroku_config['TDDIUM_USER_NAME']
|
453
448
|
|
454
449
|
if user["user"]["heroku_needs_activation"] == true
|
450
|
+
say Text::Process::HEROKU_ACTIVATE
|
455
451
|
params = get_user_credentials(:email => heroku_config['TDDIUM_USER_NAME'])
|
456
452
|
params.delete(:email)
|
457
453
|
params[:password_confirmation] = HighLine.ask(Text::Prompt::PASSWORD_CONFIRMATION) { |q| q.echo = "*" }
|
@@ -494,21 +490,40 @@ class Tddium < Thor
|
|
494
490
|
data
|
495
491
|
end
|
496
492
|
|
497
|
-
def prompt_suite_params(options, params)
|
498
|
-
params[:
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
493
|
+
def prompt_suite_params(options, params, current={})
|
494
|
+
params[:ruby_version] = dependency_version(:ruby)
|
495
|
+
params[:bundler_version] = dependency_version(:bundle)
|
496
|
+
params[:rubygems_version] = dependency_version(:gem)
|
497
|
+
|
498
|
+
ask_or_update = lambda do |key, text, default|
|
499
|
+
params[key] = prompt(text, options[key], current.fetch(key.to_s, default))
|
500
|
+
end
|
501
|
+
|
502
|
+
ask_subsection = lambda do |key, text|
|
503
|
+
current[key.to_s] ||
|
504
|
+
prompt(text, options[key] ? 'y' : nil, 'n') == Text::Prompt::Response::YES
|
505
|
+
end
|
506
|
+
|
507
|
+
ask_or_update.call(:test_pattern, Text::Prompt::TEST_PATTERN, Default::SUITE_TEST_PATTERN)
|
508
|
+
|
509
|
+
if ask_subsection.call(:ci_pull_url, Text::Prompt::ENABLE_CI)
|
510
|
+
ask_or_update.call(:ci_pull_url, Text::Prompt::CI_PULL_URL, nil)
|
511
|
+
ask_or_update.call(:ci_push_url, Text::Prompt::CI_PUSH_URL, nil)
|
512
|
+
if ask_subsection.call(:campfire_subdomain, Text::Prompt::ENABLE_CAMPFIRE)
|
513
|
+
ask_or_update.call(:campfire_subdomain, Text::Prompt::CAMPFIRE_SUBDOMAIN, nil)
|
514
|
+
ask_or_update.call(:campfire_token, Text::Prompt::CAMPFIRE_TOKEN, nil)
|
515
|
+
ask_or_update.call(:campfire_room, Text::Prompt::CAMPFIRE_ROOM, nil)
|
506
516
|
end
|
507
517
|
end
|
508
518
|
end
|
509
519
|
|
510
|
-
def prompt_update_suite(
|
511
|
-
|
520
|
+
def prompt_update_suite(suite, options)
|
521
|
+
if prompt(Text::Prompt::UPDATE_SUITE, nil, 'n') == Text::Prompt::Response::YES
|
522
|
+
params = {}
|
523
|
+
prompt_suite_params(options, params, suite)
|
524
|
+
call_api(:put, "#{Api::Path::SUITES}/#{suite['id']}", params)
|
525
|
+
say Text::Process::UPDATED_SUITE
|
526
|
+
end
|
512
527
|
end
|
513
528
|
|
514
529
|
def resolve_suite_name(options, params, default_suite_name)
|
data/lib/tddium/constant.rb
CHANGED
@@ -60,12 +60,12 @@ module TddiumConstant
|
|
60
60
|
TEST_PATTERN = "Enter a test pattern or press 'Return'. Using '%s' by default:"
|
61
61
|
ENABLE_CI = "Do you want to configure Hosted Continuous Integration?"
|
62
62
|
UPDATE_SUITE = "Do you want to edit settings for this suite?"
|
63
|
-
CI_PULL_URL = "Enter a git URL to pull from:"
|
64
|
-
CI_PUSH_URL = "
|
63
|
+
CI_PULL_URL = "Enter a git URL to pull from (default '%s'):"
|
64
|
+
CI_PUSH_URL = "Push to git URL on tests pass (unset=disable) (default '%s'):"
|
65
65
|
ENABLE_CAMPFIRE = "Setup Campfire CI notifications?"
|
66
|
-
CAMPFIRE_SUBDOMAIN = "Enter your Campfire subdomain:"
|
67
|
-
CAMPFIRE_ROOM = "Enter the Campfire room name:"
|
68
|
-
CAMPFIRE_TOKEN = "Enter your Campfire API Token:"
|
66
|
+
CAMPFIRE_SUBDOMAIN = "Enter your Campfire subdomain (default '%s'):"
|
67
|
+
CAMPFIRE_ROOM = "Enter the Campfire room name (default '%s'):"
|
68
|
+
CAMPFIRE_TOKEN = "Enter your Campfire API Token (default '%s'):"
|
69
69
|
end
|
70
70
|
|
71
71
|
module Process
|
@@ -108,10 +108,13 @@ Thanks for installing the Tddium Heroku Add-On!
|
|
108
108
|
|
109
109
|
Your tddium username is: %s
|
110
110
|
|
111
|
+
"
|
112
|
+
HEROKU_ACTIVATE = "
|
111
113
|
Next, set a password and provide an SSH key to authenticate your communication
|
112
114
|
with Tddium.
|
113
|
-
|
114
115
|
"
|
116
|
+
UPDATED_SUITE = "Updated suite successfully."
|
117
|
+
|
115
118
|
end
|
116
119
|
|
117
120
|
module Status
|
data/lib/tddium/heroku.rb
CHANGED
data/lib/tddium/version.rb
CHANGED
data/spec/tddium_spec.rb
CHANGED
@@ -1324,6 +1324,28 @@ describe Tddium do
|
|
1324
1324
|
tddium.stub(:ask).and_return("")
|
1325
1325
|
end
|
1326
1326
|
|
1327
|
+
shared_examples_for "prompting for suite configuration" do
|
1328
|
+
context "enable ci and campfire" do
|
1329
|
+
before do
|
1330
|
+
tddium.stub(:ask).with(Tddium::Text::Prompt::ENABLE_CI).and_return(Tddium::Text::Prompt::Response::YES)
|
1331
|
+
tddium.stub(:ask).with(Tddium::Text::Prompt::ENABLE_CAMPFIRE).and_return(Tddium::Text::Prompt::Response::YES)
|
1332
|
+
end
|
1333
|
+
|
1334
|
+
it "should prompt for URLs" do
|
1335
|
+
tddium.should_receive(:ask).with(Tddium::Text::Prompt::CI_PULL_URL % current['ci_pull_url'])
|
1336
|
+
tddium.should_receive(:ask).with(Tddium::Text::Prompt::CI_PUSH_URL % current['ci_push_url'])
|
1337
|
+
run_suite(tddium)
|
1338
|
+
end
|
1339
|
+
|
1340
|
+
it "should prompt for campfire" do
|
1341
|
+
tddium.should_receive(:ask).with(Tddium::Text::Prompt::CAMPFIRE_SUBDOMAIN % current['campfire_subdomain'])
|
1342
|
+
tddium.should_receive(:ask).with(Tddium::Text::Prompt::CAMPFIRE_TOKEN % current['campfire_token'])
|
1343
|
+
tddium.should_receive(:ask).with(Tddium::Text::Prompt::CAMPFIRE_ROOM % current['campfire_room'])
|
1344
|
+
run_suite(tddium)
|
1345
|
+
end
|
1346
|
+
end
|
1347
|
+
end
|
1348
|
+
|
1327
1349
|
it_should_behave_like "set the default environment"
|
1328
1350
|
it_should_behave_like "sending the api key"
|
1329
1351
|
it_should_behave_like "git repo has not been initialized"
|
@@ -1497,24 +1519,8 @@ describe Tddium do
|
|
1497
1519
|
end
|
1498
1520
|
end
|
1499
1521
|
|
1500
|
-
|
1501
|
-
|
1502
|
-
tddium.stub(:ask).with(Tddium::Text::Prompt::ENABLE_CI).and_return(Tddium::Text::Prompt::Response::YES)
|
1503
|
-
tddium.stub(:ask).with(Tddium::Text::Prompt::ENABLE_CAMPFIRE).and_return(Tddium::Text::Prompt::Response::YES)
|
1504
|
-
end
|
1505
|
-
|
1506
|
-
it "should prompt for URLs" do
|
1507
|
-
tddium.should_receive(:ask).with(Tddium::Text::Prompt::CI_PULL_URL)
|
1508
|
-
tddium.should_receive(:ask).with(Tddium::Text::Prompt::CI_PUSH_URL)
|
1509
|
-
run_suite(tddium)
|
1510
|
-
end
|
1511
|
-
|
1512
|
-
it "should prompt for campfire" do
|
1513
|
-
tddium.should_receive(:ask).with(Tddium::Text::Prompt::CAMPFIRE_SUBDOMAIN)
|
1514
|
-
tddium.should_receive(:ask).with(Tddium::Text::Prompt::CAMPFIRE_TOKEN)
|
1515
|
-
tddium.should_receive(:ask).with(Tddium::Text::Prompt::CAMPFIRE_ROOM)
|
1516
|
-
run_suite(tddium)
|
1517
|
-
end
|
1522
|
+
it_behaves_like "prompting for suite configuration" do
|
1523
|
+
let(:current) { {} }
|
1518
1524
|
end
|
1519
1525
|
end
|
1520
1526
|
|
@@ -1541,6 +1547,7 @@ describe Tddium do
|
|
1541
1547
|
context "'GET #{Tddium::Api::Path::SUITES}/#{SAMPLE_SUITE_ID}' is successful" do
|
1542
1548
|
before(:each) do
|
1543
1549
|
stub_call_api_response(:get, "#{Tddium::Api::Path::SUITES}/#{SAMPLE_SUITE_ID}", {"suite"=>SAMPLE_SUITE_RESPONSE})
|
1550
|
+
stub_call_api_response(:put, "#{Tddium::Api::Path::SUITES}/#{SAMPLE_SUITE_ID}", {"status"=>0})
|
1544
1551
|
end
|
1545
1552
|
|
1546
1553
|
it "should not ask for a suite name" do
|
@@ -1559,6 +1566,24 @@ describe Tddium do
|
|
1559
1566
|
run_suite(tddium)
|
1560
1567
|
end
|
1561
1568
|
|
1569
|
+
it "should check if the user wants to update the suite" do
|
1570
|
+
tddium.should_receive(:ask).with(Tddium::Text::Prompt::UPDATE_SUITE)
|
1571
|
+
run_suite(tddium)
|
1572
|
+
end
|
1573
|
+
|
1574
|
+
context "user wants to update the suite" do
|
1575
|
+
before(:each) do
|
1576
|
+
tddium.stub(:ask).with(Tddium::Text::Prompt::UPDATE_SUITE).and_return(Tddium::Text::Prompt::Response::YES)
|
1577
|
+
end
|
1578
|
+
it_behaves_like "prompting for suite configuration" do
|
1579
|
+
let(:current) { SAMPLE_SUITE_RESPONSE }
|
1580
|
+
end
|
1581
|
+
it "should PUT to /suites/#{SAMPLE_SUITE_ID}" do
|
1582
|
+
call_api_should_receive(:method=>:put, :path=>"#{Tddium::Api::Path::SUITES}/#{SAMPLE_SUITE_ID}")
|
1583
|
+
run_suite(tddium)
|
1584
|
+
end
|
1585
|
+
end
|
1586
|
+
|
1562
1587
|
it_should_behave_like "sending the api key"
|
1563
1588
|
it_should_behave_like "an unsuccessful api call"
|
1564
1589
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: tddium-preview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.6.
|
5
|
+
version: 0.6.7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Solano Labs
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-17 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|