tddium-preview 0.6.16 → 0.6.18

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -21,6 +21,8 @@ nbproject
21
21
  .rvmrc
22
22
  .tddium
23
23
  .tddium.development
24
+ .tddium-deploy-key
25
+ .tddium-deploy-key.*
24
26
  .DS_Store
25
27
 
26
28
  # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tddium-preview (0.6.15)
4
+ tddium-preview (0.6.18)
5
5
  bundler
6
6
  highline
7
7
  json
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  # Copyright (c) 2011 Solano Labs All Rights Reserved
2
+ #
2
3
 
3
4
  require 'bundler'
4
5
  Bundler::GemHelper.install_tasks
@@ -11,7 +12,7 @@ end
11
12
  task :default => :spec
12
13
 
13
14
  namespace :spec do
14
- RUBY_VERSIONS = ["1.9.2-p180", "1.8.7-p302"]
15
+ RUBY_VERSIONS = ["1.9.2-p180", "1.8.7-p334"]
15
16
  GEMSET = "tddium"
16
17
  desc "Runs the specs across Ruby 1.8.7 and 1.9.2"
17
18
  task :xruby do
data/lib/tddium.rb CHANGED
@@ -8,7 +8,7 @@ require "highline/import"
8
8
  require "json"
9
9
  require "tddium_client"
10
10
  require "base64"
11
- require 'erb'
11
+ require "erb"
12
12
  require File.expand_path("../tddium/constant", __FILE__)
13
13
  require File.expand_path("../tddium/version", __FILE__)
14
14
  require File.expand_path("../tddium/heroku", __FILE__)
@@ -107,6 +107,7 @@ class Tddium < Thor
107
107
  end
108
108
 
109
109
  desc "password", "Change password"
110
+ map "passwd" => :password
110
111
  method_option :environment, :type => :string, :default => nil
111
112
  def password
112
113
  set_default_environment(options[:environment])
@@ -157,8 +158,14 @@ class Tddium < Thor
157
158
  method_option :user_data_file, :type => :string, :default => nil
158
159
  method_option :max_parallelism, :type => :numeric, :default => nil
159
160
  method_option :test_pattern, :type => :string, :default => nil
161
+ method_option :force, :type => :boolean, :default => false
160
162
  def spec
161
163
  set_default_environment(options[:environment])
164
+ git_version_ok
165
+ if git_changes then
166
+ exit_failure(Text::Error::GIT_CHANGES_NOT_COMMITTED) if !options[:force]
167
+ warn(Text::Warning::GIT_CHANGES_NOT_COMMITTED)
168
+ end
162
169
  exit_failure unless git_repo? && tddium_settings && suite_for_current_branch?
163
170
 
164
171
  test_execution_params = {}
@@ -247,7 +254,8 @@ class Tddium < Thor
247
254
  say "#{finished_tests.size} tests, #{test_statuses["failed"]} failures, #{test_statuses["error"]} errors, #{test_statuses["pending"]} pending"
248
255
 
249
256
  # Save the spec options
250
- write_suite(current_suite_id, {"user_data_file" => user_data_file_path,
257
+ write_suite(suite_details["suite"].merge({"id" => current_suite_id}),
258
+ {"user_data_file" => user_data_file_path,
251
259
  "max_parallelism" => max_parallelism,
252
260
  "test_pattern" => test_pattern})
253
261
 
@@ -263,6 +271,7 @@ class Tddium < Thor
263
271
  method_option :environment, :type => :string, :default => nil
264
272
  def status
265
273
  set_default_environment(options[:environment])
274
+ git_version_ok
266
275
  return unless git_repo? && tddium_settings && suite_for_current_branch?
267
276
 
268
277
  begin
@@ -292,6 +301,7 @@ class Tddium < Thor
292
301
  end
293
302
 
294
303
  desc "suite", "Register the suite for this project, or edit its settings"
304
+ method_option :edit, :type => :boolean, :default => false
295
305
  method_option :name, :type => :string, :default => nil
296
306
  method_option :pull_url, :type => :string, :default => nil
297
307
  method_option :push_url, :type => :string, :default => nil
@@ -299,6 +309,7 @@ class Tddium < Thor
299
309
  method_option :environment, :type => :string, :default => nil
300
310
  def suite
301
311
  set_default_environment(options[:environment])
312
+ git_version_ok
302
313
  return unless git_repo? && tddium_settings
303
314
 
304
315
  params = {}
@@ -306,8 +317,11 @@ class Tddium < Thor
306
317
  if current_suite_id
307
318
  current_suite = call_api(:get, current_suite_path)["suite"]
308
319
 
309
- say Text::Process::EXISTING_SUITE % format_suite_details(current_suite)
310
- prompt_update_suite(current_suite, options)
320
+ if options[:edit]
321
+ update_suite(current_suite, options)
322
+ else
323
+ say Text::Process::EXISTING_SUITE % format_suite_details(current_suite)
324
+ end
311
325
  else
312
326
  params[:branch] = current_git_branch
313
327
  default_suite_name = File.basename(Dir.pwd)
@@ -317,7 +331,7 @@ class Tddium < Thor
317
331
 
318
332
  if use_existing_suite
319
333
  # Write to file and exit when using the existing suite
320
- write_suite(existing_suite["id"])
334
+ write_suite(existing_suite)
321
335
  say Text::Status::USING_SUITE % format_suite_details(existing_suite)
322
336
  return
323
337
  end
@@ -332,7 +346,7 @@ class Tddium < Thor
332
346
  say Text::Process::CREATING_SUITE % [params[:repo_name], params[:branch]]
333
347
  new_suite = call_api(:post, Api::Path::SUITES, {:suite => params})
334
348
  # Save the created suite
335
- write_suite(new_suite["suite"]["id"])
349
+ write_suite(new_suite["suite"])
336
350
 
337
351
  # Manage git
338
352
  exit_failure("Failed to push repo to Tddium!") unless update_git_remote_and_push(new_suite)
@@ -363,6 +377,45 @@ class Tddium < Thor
363
377
  result
364
378
  end
365
379
 
380
+ def git_changes
381
+ cmd = "(git ls-files --exclude-standard -d -m -t || echo GIT_FAILED) < /dev/null 2>&1"
382
+ p = IO.popen(cmd)
383
+ changes = false
384
+ while line = p.gets do
385
+ if line =~ /GIT_FAILED/
386
+ warn(Text::Warning::GIT_UNABLE_TO_DETECT)
387
+ return false
388
+ end
389
+ line = line.strip
390
+ fields = line.split(/\s+/)
391
+ status = fields[0]
392
+ if status !~ /^\?/ then
393
+ changes = true
394
+ break
395
+ end
396
+ end
397
+ return changes
398
+ end
399
+
400
+ def git_version_ok
401
+ version = nil
402
+ begin
403
+ version_string = `git --version`
404
+ m = version_string.match(Dependency::VERSION_REGEXP)
405
+ version = m[0] unless m.nil?
406
+ rescue Errno
407
+ rescue Exception
408
+ end
409
+ if version.nil? || version.empty? then
410
+ exit_failure(Text::Error::GIT_NOT_FOUND)
411
+ end
412
+ version_parts = version.split(".")
413
+ if version_parts[0].to_i < 1 ||
414
+ version_parts[1].to_i < 7 then
415
+ warn(Text::Warning::GIT_VERSION % version)
416
+ end
417
+ end
418
+
366
419
  def current_git_branch
367
420
  @current_git_branch ||= File.basename(`git symbolic-ref HEAD`.gsub("\n", ""))
368
421
  end
@@ -546,13 +599,11 @@ class Tddium < Thor
546
599
  ask_or_update.call(:campfire_room, Text::Prompt::CAMPFIRE_ROOM, nil)
547
600
  end
548
601
 
549
- def prompt_update_suite(suite, options)
550
- if prompt(Text::Prompt::UPDATE_SUITE, nil, 'n') == Text::Prompt::Response::YES
551
- params = {}
552
- prompt_suite_params(options, params, suite)
553
- call_api(:put, "#{Api::Path::SUITES}/#{suite['id']}", params)
554
- say Text::Process::UPDATED_SUITE
555
- end
602
+ def update_suite(suite, options)
603
+ params = {}
604
+ prompt_suite_params(options, params, suite)
605
+ call_api(:put, "#{Api::Path::SUITES}/#{suite['id']}", params)
606
+ say Text::Process::UPDATED_SUITE
556
607
  end
557
608
 
558
609
  def resolve_suite_name(options, params, default_suite_name)
@@ -630,6 +681,11 @@ class Tddium < Thor
630
681
  details
631
682
  end
632
683
 
684
+ def tddium_deploy_key_file_name
685
+ extension = ".#{environment}" unless environment == :production
686
+ ".tddium-deploy-key#{extension}"
687
+ end
688
+
633
689
  def suite_for_current_branch?
634
690
  unless current_suite_id
635
691
  message = Text::Error::NO_SUITE_EXISTS % current_git_branch
@@ -685,20 +741,26 @@ class Tddium < Thor
685
741
  write_tddium_to_gitignore
686
742
  end
687
743
 
688
- def write_suite(suite_id, options = {})
744
+ def write_suite(suite, options = {})
745
+ suite_id = suite["id"]
689
746
  branches = tddium_settings["branches"] || {}
690
747
  branches.merge!({current_git_branch => {"id" => suite_id, "options" => options}})
691
748
  File.open(tddium_file_name, "w") do |file|
692
749
  file.write(tddium_settings.merge({"branches" => branches}).to_json)
693
750
  end
751
+ File.open(tddium_deploy_key_file_name, "w") do |file|
752
+ file.write(suite["ci_ssh_pubkey"])
753
+ end
694
754
  write_tddium_to_gitignore
695
755
  end
696
756
 
697
757
  def write_tddium_to_gitignore
698
758
  content = File.exists?(Git::GITIGNORE) ? File.read(Git::GITIGNORE) : ''
699
- unless content.include?("#{tddium_file_name}\n")
700
- File.open(Git::GITIGNORE, "a") do |file|
701
- file.write("#{tddium_file_name}\n")
759
+ [tddium_file_name, tddium_deploy_key_file_name].each do |fn|
760
+ unless content.include?("#{fn}\n")
761
+ File.open(Git::GITIGNORE, "a") do |file|
762
+ file.write("#{fn}\n")
763
+ end
702
764
  end
703
765
  end
704
766
  end
@@ -59,7 +59,6 @@ module TddiumConstant
59
59
  INVITATION_TOKEN = "Enter your invitation token:"
60
60
  USE_EXISTING_SUITE = "A suite exists '%%s' (branch %s). Enter '#{Response::YES}' to use it, or enter a new repo name:"
61
61
  TEST_PATTERN = "Enter a test pattern or press 'Return'. Using '%s' by default:"
62
- UPDATE_SUITE = "Do you want to edit settings for this suite? (y/n)"
63
62
  CI_PULL_URL = "Enter git URL to pull from (default '%s'):"
64
63
  CI_PUSH_URL = "Enter git URL to push to (default '%s'):"
65
64
  CAMPFIRE_SUBDOMAIN = "Enter your Campfire subdomain (default '%s'):"
@@ -68,7 +67,9 @@ module TddiumConstant
68
67
  end
69
68
 
70
69
  module Warning
71
- GIT_CHANGES_NOT_COMMITTED = "Uncommitted changes in local git repository"
70
+ GIT_VERSION = "Unsupported git version: %s"
71
+ GIT_CHANGES_NOT_COMMITTED = "There are uncommitted changes in the local git repository"
72
+ GIT_UNABLE_TO_DETECT = "Unable to detect uncommitted git changes"
72
73
  end
73
74
 
74
75
  module Process
@@ -222,19 +223,54 @@ Notifications:
222
223
  Authorize the following SSH key to let Tddium's pulls and pushes through:
223
224
 
224
225
  <%=suite["ci_ssh_pubkey"]%>
226
+ <% if suite["ci_pull_url"] =~ /^git@github.com:(.*).git$/ %>
227
+ Tddium will pull from your Github repository. Visit
228
+ https://github.com/<%= $1 %>/admin/keys
229
+ then click "Add another deploy key" and copy and paste the above key.
230
+ <% end %>
231
+ <% if suite["ci_push_url"] =~ /^git@heroku.com:(.*).git$/ %>
232
+ Tddium will push to your Heroku application <%= $1 %>.
233
+ To authorize the key, use the following command:
234
+ heroku keys:add <%= tddium_deploy_key_file_name %> --app <%= $1 %>
235
+ <% end %>
225
236
 
226
- To trigger CI builds, POST to the following URL from a post-commit hook:
227
-
237
+ <% if suite["ci_pull_url"] =~ /^git@github.com:(.*).git$/ %>
238
+ Github can notify Tddium of your commits with a post-receive hook. Visit
239
+ https://github.com/<%= $1 %>/admin/hooks#generic_minibucket
240
+ then add the following URL and click "Update Settings":
228
241
  <%=suite["hook_uri"]%>
242
+ <% else %>
243
+ It looks like you aren't using Github, so you'll need to manually configure
244
+ your post-commit hook. In Unix-based Git repositories, find the repository
245
+ root and look for a shell script in `.git/hooks/post-commit`.
246
+ To trigger CI builds, POST to the following URL from a post-commit hook:
247
+ <% end %>
229
248
 
230
- See www.tddium.com/support for more information.
249
+ See http://www.tddium.com/support for more information on Tddium CI.
231
250
  <% end %>
251
+
252
+ If your tests don't require a database, you're all set and can now run
253
+ tddium spec.
254
+
255
+ If your tests do use a database, you'll now need to configure your
256
+ database setup. See http://www.tddium.com/support/reference#setup_hooks
257
+ to create a Rake task for Tddium to set up your database.
258
+
259
+ Run 'tddium suite --edit' to edit suite settings.
232
260
  EOF
233
261
  end
234
262
 
235
263
  module Error
264
+ GIT_CHANGES_NOT_COMMITTED =<<EOF
265
+ There are uncommitted changes in the local git repository.
266
+
267
+ Commit changes before running 'tddium spec'.
268
+
269
+ Use 'tddium spec --force' to test with only already-committed changes.
270
+ EOF
236
271
  NOT_INITIALIZED = "tddium must be initialized. Try 'tddium login'"
237
272
  INVALID_TDDIUM_FILE = ".tddium.%s config file is corrupt. Try 'tddium login'"
273
+ GIT_NOT_FOUND = "Tddium requires git and git is not on your PATH"
238
274
  GIT_NOT_INITIALIZED =<<EOF;
239
275
  It doesn't look like you're in a git repo. If you're not, use 'git init' to
240
276
  create one.
@@ -265,7 +301,15 @@ http://blog.tddium.com/home/
265
301
  HEROKU_MISCONFIGURED = "There was an error linking your Heroku account to Tddium: %s"
266
302
  module Heroku
267
303
  NOT_FOUND = "heroku command not found. Make sure the latest heroku gem is installed.\nOutput of `gem list heroku`:\n%s"
268
- NOT_ADDED = "It looks like you haven't enabled the tddium addon. Add it using 'heroku addons:add tddium'"
304
+ NOT_ADDED =<<EOF;
305
+ It looks like you haven't enabled the tddium add-on for the default app.
306
+ Add it using 'heroku addons:add tddium'
307
+
308
+ If you've already enabled the addon for a specific app, try running:
309
+
310
+ $ tddium heroku --app <your app name>'
311
+
312
+ EOF
269
313
  INVALID_FORMAT = "The 'heroku -s' command output a format we didn't recognize. Make sure you're running the latest version of the heroku gem"
270
314
  NOT_LOGGED_IN = "Log in to your heroku account first using 'heroku login'"
271
315
  APP_NOT_FOUND = "The app '%s' is not recognized by Heroku"
@@ -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.16"
6
+ VERSION = "0.6.18"
7
7
  end
data/spec/spec_helper.rb CHANGED
@@ -9,6 +9,7 @@ require 'rspec'
9
9
  require "fakefs/spec_helpers"
10
10
  require "tddium_client/tddium_spec_helpers"
11
11
 
12
+ require "stringio"
12
13
  require 'ostruct'
13
14
 
14
15
  class Open3SpecHelper
data/spec/tddium_spec.rb CHANGED
@@ -35,6 +35,7 @@ describe Tddium do
35
35
  DEFAULT_TEST_PATTERN = "**/*_spec.rb"
36
36
  SAMPLE_SUITE_PATTERN = "features/*.feature, spec/**/*_spec.rb"
37
37
  CUSTOM_TEST_PATTERN = "**/cat_spec.rb"
38
+ SAMPLE_SSH_PUBKEY = "ssh-rsa 1234567890"
38
39
  SAMPLE_SUITE_RESPONSE = {"repo_name" => SAMPLE_APP_NAME,
39
40
  "branch" => SAMPLE_BRANCH_NAME,
40
41
  "id" => SAMPLE_SUITE_ID,
@@ -42,10 +43,11 @@ describe Tddium do
42
43
  "rubygems_version"=>SAMPLE_RUBYGEMS_VERSION,
43
44
  "bundler_version"=>SAMPLE_BUNDLER_VERSION,
44
45
  "git_repo_uri" => SAMPLE_GIT_REPO_URI,
46
+ "ci_ssh_pubkey" => SAMPLE_SSH_PUBKEY,
45
47
  "test_pattern" => SAMPLE_SUITE_PATTERN}
46
48
  SAMPLE_SUITES_RESPONSE = {"suites" => [SAMPLE_SUITE_RESPONSE]}
47
- SAMPLE_SUITE_OUTPUT = "Repo: #{SAMPLE_APP_NAME}/#{SAMPLE_BRANCH_NAME}\nDefault Test Pattern: #{SAMPLE_SUITE_PATTERN}\nRuby Version: #{SAMPLE_RUBY_VERSION}\nRubygems Version: #{SAMPLE_RUBYGEMS_VERSION}\nBundler Version: #{SAMPLE_BUNDLER_VERSION}\n\n"
48
49
  SAMPLE_TDDIUM_CONFIG_FILE = ".tddium.test"
50
+ SAMPLE_TDDIUM_DEPLOY_KEY_FILE = ".tddium-deploy-key.test"
49
51
  SAMPLE_TEST_EXECUTION_STATS = "total 1, notstarted 0, started 1, passed 0, failed 0, pending 0, error 0", "start_time"
50
52
  SAMPLE_USER_RESPONSE = {"status"=>0, "user"=>
51
53
  { "id"=>SAMPLE_USER_ID,
@@ -53,7 +55,6 @@ describe Tddium do
53
55
  "email" => SAMPLE_EMAIL,
54
56
  "created_at" => SAMPLE_DATE_TIME,
55
57
  "recurly_url" => SAMPLE_RECURLY_URL}}
56
- SAMPLE_SSH_PUBKEY = "ssh-rsa 1234567890"
57
58
  SAMPLE_HEROKU_USER_RESPONSE = {"user"=>
58
59
  { "id"=>SAMPLE_USER_ID,
59
60
  "api_key" => SAMPLE_API_KEY,
@@ -178,6 +179,8 @@ describe Tddium do
178
179
  stub_tddium_client
179
180
  stub_git_status(tddium)
180
181
  stub_git_config(tddium)
182
+ stub_git_changes(tddium)
183
+ stub_git_version_ok(tddium)
181
184
  create_file(File.join(".git", "something"), "something")
182
185
  create_file(Tddium::Git::GITIGNORE, "something")
183
186
  end
@@ -190,6 +193,14 @@ describe Tddium do
190
193
  tddium.stub(:system).with(/git status/).and_return(result)
191
194
  end
192
195
 
196
+ def stub_git_changes(tddium, result=false)
197
+ tddium.stub(:git_changes).and_return(result)
198
+ end
199
+
200
+ def stub_git_version_ok(tddium, result=false)
201
+ tddium.stub(:git_version_ok).and_return(result)
202
+ end
203
+
193
204
  def stub_git_config(tddium)
194
205
  tddium.stub(:`).with("git config --get remote.origin.url").and_return(SAMPLE_GIT_REPO_URI)
195
206
  end
@@ -230,6 +241,61 @@ describe Tddium do
230
241
  let(:tddium) { Tddium.new }
231
242
  let(:tddium_client) { mock(TddiumClient).as_null_object }
232
243
 
244
+ describe "problems running git" do
245
+ before(:each) do
246
+ end
247
+
248
+ it "should fail and exit if git is not found" do
249
+ tddium.stub(:`).with('git --version').and_raise(Errno::ENOENT)
250
+ tddium.should_receive(:exit_failure).with(Tddium::Text::Error::GIT_NOT_FOUND).and_raise("exit")
251
+ lambda { tddium.send(:git_version_ok) }.should raise_error("exit")
252
+ end
253
+
254
+ it "should warn if git version is unsupported" do
255
+ tddium.stub(:`).with('git --version').and_return("git version 1.6.2")
256
+ tddium.should_receive(:warn).with(Tddium::Text::Warning::GIT_VERSION % "1.6.2").and_return(nil)
257
+ tddium.send(:git_version_ok)
258
+ end
259
+
260
+ it "should warn if git version is unsupported" do
261
+ tddium.stub(:`).with('git --version').and_return("git version 1.7.5")
262
+ tddium.should_not_receive(:exit_failure)
263
+ tddium.should_not_receive(:warn)
264
+ tddium.send(:git_version_ok)
265
+ end
266
+ end
267
+
268
+ describe "changes in git" do
269
+ before(:each) do
270
+ @none = ''
271
+ @modified = "C lib/tddium.rb\n R spec/spec_helper.rb\n"
272
+ @unknown = " ? spec/bogus_spec.rb\n"
273
+ stub_config_file(:api_key => true, :branches => true)
274
+ end
275
+
276
+ it "should handle failure" do
277
+ ::IO.stub(:popen) { StringIO.new("GIT_FAILED") }
278
+ tddium.should_receive(:warn).with(Tddium::Text::Warning::GIT_UNABLE_TO_DETECT).and_return(nil)
279
+ tddium.send(:git_changes).should be_false
280
+ end
281
+
282
+ it "should signal no changes if there are none" do
283
+ ::IO.stub(:popen) { StringIO.new(@none) }
284
+ tddium.send(:git_changes).should be_false
285
+ end
286
+
287
+ it "should ignore unknown files if there are any" do
288
+ ::IO.stub(:popen) { StringIO.new(@unknown) }
289
+ tddium.send(:git_changes).should be_false
290
+ end
291
+
292
+ it "should signal uncommitted changes" do
293
+ status = @unknown + @modified
294
+ ::IO.stub(:popen) { StringIO.new(status) }
295
+ tddium.send(:git_changes).should be_true
296
+ end
297
+ end
298
+
233
299
  shared_examples_for "a password prompt" do
234
300
  context "--password was not passed in" do
235
301
  it "should prompt for a password or confirmation" do
@@ -1041,6 +1107,13 @@ describe Tddium do
1041
1107
  end
1042
1108
  end
1043
1109
 
1110
+ shared_examples_for("saving spec options") do
1111
+ it "should save the spec options" do
1112
+ tddium.should_receive(:write_suite).with(SAMPLE_SUITE_RESPONSE, {"user_data_file" => nil, "max_parallelism" => 3, "test_pattern" => nil})
1113
+ run_spec(tddium, {:max_parallelism => 3})
1114
+ end
1115
+ end
1116
+
1044
1117
  context "user presses 'Ctrl-C' during the process" do
1045
1118
  before do
1046
1119
  stub_call_api_response(:get, "#{Tddium::Api::Path::SESSIONS}/#{SAMPLE_SESSION_ID}/#{Tddium::Api::Path::TEST_EXECUTIONS}", get_test_executions_response)
@@ -1106,11 +1179,7 @@ describe Tddium do
1106
1179
  end
1107
1180
  end
1108
1181
 
1109
- it "should save the spec options" do
1110
- tddium.should_receive(:write_suite).with(SAMPLE_SUITE_ID, {"user_data_file" => nil, "max_parallelism" => 3, "test_pattern" => nil})
1111
- run_spec(tddium, {:max_parallelism => 3})
1112
- end
1113
-
1182
+ it_behaves_like "saving spec options"
1114
1183
  it_should_behave_like("test output summary")
1115
1184
  end
1116
1185
 
@@ -1167,11 +1236,7 @@ describe Tddium do
1167
1236
  end
1168
1237
  end
1169
1238
 
1170
- it "should save the spec options" do
1171
- tddium.should_receive(:write_suite).with(SAMPLE_SUITE_ID, {"user_data_file" => nil, "max_parallelism" => 3, "test_pattern" => nil})
1172
- run_spec(tddium, {:max_parallelism => 3})
1173
- end
1174
-
1239
+ it_should_behave_like "saving spec options"
1175
1240
  it_should_behave_like("test output summary")
1176
1241
  end
1177
1242
  end
@@ -1339,18 +1404,18 @@ describe Tddium do
1339
1404
  tddium.stub(:ask).and_return("")
1340
1405
  end
1341
1406
 
1342
- shared_examples_for "prompting for suite configuration" do
1407
+ shared_examples_for "prompting for suite configuration" do |options|
1343
1408
  it "should prompt for URLs" do
1344
1409
  tddium.should_receive(:ask).with(Tddium::Text::Prompt::CI_PULL_URL % current.fetch('ci_pull_url', SAMPLE_GIT_REPO_URI), anything)
1345
1410
  tddium.should_receive(:ask).with(Tddium::Text::Prompt::CI_PUSH_URL % current['ci_push_url'], anything)
1346
- run_suite(tddium)
1411
+ run_suite(tddium, options)
1347
1412
  end
1348
1413
 
1349
1414
  it "should prompt for campfire" do
1350
1415
  tddium.should_receive(:ask).with(Tddium::Text::Prompt::CAMPFIRE_SUBDOMAIN % current['campfire_subdomain'], anything)
1351
1416
  tddium.should_receive(:ask).with(Tddium::Text::Prompt::CAMPFIRE_TOKEN % current['campfire_token'], anything)
1352
1417
  tddium.should_receive(:ask).with(Tddium::Text::Prompt::CAMPFIRE_ROOM % current['campfire_room'], anything)
1353
- run_suite(tddium)
1418
+ run_suite(tddium, options)
1354
1419
  end
1355
1420
  end
1356
1421
 
@@ -1420,6 +1485,12 @@ describe Tddium do
1420
1485
  JSON.parse(tddium_file)["branches"][SAMPLE_BRANCH_NAME]["id"].should == SAMPLE_SUITE_ID
1421
1486
  end
1422
1487
 
1488
+ it "should write the deploy key file" do
1489
+ run_suite(tddium)
1490
+ deploy_key_data = File.open(SAMPLE_TDDIUM_DEPLOY_KEY_FILE) { |file| file.read }
1491
+ deploy_key_data.should == SAMPLE_SSH_PUBKEY
1492
+ end
1493
+
1423
1494
  it "should update the gitignore file with tddium" do
1424
1495
  run_suite(tddium)
1425
1496
  gitignore_file = File.open(Tddium::Git::GITIGNORE) { |file| file.read }
@@ -1473,8 +1544,8 @@ describe Tddium do
1473
1544
 
1474
1545
  it_should_behave_like "writing the suite to file"
1475
1546
 
1476
- it "should show the user: '#{Tddium::Text::Status::USING_SUITE % SAMPLE_SUITE_OUTPUT}'" do
1477
- tddium.should_receive(:say).with(Tddium::Text::Status::USING_SUITE % SAMPLE_SUITE_OUTPUT)
1547
+ it "should show the user: sample suite output" do
1548
+ tddium.should_receive(:say).with(Tddium::Text::Status::USING_SUITE % tddium.send(:format_suite_details, SAMPLE_SUITE_RESPONSE))
1478
1549
  run_suite(tddium)
1479
1550
  end
1480
1551
  end
@@ -1570,25 +1641,17 @@ describe Tddium do
1570
1641
  end
1571
1642
 
1572
1643
  it "should display '#{Tddium::Text::Process::EXISTING_SUITE}'" do
1573
- tddium.should_receive(:say).with(Tddium::Text::Process::EXISTING_SUITE % SAMPLE_SUITE_OUTPUT)
1574
- run_suite(tddium)
1575
- end
1576
-
1577
- it "should check if the user wants to update the suite" do
1578
- tddium.should_receive(:ask).with(Tddium::Text::Prompt::UPDATE_SUITE, anything)
1644
+ tddium.should_receive(:say).with(Tddium::Text::Process::EXISTING_SUITE % tddium.send(:format_suite_details, SAMPLE_SUITE_RESPONSE))
1579
1645
  run_suite(tddium)
1580
1646
  end
1581
1647
 
1582
1648
  context "user wants to update the suite" do
1583
- before(:each) do
1584
- tddium.stub(:ask).with(Tddium::Text::Prompt::UPDATE_SUITE, anything).and_return(Tddium::Text::Prompt::Response::YES)
1585
- end
1586
- it_behaves_like "prompting for suite configuration" do
1649
+ it_behaves_like "prompting for suite configuration", {:edit=>true} do
1587
1650
  let(:current) { SAMPLE_SUITE_RESPONSE }
1588
1651
  end
1589
1652
  it "should PUT to /suites/#{SAMPLE_SUITE_ID}" do
1590
1653
  call_api_should_receive(:method=>:put, :path=>"#{Tddium::Api::Path::SUITES}/#{SAMPLE_SUITE_ID}")
1591
- run_suite(tddium)
1654
+ run_suite(tddium, {:edit=>true})
1592
1655
  end
1593
1656
  end
1594
1657
 
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.16
5
+ version: 0.6.18
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-28 00:00:00 -07:00
13
+ date: 2011-06-30 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency