diff --git a/lib/rails/generators/culerity_generator.rb b/lib/rails/generators/culerity_generator.rb new file mode 100644 index 0000000..7de6326 --- /dev/null +++ b/lib/rails/generators/culerity_generator.rb @@ -0,0 +1,17 @@ +class CulerityGenerator < ::Rails::Generators::Base + source_root File.expand_path('../templates', __FILE__) + desc "Install Culerity into your application" + def generate_culerity + copy_file 'features/step_definitions/culerity_steps.rb', 'features/step_definitions/culerity_steps.rb' + copy_file 'features/support/env.rb', 'features/support/culerity_env.rb' + copy_file 'config/environments/culerity.rb', 'config/environments/culerity.rb' + gsub_file 'config/environments/culerity.rb', /Rarp/, Rails::Application.subclasses[0].name.to_s.split("::")[0] + gsub_file 'config/database.yml', /cucumber:.*\n/, "cucumber: &CUCUMBER\n" + + gsub_file 'config/database.yml', /\z/, "\nculerity:\n <<: *CUCUMBER" + + copy_file "lib/tasks/culerity.rake", "lib/tasks/culerity.rake" + + copy_file 'public/javascripts/culerity.js', 'public/javascripts/culerity.js' + end +end diff --git a/lib/rails/generators/templates/config/environments/culerity.rb b/lib/rails/generators/templates/config/environments/culerity.rb new file mode 100644 index 0000000..f11cf87 --- /dev/null +++ b/lib/rails/generators/templates/config/environments/culerity.rb @@ -0,0 +1,19 @@ +Rarp::Application.configure do + config.cache_classes = true # set because of https://rspec.lighthouseapp.com/projects/16211/tickets/165 + + # Log error messages when you accidentally call methods on nil. + config.whiny_nils = true + + # Show full error reports and disable caching + config.action_controller.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Disable request forgery protection in test environment + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :persistent + config.active_support.deprecation = :log +end \ No newline at end of file diff --git a/rails_generators/culerity/templates/config/environments/culerity_continuousintegration.rb b/lib/rails/generators/templates/config/environments/culerity_continuousintegration.rb similarity index 100% rename from rails_generators/culerity/templates/config/environments/culerity_continuousintegration.rb rename to lib/rails/generators/templates/config/environments/culerity_continuousintegration.rb diff --git a/rails_generators/culerity/templates/features/step_definitions/culerity_steps.rb b/lib/rails/generators/templates/features/step_definitions/culerity_steps.rb similarity index 100% rename from rails_generators/culerity/templates/features/step_definitions/culerity_steps.rb rename to lib/rails/generators/templates/features/step_definitions/culerity_steps.rb diff --git a/rails_generators/culerity/templates/features/support/env.rb b/lib/rails/generators/templates/features/support/env.rb similarity index 100% rename from rails_generators/culerity/templates/features/support/env.rb rename to lib/rails/generators/templates/features/support/env.rb diff --git a/rails_generators/culerity/templates/lib/tasks/culerity.rake b/lib/rails/generators/templates/lib/tasks/culerity.rake similarity index 84% rename from rails_generators/culerity/templates/lib/tasks/culerity.rake rename to lib/rails/generators/templates/lib/tasks/culerity.rake index 46a84f2..39ec4c0 100644 --- a/rails_generators/culerity/templates/lib/tasks/culerity.rake +++ b/lib/rails/generators/templates/lib/tasks/culerity.rake @@ -4,18 +4,18 @@ namespace 'culerity' do task :start do port = ENV['PORT'] || 3001 environment = ENV["RAILS_ENV"] || 'culerity' - pid_file = RAILS_ROOT + "/tmp/culerity_rails_server.pid" + pid_file = Rails.root.to_s + "/tmp/culerity_rails_server.pid" if File.exists?(pid_file) puts "culerity rails server already running; if not, delete tmp/culerity_rails_server.pid and try again" exit 1 end - rails_server = IO.popen("script/server -e #{environment} -p #{port}", 'r+') + rails_server = IO.popen("rails s -e #{environment} -p #{port}", 'r+') File.open(pid_file, "w") { |file| file << rails_server.pid } end desc "Stops the running rails server for cucumber/culerity tests" task :stop do - pid_file = RAILS_ROOT + "/tmp/culerity_rails_server.pid" + pid_file = Rails.root.to_s + "/tmp/culerity_rails_server.pid" if File.exists?(pid_file) pid = File.read(pid_file).to_i Process.kill(6, pid) diff --git a/rails_generators/culerity/templates/public/javascripts/culerity.js b/lib/rails/generators/templates/public/javascripts/culerity.js similarity index 100% rename from rails_generators/culerity/templates/public/javascripts/culerity.js rename to lib/rails/generators/templates/public/javascripts/culerity.js diff --git a/rails/init.rb b/lib/rails/init.rb similarity index 100% rename from rails/init.rb rename to lib/rails/init.rb diff --git a/rails_generators/culerity/culerity_generator.rb b/rails_generators/culerity/culerity_generator.rb deleted file mode 100644 index d91d02d..0000000 --- a/rails_generators/culerity/culerity_generator.rb +++ /dev/null @@ -1,26 +0,0 @@ -class CulerityGenerator < Rails::Generator::Base - - def manifest - record do |m| - m.directory 'features/step_definitions' - m.file 'features/step_definitions/culerity_steps.rb', 'features/step_definitions/culerity_steps.rb' - m.file 'features/support/env.rb', 'features/support/env.rb' - m.file 'config/environments/culerity.rb', 'config/environments/culerity.rb' - - m.gsub_file 'config/database.yml', /cucumber:.*\n/, "cucumber: &CUCUMBER\n" - - m.gsub_file 'config/database.yml', /\z/, "\nculerity:\n <<: *CUCUMBER" - - m.file "lib/tasks/culerity.rake", "lib/tasks/culerity.rake" - - m.file 'public/javascripts/culerity.js', 'public/javascripts/culerity.js' - end - end - -protected - - def banner - "Usage: #{$0} culerity" - end - -end diff --git a/rails_generators/culerity/templates/config/environments/culerity.rb b/rails_generators/culerity/templates/config/environments/culerity.rb deleted file mode 100644 index 9024569..0000000 --- a/rails_generators/culerity/templates/config/environments/culerity.rb +++ /dev/null @@ -1,22 +0,0 @@ -config.cache_classes = true # set because of https://rspec.lighthouseapp.com/projects/16211/tickets/165 - -# Log error messages when you accidentally call methods on nil. -config.whiny_nils = true - -# Show full error reports and disable caching -config.action_controller.consider_all_requests_local = true -config.action_controller.perform_caching = false -config.action_view.cache_template_loading = false - -# Disable request forgery protection in test environment -config.action_controller.allow_forgery_protection = false - -# Tell Action Mailer not to deliver emails to the real world. -# The :test delivery method accumulates sent emails in the -# ActionMailer::Base.deliveries array. -config.action_mailer.delivery_method = :persistent - -config.after_initialize do - require 'culerity/persistent_delivery' -end -