tddium-preview 0.6.8 → 0.6.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tddium-preview (0.6.7)
4
+ tddium-preview (0.6.9)
5
5
  bundler
6
6
  highline
7
7
  json
data/lib/tddium.rb CHANGED
@@ -13,7 +13,7 @@ require File.expand_path("../tddium/constant", __FILE__)
13
13
  require File.expand_path("../tddium/heroku", __FILE__)
14
14
 
15
15
  # Usage:
16
- #
16
+
17
17
  # tddium suite # Register the suite for this rails app, or manage its settings
18
18
  # tddium spec # Run the test suite
19
19
  # tddium status # Display information about this suite, and any open dev sessions
@@ -22,7 +22,7 @@ require File.expand_path("../tddium/heroku", __FILE__)
22
22
  # tddium logout # Log out
23
23
  #
24
24
  # tddium account # View/Manage account information
25
- # tddium account:password # Change password
25
+ # tddium password # Change password
26
26
  #
27
27
  # tddium help # Print this usage message
28
28
 
@@ -291,7 +291,7 @@ class Tddium < Thor
291
291
  end
292
292
  end
293
293
 
294
- desc "suite", "Register the suite for this project, or manage its settings"
294
+ desc "suite", "Register the suite for this project, or edit its settings"
295
295
  method_option :name, :type => :string, :default => nil
296
296
  method_option :pull_url, :type => :string, :default => nil
297
297
  method_option :push_url, :type => :string, :default => nil
@@ -435,13 +435,22 @@ class Tddium < Thor
435
435
  end
436
436
 
437
437
  def git_repo?
438
- unless File.exists?(".git")
438
+ unless system("git status --porcelain > /dev/null 2>&1")
439
439
  message = Text::Error::GIT_NOT_INITIALIZED
440
440
  say message
441
441
  end
442
442
  message.nil?
443
443
  end
444
444
 
445
+ def git_origin_url
446
+ result = `git config --get remote.origin.url`
447
+ if $? == 0
448
+ result
449
+ else
450
+ nil
451
+ end
452
+ end
453
+
445
454
  def handle_heroku_user(options, heroku_config)
446
455
  api_key = heroku_config['TDDIUM_API_KEY']
447
456
  user = tddium_client.call_api(:get, Api::Path::USERS, {}, api_key) rescue nil
@@ -481,7 +490,7 @@ class Tddium < Thor
481
490
  end
482
491
 
483
492
  def prompt(text, current_value, default_value)
484
- value = current_value || ask(text % default_value)
493
+ value = current_value || ask(text % default_value, :bold)
485
494
  value.empty? ? default_value : value
486
495
  end
487
496
 
@@ -501,22 +510,26 @@ class Tddium < Thor
501
510
  params[key] = prompt(text, options[key], current.fetch(key.to_s, default))
502
511
  end
503
512
 
504
- ask_subsection = lambda do |key, text|
505
- current[key.to_s] ||
506
- prompt(text, options[key] ? 'y' : nil, 'n') == Text::Prompt::Response::YES
513
+ ask_or_update.call(:test_pattern, Text::Prompt::TEST_PATTERN, Default::SUITE_TEST_PATTERN)
514
+
515
+ if current.size > 0 && current['ci_pull_url']
516
+ say(Text::Process::SETUP_CI_EDIT)
517
+ else
518
+ say(Text::Process::SETUP_CI_FIRST_TIME % params[:test_pattern])
507
519
  end
508
520
 
509
- ask_or_update.call(:test_pattern, Text::Prompt::TEST_PATTERN, Default::SUITE_TEST_PATTERN)
521
+ ask_or_update.call(:ci_pull_url, Text::Prompt::CI_PULL_URL, git_origin_url)
522
+ ask_or_update.call(:ci_push_url, Text::Prompt::CI_PUSH_URL, nil)
510
523
 
511
- if ask_subsection.call(:ci_pull_url, Text::Prompt::ENABLE_CI)
512
- ask_or_update.call(:ci_pull_url, Text::Prompt::CI_PULL_URL, nil)
513
- ask_or_update.call(:ci_push_url, Text::Prompt::CI_PUSH_URL, nil)
514
- if ask_subsection.call(:campfire_subdomain, Text::Prompt::ENABLE_CAMPFIRE)
515
- ask_or_update.call(:campfire_subdomain, Text::Prompt::CAMPFIRE_SUBDOMAIN, nil)
516
- ask_or_update.call(:campfire_token, Text::Prompt::CAMPFIRE_TOKEN, nil)
517
- ask_or_update.call(:campfire_room, Text::Prompt::CAMPFIRE_ROOM, nil)
518
- end
524
+ if current.size > 0 && current['campfire_room']
525
+ say(Text::Process::SETUP_CAMPFIRE_EDIT)
526
+ else
527
+ say(Text::Process::SETUP_CAMPFIRE_FIRST_TIME)
519
528
  end
529
+
530
+ ask_or_update.call(:campfire_subdomain, Text::Prompt::CAMPFIRE_SUBDOMAIN, nil)
531
+ ask_or_update.call(:campfire_token, Text::Prompt::CAMPFIRE_TOKEN, nil)
532
+ ask_or_update.call(:campfire_room, Text::Prompt::CAMPFIRE_ROOM, nil)
520
533
  end
521
534
 
522
535
  def prompt_update_suite(suite, options)
@@ -46,6 +46,7 @@ module TddiumConstant
46
46
  module Response
47
47
  AGREE_TO_LICENSE = "I AGREE"
48
48
  YES = "y"
49
+ DISABLE = 'disable'
49
50
  end
50
51
  SSH_KEY = "Enter your ssh key or press 'Return'. Using '%s' by default:"
51
52
  SUITE_NAME = "Enter a suite name or press 'Return'. Using '%s' by default:"
@@ -58,11 +59,9 @@ module TddiumConstant
58
59
  INVITATION_TOKEN = "Enter your invitation token:"
59
60
  USE_EXISTING_SUITE = "A suite exists '%%s' (branch %s). Enter '#{Response::YES}' to use it, or enter a new repo name:"
60
61
  TEST_PATTERN = "Enter a test pattern or press 'Return'. Using '%s' by default:"
61
- ENABLE_CI = "Do you want to configure Hosted Continuous Integration?"
62
- UPDATE_SUITE = "Do you want to edit settings for this suite?"
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
- ENABLE_CAMPFIRE = "Setup Campfire CI notifications?"
62
+ UPDATE_SUITE = "Do you want to edit settings for this suite? (y/n)"
63
+ CI_PULL_URL = "Enter git URL to pull from (default '%s'):"
64
+ CI_PUSH_URL = "Enter git URL to push to (default '%s'):"
66
65
  CAMPFIRE_SUBDOMAIN = "Enter your Campfire subdomain (default '%s'):"
67
66
  CAMPFIRE_ROOM = "Enter the Campfire room name (default '%s'):"
68
67
  CAMPFIRE_TOKEN = "Enter your Campfire API Token (default '%s'):"
@@ -115,6 +114,54 @@ with Tddium.
115
114
  "
116
115
  UPDATED_SUITE = "Updated suite successfully."
117
116
  DEPENDENCY_VERSION = "Detected %s %s"
117
+ SETUP_CI_FIRST_TIME =<<EOF;
118
+
119
+ Tddium Hosted CI will wait for a POST from a git post-receive hook.
120
+
121
+ When the hook runs, Tddium will:
122
+
123
+ 1) Pull your integration branch from your git server (pull from URL)
124
+ 2) Run all the tests that match the test pattern for this suite:
125
+ %s
126
+ 3) Notify you by email and/or campfire
127
+ 4) If you want, when tests pass, Tddium CI will then push to a git
128
+ server (push to URL). For example, enter the git URL to your
129
+ Heroku staging app.
130
+
131
+ Enter a git URL to pull from to enable hosted CI.
132
+
133
+ When everything's been set up, you'll receive an SSH public key to authorize in
134
+ git for pulls and pushes, and a Hook URL to configure in a post-commit hook.
135
+
136
+ Leave both the pull and push URL settings blank to disable hosted CI.
137
+ EOF
138
+ SETUP_CAMPFIRE_FIRST_TIME =<<EOF;
139
+
140
+ To enable Campfire notifications, enter your Campfire subdomain, API token,
141
+ and the room name to post for this suite's builds.
142
+
143
+ Subdomain and API token are shared by all suites that belong to you (%s).
144
+
145
+ Leave the Campfire room name blank to disable Campfire for this suite.
146
+
147
+ EOF
148
+
149
+ SETUP_CI_EDIT =<<EOF;
150
+
151
+ Tddium Hosted CI is enabled for this suite.
152
+
153
+ Set the "git URL to pull from" to 'disable' to disable CI completely.
154
+ Set the "git URL to push to" to 'disable' to disable CI completely.
155
+
156
+ EOF
157
+ SETUP_CAMPFIRE_EDIT =<<EOF;
158
+
159
+ Campfire notifications are enabled for this suite.
160
+ Subdomain and API token are shared by all suites that belong to you (%s).
161
+
162
+ Set the "Campfire room name" to 'disable' to disable Campfire notifications
163
+ for this suite.
164
+ EOF
118
165
  end
119
166
 
120
167
  module Status
@@ -174,6 +221,8 @@ Authorize the following SSH key to let Tddium's pulls and pushes through:
174
221
  To trigger CI builds, POST to the following URL from a post-commit hook:
175
222
 
176
223
  <%=suite["hook_uri"]%>
224
+
225
+ See www.tddium.com/support for more information.
177
226
  <% end %>
178
227
  EOF
179
228
  end
@@ -3,5 +3,5 @@ Copyright (c) 2011 Solano Labs All Rights Reserved
3
3
  =end
4
4
 
5
5
  module TddiumVersion
6
- VERSION = "0.6.8"
6
+ VERSION = "0.6.10"
7
7
  end
data/spec/tddium_spec.rb CHANGED
@@ -174,6 +174,8 @@ describe Tddium do
174
174
  tddium.stub(:say)
175
175
  stub_git_branch(tddium)
176
176
  stub_tddium_client
177
+ stub_git_status(tddium)
178
+ stub_git_config(tddium)
177
179
  create_file(File.join(".git", "something"), "something")
178
180
  create_file(Tddium::Git::GITIGNORE, "something")
179
181
  end
@@ -182,6 +184,14 @@ describe Tddium do
182
184
  tddium.stub(:`).with("git symbolic-ref HEAD").and_return(default_branch_name)
183
185
  end
184
186
 
187
+ def stub_git_status(tddium, result=true)
188
+ tddium.stub(:system).with(/git status/).and_return(result)
189
+ end
190
+
191
+ def stub_git_config(tddium)
192
+ tddium.stub(:`).with(/git config/).and_return(SAMPLE_GIT_REPO_URI)
193
+ end
194
+
185
195
  def stub_git_push(tddium, success = true)
186
196
  tddium.stub(:system).with(/^git push/).and_return(success)
187
197
  end
@@ -247,6 +257,7 @@ describe Tddium do
247
257
  context "git repo has not been initialized" do
248
258
  before do
249
259
  FileUtils.rm_rf(".git")
260
+ stub_git_status(tddium, false)
250
261
  end
251
262
 
252
263
  it "should return git is uninitialized" do
@@ -492,14 +503,14 @@ describe Tddium do
492
503
  shared_examples_for "prompt for ssh key" do
493
504
  context "--ssh-key-file is not supplied" do
494
505
  it "should prompt the user for their ssh key file" do
495
- tddium.should_receive(:ask).with(Tddium::Text::Prompt::SSH_KEY % Tddium::Default::SSH_FILE)
506
+ tddium.should_receive(:ask).with(Tddium::Text::Prompt::SSH_KEY % Tddium::Default::SSH_FILE, anything)
496
507
  run(tddium)
497
508
  end
498
509
  end
499
510
 
500
511
  context "--ssh-key-file is supplied" do
501
512
  it "should not prompt the user for their ssh key file" do
502
- tddium.should_not_receive(:ask).with(Tddium::Text::Prompt::SSH_KEY % Tddium::Default::SSH_FILE)
513
+ tddium.should_not_receive(:ask).with(Tddium::Text::Prompt::SSH_KEY % Tddium::Default::SSH_FILE, anything)
503
514
  run(tddium, :ssh_key_file => Tddium::Default::SSH_FILE)
504
515
  end
505
516
  end
@@ -1327,24 +1338,17 @@ describe Tddium do
1327
1338
  end
1328
1339
 
1329
1340
  shared_examples_for "prompting for suite configuration" do
1330
- context "enable ci and campfire" do
1331
- before do
1332
- tddium.stub(:ask).with(Tddium::Text::Prompt::ENABLE_CI).and_return(Tddium::Text::Prompt::Response::YES)
1333
- tddium.stub(:ask).with(Tddium::Text::Prompt::ENABLE_CAMPFIRE).and_return(Tddium::Text::Prompt::Response::YES)
1334
- end
1335
-
1336
- it "should prompt for URLs" do
1337
- tddium.should_receive(:ask).with(Tddium::Text::Prompt::CI_PULL_URL % current['ci_pull_url'])
1338
- tddium.should_receive(:ask).with(Tddium::Text::Prompt::CI_PUSH_URL % current['ci_push_url'])
1339
- run_suite(tddium)
1340
- end
1341
+ it "should prompt for URLs" do
1342
+ tddium.should_receive(:ask).with(Tddium::Text::Prompt::CI_PULL_URL % current.fetch('ci_pull_url', SAMPLE_GIT_REPO_URI), anything)
1343
+ tddium.should_receive(:ask).with(Tddium::Text::Prompt::CI_PUSH_URL % current['ci_push_url'], anything)
1344
+ run_suite(tddium)
1345
+ end
1341
1346
 
1342
- it "should prompt for campfire" do
1343
- tddium.should_receive(:ask).with(Tddium::Text::Prompt::CAMPFIRE_SUBDOMAIN % current['campfire_subdomain'])
1344
- tddium.should_receive(:ask).with(Tddium::Text::Prompt::CAMPFIRE_TOKEN % current['campfire_token'])
1345
- tddium.should_receive(:ask).with(Tddium::Text::Prompt::CAMPFIRE_ROOM % current['campfire_room'])
1346
- run_suite(tddium)
1347
- end
1347
+ it "should prompt for campfire" do
1348
+ tddium.should_receive(:ask).with(Tddium::Text::Prompt::CAMPFIRE_SUBDOMAIN % current['campfire_subdomain'], anything)
1349
+ tddium.should_receive(:ask).with(Tddium::Text::Prompt::CAMPFIRE_TOKEN % current['campfire_token'], anything)
1350
+ tddium.should_receive(:ask).with(Tddium::Text::Prompt::CAMPFIRE_ROOM % current['campfire_room'], anything)
1351
+ run_suite(tddium)
1348
1352
  end
1349
1353
  end
1350
1354
 
@@ -1381,10 +1385,10 @@ describe Tddium do
1381
1385
  end
1382
1386
 
1383
1387
  context "interactive mode" do
1384
- before { tddium.stub(:ask).with(Tddium::Text::Prompt::SUITE_NAME % SAMPLE_APP_NAME).and_return("some_other_suite") }
1388
+ before { tddium.stub(:ask).with(Tddium::Text::Prompt::SUITE_NAME % SAMPLE_APP_NAME, anything).and_return("some_other_suite") }
1385
1389
 
1386
1390
  it "should ask for a suite name" do
1387
- tddium.should_receive(:ask).with(Tddium::Text::Prompt::SUITE_NAME % SAMPLE_APP_NAME)
1391
+ tddium.should_receive(:ask).with(Tddium::Text::Prompt::SUITE_NAME % SAMPLE_APP_NAME, anything)
1388
1392
  run_suite(tddium)
1389
1393
  end
1390
1394
 
@@ -1404,7 +1408,7 @@ describe Tddium do
1404
1408
  context "but this user has already registered some suites" do
1405
1409
  before do
1406
1410
  stub_call_api_response(:get, Tddium::Api::Path::SUITES, SAMPLE_SUITES_RESPONSE, {"suites" => []})
1407
- tddium.stub(:ask).with(Tddium::Text::Prompt::USE_EXISTING_SUITE % SAMPLE_BRANCH_NAME % SAMPLE_APP_NAME).and_return(Tddium::Text::Prompt::Response::YES)
1411
+ tddium.stub(:ask).with(Tddium::Text::Prompt::USE_EXISTING_SUITE % SAMPLE_BRANCH_NAME % SAMPLE_APP_NAME, anything).and_return(Tddium::Text::Prompt::Response::YES)
1408
1412
  end
1409
1413
 
1410
1414
  shared_examples_for "writing the suite to file" do
@@ -1431,7 +1435,7 @@ describe Tddium do
1431
1435
 
1432
1436
  context "passing no cli options" do
1433
1437
  it "should ask the user: '#{Tddium::Text::Prompt::USE_EXISTING_SUITE % SAMPLE_BRANCH_NAME % SAMPLE_APP_NAME}' " do
1434
- tddium.should_receive(:ask).with(Tddium::Text::Prompt::USE_EXISTING_SUITE % SAMPLE_BRANCH_NAME % SAMPLE_APP_NAME).and_return("something")
1438
+ tddium.should_receive(:ask).with(Tddium::Text::Prompt::USE_EXISTING_SUITE % SAMPLE_BRANCH_NAME % SAMPLE_APP_NAME, anything).and_return("something")
1435
1439
  run_suite(tddium)
1436
1440
  end
1437
1441
  end
@@ -1442,7 +1446,7 @@ describe Tddium do
1442
1446
  end
1443
1447
 
1444
1448
  it "should not ask the user if they want to use the existing suite" do
1445
- tddium_client.should_not_receive(:ask).with(Tddium::Text::Prompt::USE_EXISTING_SUITE % "my_suite")
1449
+ tddium_client.should_not_receive(:ask).with(Tddium::Text::Prompt::USE_EXISTING_SUITE % "my_suite", anything)
1446
1450
  run_suite(tddium, :name => "my_suite")
1447
1451
  end
1448
1452
 
@@ -1474,7 +1478,7 @@ describe Tddium do
1474
1478
  end
1475
1479
 
1476
1480
  context "the user does not want to use the existing suite" do
1477
- before{ tddium.stub(:ask).with(Tddium::Text::Prompt::USE_EXISTING_SUITE % SAMPLE_BRANCH_NAME % SAMPLE_APP_NAME).and_return("some_other_suite") }
1481
+ before{ tddium.stub(:ask).with(Tddium::Text::Prompt::USE_EXISTING_SUITE % SAMPLE_BRANCH_NAME % SAMPLE_APP_NAME, anything).and_return("some_other_suite") }
1478
1482
 
1479
1483
 
1480
1484
  it "should send a 'POST' request to '#{Tddium::Api::Path::SUITES}'" do
@@ -1508,8 +1512,8 @@ describe Tddium do
1508
1512
 
1509
1513
  context "interactive mode" do
1510
1514
  before do
1511
- tddium.stub(:ask).with(Tddium::Text::Prompt::USE_EXISTING_SUITE % SAMPLE_BRANCH_NAME % SAMPLE_APP_NAME).and_return("foobar")
1512
- tddium.stub(:ask).with(Tddium::Text::Prompt::TEST_PATTERN % Tddium::Default::SUITE_TEST_PATTERN).and_return(SAMPLE_SUITE_PATTERN)
1515
+ tddium.stub(:ask).with(Tddium::Text::Prompt::USE_EXISTING_SUITE % SAMPLE_BRANCH_NAME % SAMPLE_APP_NAME, anything).and_return("foobar")
1516
+ tddium.stub(:ask).with(Tddium::Text::Prompt::TEST_PATTERN % Tddium::Default::SUITE_TEST_PATTERN, anything).and_return(SAMPLE_SUITE_PATTERN)
1513
1517
  stub_default_suite_name
1514
1518
  end
1515
1519
 
@@ -1569,13 +1573,13 @@ describe Tddium do
1569
1573
  end
1570
1574
 
1571
1575
  it "should check if the user wants to update the suite" do
1572
- tddium.should_receive(:ask).with(Tddium::Text::Prompt::UPDATE_SUITE)
1576
+ tddium.should_receive(:ask).with(Tddium::Text::Prompt::UPDATE_SUITE, anything)
1573
1577
  run_suite(tddium)
1574
1578
  end
1575
1579
 
1576
1580
  context "user wants to update the suite" do
1577
1581
  before(:each) do
1578
- tddium.stub(:ask).with(Tddium::Text::Prompt::UPDATE_SUITE).and_return(Tddium::Text::Prompt::Response::YES)
1582
+ tddium.stub(:ask).with(Tddium::Text::Prompt::UPDATE_SUITE, anything).and_return(Tddium::Text::Prompt::Response::YES)
1579
1583
  end
1580
1584
  it_behaves_like "prompting for suite configuration" do
1581
1585
  let(:current) { SAMPLE_SUITE_RESPONSE }
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.8
5
+ version: 0.6.10
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-17 00:00:00 -07:00
13
+ date: 2011-06-21 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency