diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..53607ea --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--colour diff --git a/Guardfile b/Guardfile new file mode 100644 index 0000000..4b67aaf --- /dev/null +++ b/Guardfile @@ -0,0 +1,47 @@ +guard 'rails' do + watch('Gemfile.lock') + watch(%r{^(config|lib)/.*}) +end + +guard 'livereload' do + watch(%r{app/views/.+\.(erb|haml|slim)}) + watch(%r{app/helpers/.+\.rb}) + watch(%r{public/.+\.(css|js|html)}) + watch(%r{config/locales/.+\.yml}) + # Rails Assets Pipeline + watch(%r{(app|vendor)/assets/\w+/(.+\.(css|js|html)).*}) { |m| "/assets/#{m[2]}" } +end + +guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' }, :wait => 45 do + watch('config/application.rb') + watch('config/environment.rb') + watch(%r{^config/environments/.+\.rb$}) + watch(%r{^config/initializers/.+\.rb$}) + watch('Gemfile') + watch('Gemfile.lock') + watch('spec/spec_helper.rb') { :rspec } + watch('test/test_helper.rb') { :test_unit } + watch(%r{features/support/}) { :cucumber } +end + +guard 'rspec', :version => 2, :cli => "--color --drb --tag ~no_drb --fail-fast -f #{ENV['RSPEC_FORMAT'] || 'progress'}", + :bundler => false, :all_after_pass => false, :all_on_start => false do + watch(%r{^spec/.+_spec\.rb$}) + watch(%r{app/(.*)\.rb}) { |m| "spec/#{m[1]}_spec.rb" } + watch(%r{app/(.*\.haml)}) { |m| "spec/#{m[1]}_spec.rb" } + watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { "spec" } + watch('spec/factories.rb') { "spec/models" } +end + +guard 'pow' do + watch('.powrc') + watch('.powenv') + watch('.rvmrc') + watch('Gemfile') + watch('Gemfile.lock') + watch('config/application.rb') + watch('config/environment.rb') + watch(%r{^config/environments/.*\.rb$}) + watch(%r{^config/initializers/.*\.rb$}) +end diff --git a/config/application.rb b/config/application.rb index 0b30b44..220e466 100644 --- a/config/application.rb +++ b/config/application.rb @@ -16,7 +16,9 @@ class Application < Rails::Application # -- all .rb files in that directory are automatically loaded. # Custom directories with classes and modules you want to be autoloadable. - # config.autoload_paths += %W(#{config.root}/extras) + config.autoload_paths += %W(#{config.root}/lib) + config.autoload_paths += Dir["#{config.root}/lib/**/"] + # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named. @@ -48,7 +50,7 @@ class Application < Rails::Application # This will create an empty whitelist of attributes available for mass-assignment for all models # in your app. As such, your models will need to explicitly whitelist or blacklist accessible # parameters by using an attr_accessible or attr_protected declaration. - # config.active_record.whitelist_attributes = true + config.active_record.whitelist_attributes = true # Enable the asset pipeline config.assets.enabled = true diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..0b8c008 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,55 @@ +require 'rubygems' +require 'spork' + +Spork.prefork do + + # This file is copied to spec/ when you run 'rails generate rspec:install' + ENV["RAILS_ENV"] ||= 'test' + + if Spork.using_spork? + require "rails/application" + Spork.trap_method(Rails::Application::RoutesReloader, :reload!) + end + + require File.expand_path("../../config/environment", __FILE__) + + require 'rspec/rails' + require 'rspec/autorun' + + # Requires supporting ruby files with custom matchers and macros, etc, + # in spec/support/ and its subdirectories. + Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} + + RSpec.configure do |config| + + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If true, the base class of anonymous controllers will be inferred + # automatically. This will be the default behavior in future versions of + # rspec-rails. + config.infer_base_class_for_anonymous_controllers = false + end +end + +Spork.each_run do + Rails.logger.level = 4 + + # http://blog.plataformatec.com.br/2011/12/three-tips-to-improve-the-performance-of-your-test-suite/ + class ActiveRecord::Base + mattr_accessor :shared_connection + @@shared_connection = nil + + def self.connection + @@shared_connection || retrieve_connection + end + end + end