tddium-preview 0.1.0 → 0.1.1

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.0.8)
4
+ tddium-preview (0.1.0)
5
5
  bundler
6
6
  highline
7
7
  json
data/lib/tddium.rb CHANGED
@@ -102,6 +102,7 @@ class Tddium < Thor
102
102
  method_option :environment, :type => :string, :default => nil
103
103
  method_option :user_data_file, :type => :string, :default => nil
104
104
  method_option :max_parallelism, :type => :numeric, :default => nil
105
+ method_option :test_pattern, :type => :string, :default => "**/*_spec.rb"
105
106
  def spec
106
107
  set_default_environment(options[:environment])
107
108
  return unless git_repo? && tddium_settings && suite_for_current_branch?
@@ -127,6 +128,12 @@ class Tddium < Thor
127
128
  say Text::Process::USING_PREVIOUS_MAX_PARALLELISM % max_parallelism if max_parallelism == current_suite_options["max_parallelism"]
128
129
  test_execution_params[:max_parallelism] = max_parallelism
129
130
  end
131
+
132
+ # Set test_pattern param
133
+ test_pattern = options[:test_pattern]
134
+ if current_suite_options["test_pattern"]
135
+ say Text::Process::USING_PREVIOUS_TEST_PATTERN % test_pattern if test_pattern == current_suite_options["test_pattern"]
136
+ end
130
137
 
131
138
  start_time = Time.now
132
139
 
@@ -138,9 +145,13 @@ class Tddium < Thor
138
145
  return unless update_git_remote_and_push(suite_details)
139
146
 
140
147
  # Get a list of files to be tested
141
- test_pattern = suite_details["suite"]["test_pattern"]
142
148
  test_files = Dir.glob(test_pattern).collect {|file_path| {:test_name => file_path}}
143
149
 
150
+ if test_files.empty?
151
+ say Text::Error::NO_MATCHING_FILES % test_pattern
152
+ return
153
+ end
154
+
144
155
  # Create a session
145
156
  new_session = call_api(:post, Api::Path::SESSIONS)
146
157
  session_id = new_session["session"]["id"]
@@ -194,7 +205,9 @@ class Tddium < Thor
194
205
  say "#{finished_tests.size} examples, #{test_statuses["failed"]} failures, #{test_statuses["error"]} errors, #{test_statuses["pending"]} pending"
195
206
 
196
207
  # Save the spec options
197
- write_suite(current_suite_id, {"user_data_file" => user_data_file_path, "max_parallelism" => max_parallelism})
208
+ write_suite(current_suite_id, {"user_data_file" => user_data_file_path,
209
+ "max_parallelism" => max_parallelism,
210
+ "test_pattern" => test_pattern})
198
211
  rescue TddiumClient::Error::Base
199
212
  end
200
213
  end
@@ -87,6 +87,7 @@ tddium spec
87
87
  LOGGED_OUT_SUCCESSFULLY = "Logged out successfully"
88
88
  USING_PREVIOUS_USER_DATA_FILE = "Using the previous user data file '%s'"
89
89
  USING_PREVIOUS_MAX_PARALLELISM = "Using the previous value of max_parallelism = %s"
90
+ USING_PREVIOUS_TEST_PATTERN = "Using the previous value of test_pattern = %s"
90
91
  end
91
92
 
92
93
  module Status
@@ -116,6 +117,7 @@ http://blog.tddium.com/home/
116
117
 
117
118
  "
118
119
  NO_USER_DATA_FILE = "User data file '%s' does not exist"
120
+ NO_MATCHING_FILES = "No files match '%s'"
119
121
  end
120
122
  end
121
123
 
@@ -3,5 +3,5 @@ Copyright (c) 2011 Solano Labs All Rights Reserved
3
3
  =end
4
4
 
5
5
  module TddiumVersion
6
- VERSION = "0.1.0"
6
+ VERSION = "0.1.1"
7
7
  end
data/spec/tddium_spec.rb CHANGED
@@ -27,7 +27,9 @@ describe Tddium do
27
27
  SAMPLE_RECURLY_URL = "https://tddium.recurly.com/account/1"
28
28
  SAMPLE_SESSION_ID = 1
29
29
  SAMPLE_SUITE_ID = 1
30
- SAMPLE_TEST_PATTERN = "**/*_spec.rb"
30
+ SAMPLE_TEST_PATTERN = "**/*_spec.rb" # XXX Bogus. Removeme.
31
+ DEFAULT_TEST_PATTERN = "**/*_spec.rb"
32
+ CUSTOM_TEST_PATTERN = "**/cat_spec.rb"
31
33
  SAMPLE_SUITE_RESPONSE = {"repo_name" => SAMPLE_APP_NAME, "branch" => SAMPLE_BRANCH_NAME, "id" => SAMPLE_SUITE_ID, "test_pattern"=>SAMPLE_TEST_PATTERN, "ruby_version"=>SAMPLE_RUBY_VERSION, "git_repo_uri" => SAMPLE_GIT_REPO_URI}
32
34
  SAMPLE_SUITES_RESPONSE = {"suites" => [SAMPLE_SUITE_RESPONSE]}
33
35
  SAMPLE_TDDIUM_CONFIG_FILE = ".tddium.test"
@@ -48,13 +50,16 @@ describe Tddium do
48
50
  (array.last.is_a?(Hash) && is_options) ? array.pop : {}
49
51
  end
50
52
 
51
- def run(tddium, options = {:environment => "test"})
53
+ def run(tddium, options = {:test_pattern => DEFAULT_TEST_PATTERN, :environment => "test"})
52
54
  send("run_#{example.example_group.ancestors.map(&:description)[-2][1..-1]}", tddium, options)
53
55
  end
54
56
 
55
57
  [:suite, :spec, :status, :account, :login, :logout].each do |method|
56
58
  define_method("run_#{method}") do |tddium, *params|
57
59
  options = params.first || {}
60
+ if method == :spec
61
+ options[:test_pattern] = DEFAULT_TEST_PATTERN unless options.has_key?(:test_pattern)
62
+ end
58
63
  options[:environment] = "test" unless options.has_key?(:environment)
59
64
  stub_cli_options(tddium, options)
60
65
  tddium.send(method)
@@ -636,15 +641,27 @@ describe Tddium do
636
641
 
637
642
  it_should_behave_like "sending the api key"
638
643
 
639
- it "should POST the names of the file names extracted from the suite's test_pattern" do
640
- current_dir = Dir.pwd
641
- call_api_should_receive(:params => {:suite_id => SAMPLE_SUITE_ID,
642
- :tests => [{:test_name => "#{current_dir}/spec/cat_spec.rb"},
643
- {:test_name => "#{current_dir}/spec/dog_spec.rb"},
644
- {:test_name => "#{current_dir}/spec/mouse_spec.rb"}]})
645
- run_spec(tddium)
644
+ context "default test pattern" do
645
+ it "should POST the names of the file names extracted from the test_pattern parameter" do
646
+ current_dir = Dir.pwd
647
+ call_api_should_receive(:params => {:suite_id => SAMPLE_SUITE_ID,
648
+ :tests => [{:test_name => "#{current_dir}/spec/cat_spec.rb"},
649
+ {:test_name => "#{current_dir}/spec/dog_spec.rb"},
650
+ {:test_name => "#{current_dir}/spec/mouse_spec.rb"}]})
651
+ run_spec(tddium)
652
+ end
646
653
  end
647
654
 
655
+ context "--test-pattern=#{CUSTOM_TEST_PATTERN}" do
656
+ it "should POST the names of the file names extracted from the test_pattern parameter" do
657
+ current_dir = Dir.pwd
658
+ call_api_should_receive(:params => {:suite_id => SAMPLE_SUITE_ID,
659
+ :tests => [{:test_name => "#{current_dir}/spec/cat_spec.rb"}]})
660
+ run_spec(tddium, {:test_pattern=>CUSTOM_TEST_PATTERN})
661
+ end
662
+ end
663
+
664
+
648
665
  context "'POST #{Tddium::Api::Path::REGISTER_TEST_EXECUTIONS}' is successful" do
649
666
  before do
650
667
  response = {"added"=>0, "existing"=>1, "errors"=>0, "status"=>0}
@@ -790,7 +807,7 @@ describe Tddium do
790
807
  end
791
808
 
792
809
  it "should save the spec options" do
793
- tddium.should_receive(:write_suite).with(SAMPLE_SUITE_ID, {"user_data_file" => nil, "max_parallelism" => 3})
810
+ tddium.should_receive(:write_suite).with(SAMPLE_SUITE_ID, {"user_data_file" => nil, "max_parallelism" => 3, "test_pattern" => "**/*_spec.rb"})
794
811
  run_spec(tddium, {:max_parallelism => 3})
795
812
  end
796
813
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: tddium-preview
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
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-04-15 00:00:00 -07:00
13
+ date: 2011-04-29 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency