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 +1 -1
- data/lib/single_test.rb +5 -2
- data/single_test.gemspec +1 -1
- data/spec/single_test_spec.rb +15 -6
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
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
|
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
data/spec/single_test_spec.rb
CHANGED
@@ -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/
|
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
|
-
|
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
|
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
|
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
|
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
|
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
|
|