spec/testrbl_spec.rb in testrbl-0.1.12 vs spec/testrbl_spec.rb in testrbl-0.1.13
- old
+ new
@@ -4,11 +4,11 @@
around do |example|
run "rm -rf tmp && mkdir tmp"
Dir.chdir "tmp" do
example.call
end
- run "rm -rf tmp"
+ #run "rm -rf tmp"
end
def run(cmd, options={})
result = `#{cmd} 2>&1`
raise "FAILED #{cmd} --> #{result}" if $?.success? != !options[:fail]
@@ -31,10 +31,49 @@
it "has a VERSION" do
Testrbl::VERSION.should =~ /^[\.\da-z]+$/
end
+ context "-Itest" do
+ before do
+ write "a_test.rb", <<-RUBY
+ require 'test/unit'
+ require 'xxx'
+
+ class Xxx < Test::Unit::TestCase
+ def test_xxx
+ puts 'ABC'
+ end
+
+ def test_yyy
+ puts 'BCD'
+ end
+ end
+ RUBY
+ write("test/xxx.rb", "puts 'XXX LOADED'")
+ end
+
+ it "does not include test by default" do
+ result = testrbl "a_test.rb:6", :fail => true
+ result.should_not include "ABC\n"
+ end
+
+ it "can use -Itest for line execution" do
+ result = testrbl "-Itest a_test.rb:6"
+ result.should include "ABC\n"
+ result.should include "XXX LOADED\n"
+ result.should_not include "BCD"
+ end
+
+ it "can use -I test for line execution" do
+ result = testrbl "-I test a_test.rb:6"
+ result.should include "ABC\n"
+ result.should include "XXX LOADED\n"
+ result.should_not include "BCD"
+ end
+ end
+
context "def test_" do
before do
write "a_test.rb", <<-RUBY
require 'test/unit'
@@ -73,15 +112,15 @@
result.should include "ABC\n"
result.should include "BCD"
end
it "runs with options" do
- pending "works in real console..." do
- result = testrbl "a_test.rb -n '/xxx/'"
- result.should include "ABC"
- result.should_not include "BCD"
- end
+ # TODO does not work with files in root folder ... WTF (only happens with a script that runs testrb)
+ write("foo/a_test.rb", read("a_test.rb"))
+ result = testrbl "foo/a_test.rb -n '/xxx/'"
+ result.should include "ABC"
+ result.should_not include "BCD"
end
end
context "test with string" do
before do
@@ -243,16 +282,16 @@
context "minitest spec" do
before do
write "a_test.rb", <<-RUBY
require 'minitest/autorun'
- describe "a" do
- it "b" do
+ describe "a-a" do
+ it "b./_-b" do
puts "ABC"
end
- it "c" do
+ it "c-c" do
puts "BCD"
end
end
RUBY
end
@@ -404,14 +443,14 @@
it "finds interpolated context do calls" do
call(" context \"c\#{111}b\" do\n").should == [" ", "c.*b"]
end
it "finds minitest it do calls" do
- call(" it \"xx xx\" do\n").should == [" ", "\\d+_xx_xx$"]
+ call(" it \"xx xx\" do\n").should == [" ", "^test_\\d+_xx xx$"]
end
it "finds complex minitest it do calls" do
- call(" it \"xx ._-.. ___ xx\" do\n").should == [" ", "\\d+_xx_______xx$"]
+ call(" it \"xX ._-.. ___ Xx\" do\n").should == [" ", "^test_\\d+_xX ._-.. ___ Xx$"]
end
it "does not find minitest describe do calls since we cannot run them" do
call(" describe Foobar do\n").should == nil
end