Permalink
Browse files

added generator specs using ammeter gem

  • Loading branch information...
1 parent 913215e commit 392cdfacc40b0caa2d44b5afc4aaa120445c5517 @alexrothenberg alexrothenberg committed Sep 30, 2011
Showing with 52 additions and 1 deletion.
  1. +2 −1 .gitignore
  2. +1 −0 formtastic.gemspec
  3. +47 −0 spec/generators/formtastic/install/install_generator_spec.rb
  4. +2 −0 spec/spec_helper.rb
View
@@ -10,4 +10,5 @@ log/*
.bundle
Gemfile.lock
.yardoc
-doc/
+doc/
+tmp
View
@@ -33,4 +33,5 @@ Gem::Specification.new do |s|
s.add_development_dependency(%q<rcov>, ["~> 0.9.9"])
s.add_development_dependency(%q<colored>)
s.add_development_dependency(%q<tzinfo>)
+ s.add_development_dependency(%q<ammeter>, ["~> 0.1.2"])
end
@@ -0,0 +1,47 @@
+require 'spec_helper'
+
+# Generators are not automatically loaded by Rails
+require 'generators/formtastic/install/install_generator'
+
+describe Formtastic::InstallGenerator do
+ # Tell the generator where to put its output (what it thinks of as Rails.root)
+ destination File.expand_path("../../../../../tmp", __FILE__)
+
+ before { prepare_destination }
+
+ describe 'no arguments' do
+ before { run_generator }
+
+ describe 'config/initializers/formtastic.rb' do
+ subject { file('config/initializers/formtastic.rb') }
+ it { should exist }
+ it { should contain "# Please note: If you're subclassing Formtastic::FormBuilder" }
+ end
+
+ describe 'lib/templates/erb/scaffold/_form.html.erb' do
+ subject { file('lib/templates/erb/scaffold/_form.html.erb') }
+ it { should exist }
+ it { should contain "<%%= semantic_form_for @<%= singular_name %> do |f| %>" }
+ end
+ end
+
+ describe 'haml' do
+ before { run_generator %w(--template-engine haml) }
+
+ describe 'lib/templates/erb/scaffold/_form.html.haml' do
+ subject { file('lib/templates/haml/scaffold/_form.html.haml') }
+ it { should exist }
+ it { should contain "= semantic_form_for @<%= singular_name %> do |f|" }
+ end
+ end
+
+ describe 'slim' do
+ before { run_generator %w(--template-engine slim) }
+
+ describe 'lib/templates/erb/scaffold/_form.html.slim' do
+ subject { file('lib/templates/slim/scaffold/_form.html.slim') }
+ it { should exist }
+ it { should contain "= semantic_form_for @<%= singular_name %> do |f|" }
+ end
+ end
+end
View
@@ -10,6 +10,8 @@
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic/util'))
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic'))
+require 'ammeter/init'
+
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories in alphabetic order.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {|f| require f}

0 comments on commit 392cdfa

Please sign in to comment.