single_test 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
data/lib/single_test.rb CHANGED
@@ -89,7 +89,10 @@ module SingleTest
89
89
  def run_test(type, file, test_name=nil)
90
90
  case type.to_s
91
91
  when 'test' then sh "ruby -Ilib:test #{file} -n /#{test_name}/"
92
- when 'spec' then sh "export RAILS_ENV=test ; #{spec_executable} --options spec/spec.opts #{file}" + (test_name ? %Q( -e "#{test_name.sub('"',"\\\"")}") : '') + (ENV['X'] ? " -X" : "")
92
+ when 'spec' then
93
+ options_file = "spec/spec.opts"
94
+ options_file = (File.exist?(options_file) ? " --options #{options_file}" : "")
95
+ sh "export RAILS_ENV=test ; #{spec_executable}#{options_file} #{file}" + (test_name ? %Q( -e "#{test_name.sub('"',"\\\"")}") : '') + (ENV['X'] ? " -X" : "")
93
96
  else raise "Unknown: #{type}"
94
97
  end
95
98
  end
@@ -101,4 +104,4 @@ module SingleTest
101
104
  def last_modified_file(dir, options={})
102
105
  Dir["#{dir}/**/*#{options[:ext]}"].sort_by { |p| File.mtime(p) }.last
103
106
  end
104
- end
107
+ end
data/single_test.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{single_test}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
@@ -103,7 +103,7 @@ describe SingleTest do
103
103
  end
104
104
 
105
105
  it "runs the last test" do
106
- SingleTest.should_receive(:run_test).with(:spec, "spec/yyy_spec.rb")
106
+ SingleTest.should_receive(:run_test).with(:spec, "spec/xxx_spec.rb")
107
107
  SingleTest.run_last(:spec)
108
108
  end
109
109
 
@@ -115,7 +115,11 @@ describe SingleTest do
115
115
  end
116
116
 
117
117
  describe :run_test do
118
- after :all do
118
+ before do
119
+ ENV['X']=nil
120
+ end
121
+
122
+ after do
119
123
  ENV['X']=nil
120
124
  end
121
125
 
@@ -134,25 +138,30 @@ describe SingleTest do
134
138
  end
135
139
 
136
140
  it "runs whole specs without -e" do
137
- SingleTest.should_receive(:sh).with('export RAILS_ENV=test ; script/spec --options spec/spec.opts xxx')
141
+ SingleTest.should_receive(:sh).with('export RAILS_ENV=test ; script/spec xxx')
138
142
  SingleTest.run_test('spec','xxx')
139
143
  end
140
144
 
141
145
  it "runs single specs through -e" do
142
- SingleTest.should_receive(:sh).with('export RAILS_ENV=test ; script/spec --options spec/spec.opts xxx -e "yyy"')
146
+ SingleTest.should_receive(:sh).with('export RAILS_ENV=test ; script/spec xxx -e "yyy"')
143
147
  SingleTest.run_test('spec','xxx', 'yyy')
144
148
  end
145
149
 
146
150
  it "runs single specs through -e with -X" do
147
151
  ENV['X']=''
148
- SingleTest.should_receive(:sh).with('export RAILS_ENV=test ; script/spec --options spec/spec.opts xxx -e "yyy" -X')
152
+ SingleTest.should_receive(:sh).with('export RAILS_ENV=test ; script/spec xxx -e "yyy" -X')
149
153
  SingleTest.run_test('spec','xxx', 'yyy')
150
154
  end
151
155
 
152
156
  it "runs quoted specs though -e" do
153
- SingleTest.should_receive(:sh).with(%Q(export RAILS_ENV=test ; script/spec --options spec/spec.opts xxx -e "y\\\"yy" -X))
157
+ SingleTest.should_receive(:sh).with(%Q(export RAILS_ENV=test ; script/spec xxx -e "y\\\"yy"))
154
158
  SingleTest.run_test('spec','xxx', 'y"yy')
159
+ end
155
160
 
161
+ it "adds --options if spec.opts file exists" do
162
+ File.stub!(:exist?).and_return true
163
+ SingleTest.should_receive(:sh).with('export RAILS_ENV=test ; script/spec --options spec/spec.opts xxx')
164
+ SingleTest.run_test('spec','xxx')
156
165
  end
157
166
  end
158
167
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 1
9
- version: 0.3.1
8
+ - 2
9
+ version: 0.3.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Grosser