lib/padrino-gen/generators/components/tests/testspec.rb in padrino-gen-0.10.1 vs lib/padrino-gen/generators/components/tests/testspec.rb in padrino-gen-0.10.2

- old
+ new

@@ -40,11 +40,11 @@ desc "Run application test suite" task 'test' => test_tasks.map { |f| "test:\#{f}" } TEST TESTSPEC_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(TESTSPEC_MODEL_TEST) -require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb') +require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb') context "!NAME! Model" do specify 'can be created' do @!DNAME! = !NAME!.new @!DNAME!.should.not.be.nil @@ -66,8 +66,10 @@ create_file destination_root(controller_test_path), testspec_contents, :skip => true end def generate_model_test(name) tests_contents = TESTSPEC_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize).gsub(/!DNAME!/, name.to_s.underscore) + path = options[:app] == '.' ? '/..' : '/../..' + tests_contents.gsub!(/!PATH!/,path) model_test_path = File.join('test',options[:app],'models',"#{name.to_s.underscore}_test.rb") create_file destination_root(model_test_path), tests_contents, :skip => true end