spec/testrbl_spec.rb in testrbl-0.1.17 vs spec/testrbl_spec.rb in testrbl-0.2.0
- old
+ new
@@ -381,28 +381,37 @@
context "avoiding testrb" do
before do
write "backtrace_test.rb", <<-RUBY
puts caller
+ require 'test/unit'
+
+ class Xxx1 < Test::Unit::TestCase
+ def test_xxx
+ puts 'BACKTRACE'
+ end
+ end
RUBY
end
it "does not run via testrb if possible" do
- result = testrbl "a/b/c_test.rb backtrace_test.rb"
+ result = testrbl "-Itest -I lib a/b/c_test.rb backtrace_test.rb -v"
result.should include("CDE")
+ result.should include("BACKTRACE")
result.should_not include("bin/testrb:")
end
- it "runs via testrb if not possible via ruby" do
- result = testrbl "a/b/c_test.rb backtrace_test.rb -v"
+ it "runs via testrb if unavoidable" do
+ result = testrbl "a/b/c_test.rb backtrace_test.rb -n '/xxx/'"
result.should include("CDE")
+ result.should include("BACKTRACE")
result.should include("bin/testrb:")
end
end
end
- describe ".pattern_from_file" do
+ describe ".test_pattern_from_file" do
def call(content, line)
lines = content.split("\n").map{|l| l + "\n" }
Testrbl.pattern_from_file(lines, line)
end
@@ -423,13 +432,13 @@
it "does not find nested it calls" do
@result = call(" context \"xxx\" do\n it \"yyy\" do\n if true do\n it \"zzz\" do\n", 4)
end
end
- describe ".pattern_from_line" do
+ describe ".test_pattern_from_line" do
def call(line)
- Testrbl.pattern_from_line(line)
+ Testrbl.test_pattern_from_line(line)
end
it "finds simple tests" do
call(" def test_xxx\n").should == [" ", "xxx"]
end
@@ -494,8 +503,38 @@
call(" context \"xx .* xx\" do\n").should == [" ", "xx \\.\\* xx"]
end
it "escapes single quotes which we use to build the pattern" do
call(" context \"xx ' xx\" do\n").should == [" ", "xx . xx"]
+ end
+ end
+
+ describe ".partition_argv" do
+ def call(*args)
+ Testrbl.send(:partition_argv, *args)
+ end
+
+ it "finds files" do
+ call(["xxx"]).should == [["xxx"], []]
+ end
+
+ it "finds files after multi-space options" do
+ call(["-I", "test", "xxx"]).should == [["xxx"], ["-I", "test"]]
+ end
+
+ it "finds options" do
+ call(["-I", "test"]).should == [[], ["-I", "test"]]
+ end
+
+ it "finds --verbose" do
+ call(["--verbose", "test"]).should == [["test"], ["--verbose"]]
+ end
+
+ it "finds -- options" do
+ call(["--foo", "test"]).should == [["test"], ["--foo"]]
+ end
+
+ it "finds mashed options" do
+ call(["-Itest"]).should == [[], ["-Itest"]]
end
end
end