lib/pluginizer/plugin_builder.rb in pluginizer-0.1.6 vs lib/pluginizer/plugin_builder.rb in pluginizer-0.1.7
- old
+ new
@@ -11,10 +11,11 @@
template '.ruby-version'
template "lib/%namespaced_name%/configuration.rb"
after_bundle do
in_root do
+ configure_database_yml if options.database == 'postgresql'
configure_rspec
git :init
git add: '.'
git commit: "-m 'first commit'"
@@ -22,10 +23,19 @@
end
end
private
+ def configure_database_yml
+ insert_into_file 'spec/dummy/config/database.yml', <<-END.strip_heredoc.indent(2), after: "encoding: unicode"
+
+ host: 127.0.0.1
+ username: postgres
+ password: postgres
+ END
+ end
+
def configure_rspec
invoke('rspec:install')
rails_helper = 'spec/rails_helper.rb'
gsub_file rails_helper,
@@ -35,40 +45,33 @@
%{config.fixture_path = "\#{::Rails.root}/spec/fixtures"},
%{config.fixture_path = "\#{#{camelized}::Engine.root}/spec/fixtures"}
run "bundle binstubs rspec-core"
- requires = %w[fantaskspec email_spec email_spec/rspec].map{ |file| "require '#{file}'" }
- insert_into_file rails_helper,
- "\n#{requires.join("\n")}\n",
- after: "# Add additional requires below this line. Rails is not loaded until this point!"
- insert_into_file rails_helper,
- "\n config.infer_rake_task_specs_from_file_location!\n",
- before: /^end/
- insert_into_file rails_helper,
- "\n config.render_views\n",
- before: /^end/
- cache = <<-CACHE.strip_heredoc.indent(2)
+ requires = %w[
+ fantaskspec
+ email_spec
+ email_spec/rspec
+ ].map{ |file| "require '#{file}'" }.join("\n")
+ insert_into_file rails_helper, "\n#{requires}\n", after: "# Add additional requires below this line. Rails is not loaded until this point!"
+ insert_into_file rails_helper, "\n config.infer_rake_task_specs_from_file_location!\n", before: /^end/
+ insert_into_file rails_helper, "\n config.render_views\n", before: /^end/
+ insert_into_file rails_helper, <<-END.strip_heredoc.indent(2), before: /^end/
+
config.before(:each) do
Rails.cache.clear
end
- CACHE
- insert_into_file rails_helper, cache,
- before: /^end/
- shoulda = <<-SHOULDA.strip_heredoc.indent(2)
+ END
+ insert_into_file rails_helper, <<-END.strip_heredoc.indent(2), before: /^end/
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end
- SHOULDA
- insert_into_file rails_helper, shoulda,
- before: /^end/
- insert_into_file rails_helper,
- "\n config.include(Shoulda::Callback::Matchers::ActiveModel)\n",
- before: /^end/
+ END
+ insert_into_file rails_helper, "\n config.include(Shoulda::Callback::Matchers::ActiveModel)\n", before: /^end/
end
end
end