lib/generators/components/tests/testspec_test_gen.rb in padrino-gen-0.1.2 vs lib/generators/components/tests/testspec_test_gen.rb in padrino-gen-0.1.3
- old
+ new
@@ -34,9 +34,25 @@
def generate_controller_test(name, root)
testspec_contents = TESTSPEC_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize)
create_file File.join(root, "test/controllers/#{name}_controller_test.rb"), testspec_contents
end
+ TESTSPEC_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '')
+ require File.dirname(__FILE__) + '/../test_config.rb'
+
+ context "!NAME! Model" do
+ specify 'can be created' do
+ @!DNAME! = !NAME!.new
+ @!DNAME!.should.not.be.nil
+ end
+ end
+ TEST
+
+ def generate_model_test(name)
+ tests_contents = TESTSPEC_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize).gsub(/!DNAME!/, name.downcase.underscore)
+ create_file app_root_path("test/models/#{name.to_s.downcase}.rb"), tests_contents
+ end
+
end
end
end
end