lib/generators/components/tests/rspec_test_gen.rb in padrino-gen-0.1.2 vs lib/generators/components/tests/rspec_test_gen.rb in padrino-gen-0.1.3
- old
+ new
@@ -36,9 +36,25 @@
def generate_controller_test(name, root)
rspec_contents = RSPEC_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize)
create_file File.join(root, "test/controllers/#{name}_controller_spec.rb"), rspec_contents
end
+ RSPEC_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '')
+ require File.dirname(__FILE__) + '/../test_config.rb'
+
+ describe "!NAME! Model" do
+ it 'can be created' do
+ @!DNAME! = !NAME!.new
+ @!DNAME!.should.not.be nil
+ end
+ end
+ TEST
+
+ def generate_model_test(name)
+ rspec_contents = RSPEC_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"), rspec_contents
+ end
+
end
end
end
end
end