spec/testrbl_spec.rb in testrbl-0.1.7 vs spec/testrbl_spec.rb in testrbl-0.1.8
- old
+ new
@@ -23,15 +23,19 @@
folder = File.dirname(file)
run "mkdir -p #{folder}" unless File.exist?(folder)
File.open(file, 'w'){|f| f.write content }
end
+ def read(file)
+ File.read(file)
+ end
+
it "has a VERSION" do
Testrbl::VERSION.should =~ /^[\.\da-z]+$/
end
- context "with a simple setup" do
+ context "def test_" do
before do
write "a_test.rb", <<-RUBY
require 'test/unit'
class Xxx < Test::Unit::TestCase
@@ -80,43 +84,59 @@
end
context "test with string" do
before do
write "a_test.rb", <<-RUBY
- require 'test/unit'
-
- class Xxx < Test::Unit::TestCase
+ REQUIRE
+ class Xxx < ANCESTOR
test "a" do
puts 'ABC'
end
test "b" do
puts 'BCD'
end
- test "c d" do
+ test "c -__.BLA:" do
puts 'CDE'
end
test "c" do
puts 'DEF'
end
end
RUBY
end
- it "runs test" do
- result = testrbl "a_test.rb:8"
- result.should_not include "ABC\n"
- result.should include "BCD\n"
- result.should_not include "CDE\n"
- end
+ [
+ ["Test::Unit::TestCase", "require 'test/unit'\n"],
+ ["ActiveSupport::TestCase", "require 'test/unit'\nrequire 'active_support/test_case'"],
+ ].each do |ancestor, require|
+ context "with #{ancestor}" do
+ before do
+ write("a_test.rb", read("a_test.rb").sub("REQUIRE", require).sub("ANCESTOR", ancestor))
+ end
- it "runs test explicitly" do
- result = testrbl "a_test.rb:16"
- result.should_not include "CDE\n"
- result.should include "DEF\n"
+ it "runs test" do
+ result = testrbl "a_test.rb:8"
+ result.should_not include "ABC\n"
+ result.should include "BCD\n"
+ result.should_not include "CDE\n"
+ end
+
+ it "runs test explicitly" do
+ result = testrbl "a_test.rb:16"
+ result.should_not include "CDE\n"
+ result.should include "DEF\n"
+ end
+
+ it "runs complex test names" do
+ result = testrbl "a_test.rb:12"
+ result.should include "CDE\n"
+ result.should_not include "DEF\n"
+ end
+ end
end
end
context "shoulda" do
before do
@@ -323,14 +343,18 @@
it "does not find other methods" do
call(" def xxx\n").should == nil
end
it "finds calls with single quotes" do
- call(" test 'xx xx' do\n").should == [" ", "^test: xx xx$"]
+ call(" test 'xx xx' do\n").should == [" ", "^test(: |_)xx.xx$"]
end
it "finds test do calls" do
- call(" test \"xx xx\" do\n").should == [" ", "^test: xx xx$"]
+ call(" test \"xx xx\" do\n").should == [" ", "^test(: |_)xx.xx$"]
+ end
+
+ it "finds complex test do calls" do
+ call(" test \"c -__.BLA:\" do\n").should == [" ", "^test(: |_)c.\\-__\\.BLA:$"]
end
it "finds should do calls" do
call(" should \"xx xx\" do\n").should == [" ", "should xx xx. $"]
end