Using the Test Generator Helper causes Test::Unit to run unintentionally

5 views
Skip to first unread message

Adam

unread,
Dec 17, 2008, 8:08:51 PM12/17/08
to RubiGen
I'm trying to get autospec working with my project right now and
because test/unit is required in the test_helper it means autospec
thinks I've got Test::Unit tests to run with my specs. Basically the
output ends up looking something like:

Finished in 2.854823 seconds

98 examples, 2 failures
Loaded suite spec/page_spec
Started

Finished in 0.00064 seconds.

0 tests, 0 assertions, 0 failures, 0 errors
==============================================================================

So autospec is essentially reporting a green spec run, which is
untrue. I fixed this by changing test_helper.rb to look something like
this at the top:

--- a/vendor/gems/gems/rubigen-1.3.2/test/test_helper.rb
+++ b/vendor/gems/gems/rubigen-1.3.2/test/test_helper.rb
@@ -1,7 +1,8 @@
-require 'test/unit'
+require 'test/unit/assertions'
require File.dirname(__FILE__) + '/../lib/rubigen'
require 'rubigen/helpers/generator_test_helper'
include RubiGen
+include Test::Unit::Assertions

def load_mocha
require 'rubygems'

Which I'm sure will cause some problems with other stuff. My question
is, is there some way we can get the assertions added, but not all of
test/unit as that causes ruby to run Test::Unit tests in addition to
specs. Maybe this can go into the test_generator_helper.rb file and
cut its dependency on test_helper.rb?

Adam

unread,
Dec 23, 2008, 12:51:30 AM12/23/08
to RubiGen
I'll answer my own question here. In my spec_helper.rb I've put the
following:

require 'rubigen'
require 'rubigen/helpers/generator_test_helper'

# Must set before requiring generator libs.
TMP_ROOT = File.join(File.dirname(__FILE__),"sandbox","generated")
PROJECT_NAME = 'example'
PROJECT_FOLDER = File.join(TMP_ROOT,PROJECT_NAME)
APP_ROOT = File.join(TMP_ROOT, PROJECT_NAME)



-Adam

Dr Nic Williams

unread,
Dec 23, 2008, 12:55:17 AM12/23/08
to rub...@googlegroups.com
I do want to give more spec support to testing rubigen generated things; newgem does it for its generators (generates either test or spec scaffoldings). I'll use all these suggestions when I get to it!
--
Dr Nic Williams
Mocra - Premier iPhone and Ruby on Rails Consultants
w - http://mocra.com
e - dr...@mocra.com
p - +61 412 002 126 or +61 7 3102 3237
skype - nicwilliams
Reply all
Reply to author
Forward
0 new messages