Permalink
Browse files

added testspec generation

  • Loading branch information...
1 parent 75347e9 commit de0fc9e1ef951eebfb54a530650ee5264dbf3545 @achiu achiu committed Jul 12, 2010
Showing with 45 additions and 0 deletions.
  1. +22 −0 lib/tumbler/generators/tests/testspec.rb
  2. +23 −0 test/generator_test.rb
@@ -0,0 +1,22 @@
+HELPER=<<-TEST
+require File.expand_path("/../lib/#{name}.rb",File.dirname(__FILE__))
+require 'test/spec'
+
+class Test::Unit::TestCase
+end
+TEST
+
+FLUNK=<<-FAIL
+require File.expand_path('helper.rb',File.dirname(__FILE__))
+
+describe "#{constant_name}" do
+ it "fails" do
+ fail "i flunked"
+ end
+end
+FAIL
+
+def setup_test
+ create_file generate_path('test/helper.rb'), HELPER
+ create_file generate_path("test/#{name}_test.rb"), FLUNK
+end
View
@@ -198,6 +198,29 @@
end
end
+ context "testspec" do
+ setup do
+ capture(:stdout) { Tumbler::Cli.start(['my_gem','--test=testspec',"-r=#{@test_dir}"]) }
+ @helper = File.join(@test_dir, 'my_gem', 'test', 'helper.rb')
+ @gem_test = File.join(@test_dir, 'my_gem', 'test','my_gem_test.rb')
+ end
+ asserts("helper.rb") { File.exist? @helper }
+ asserts("my_gem_test.rb") { File.exist? @gem_test }
+
+ context "helper" do
+ setup { File.read(@helper) }
+ asserts_topic.matches %r{require 'test/spec'}
+ asserts_topic.matches %r{lib/my_gem.rb}
+ asserts_topic.matches %r{class Test::Unit::TestCase}
+ end
+
+ context "my_gem_test.rb" do
+ setup { File.read(@gem_test) }
+ asserts_topic.matches %r{describe "MyGem"}
+ asserts_topic.matches %r{fails}
+ end
+ end
+
context "bacon" do
setup do
capture(:stdout) { Tumbler::Cli.start(['my_gem','--test=bacon',"-r=#{@test_dir}"]) }

0 comments on commit de0fc9e

Please sign in to comment.