From 4f6004e0a4c2b6e1fff0648a70ef26b463ac2045 Mon Sep 17 00:00:00 2001 From: fahchen <06fahchen@gmail.com> Date: Wed, 30 Jan 2013 17:36:48 +0800 Subject: [PATCH] switch test-unit -> rspec, erb -> slim, fixture -> factory_girl --- Gemfile | 10 ++++++++++ Gemfile.lock | 36 ++++++++++++++++++++++++++++++++++++ config/application.rb | 5 +++++ spec/spec_helper.rb | 38 ++++++++++++++++++++++++++++++++++++++ test/controllers/.keep | 0 test/fixtures/.keep | 0 test/helpers/.keep | 0 test/integration/.keep | 0 test/mailers/.keep | 0 test/models/.keep | 0 test/test_helper.rb | 7 ------- 11 files changed, 89 insertions(+), 7 deletions(-) create mode 100644 spec/spec_helper.rb delete mode 100644 test/controllers/.keep delete mode 100644 test/fixtures/.keep delete mode 100644 test/helpers/.keep delete mode 100644 test/integration/.keep delete mode 100644 test/mailers/.keep delete mode 100644 test/models/.keep delete mode 100644 test/test_helper.rb diff --git a/Gemfile b/Gemfile index 7dbe6b3..69c9598 100644 --- a/Gemfile +++ b/Gemfile @@ -41,3 +41,13 @@ gem 'jbuilder', '~> 1.0.1' # Mongodb gem 'mongoid', git: 'git://github.com/mongoid/mongoid.git', branch: '4.0.0-dev' + +gem 'slim-rails' + +# Server +gem 'thin' + +group :test, :development do + gem 'rspec-rails', '~> 2.12.2' + gem 'factory_girl_rails', '~> 4.2.0' +end diff --git a/Gemfile.lock b/Gemfile.lock index 04a2f95..48e54af 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -99,9 +99,17 @@ GEM coffee-script-source execjs coffee-script-source (1.4.0) + daemons (1.1.9) + diff-lcs (1.1.3) erubis (2.7.0) + eventmachine (1.0.0) execjs (1.4.0) multi_json (~> 1.0) + factory_girl (4.2.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.2.0) + factory_girl (~> 4.2.0) + railties (>= 3.0.0) hike (1.2.1) i18n (0.6.1) jbuilder (1.0.2) @@ -126,12 +134,36 @@ GEM rake (10.0.3) rdoc (3.12) json (~> 1.4) + rspec-core (2.12.2) + rspec-expectations (2.12.1) + diff-lcs (~> 1.1.3) + rspec-mocks (2.12.1) + rspec-rails (2.12.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 2.12.0) + rspec-expectations (~> 2.12.0) + rspec-mocks (~> 2.12.0) sass (3.2.5) + slim (1.3.6) + temple (~> 0.5.5) + tilt (~> 1.3.3) + slim-rails (1.1.0) + actionpack (>= 3.0, < 4.1) + activesupport (>= 3.0, < 4.1) + railties (>= 3.0, < 4.1) + slim (~> 1.3) sprockets (2.8.2) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) + temple (0.5.5) + thin (1.5.0) + daemons (>= 1.0.9) + eventmachine (>= 0.12.6) + rack (>= 1.0.0) thor (0.17.0) thread_safe (0.1.0) atomic @@ -153,11 +185,15 @@ DEPENDENCIES activerecord-deprecated_finders! arel! coffee-rails! + factory_girl_rails (~> 4.2.0) jbuilder (~> 1.0.1) jquery-rails mongoid! rails! + rspec-rails (~> 2.12.2) sass-rails! + slim-rails sprockets-rails! + thin turbolinks uglifier (>= 1.0.3) diff --git a/config/application.rb b/config/application.rb index 07a8568..bb0a098 100644 --- a/config/application.rb +++ b/config/application.rb @@ -32,5 +32,10 @@ module QingshuiTemple # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" + config.generators do |g| + g.test_framework :rspec + g.fixture_replacement :factory_girl, :dir => "spec/factories" + end + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..0909127 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,38 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV["RAILS_ENV"] ||= 'test' +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| + # ## Mock Framework + # + # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: + # + # config.mock_with :mocha + # config.mock_with :flexmock + # config.mock_with :rr + + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/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 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 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = "random" +end diff --git a/test/controllers/.keep b/test/controllers/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/fixtures/.keep b/test/fixtures/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/helpers/.keep b/test/helpers/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/integration/.keep b/test/integration/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/mailers/.keep b/test/mailers/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/models/.keep b/test/models/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/test_helper.rb b/test/test_helper.rb deleted file mode 100644 index 8298517..0000000 --- a/test/test_helper.rb +++ /dev/null @@ -1,7 +0,0 @@ -ENV["RAILS_ENV"] = "test" -require File.expand_path('../../config/environment', __FILE__) -require 'rails/test_help' - -class ActiveSupport::TestCase - # Add more helper methods to be used by all tests here... -end