Skip to content

Commit

Permalink
Add support for Rails 4
Browse files Browse the repository at this point in the history
* add rails4 default gems as development dependencies
* drop support for Rails 3.0.x
* move gems used for developoment and testing to Gemfile
  * (to allow using git url, and to try a new strategy of specifying development gems)
  • Loading branch information
Greg Lazarev committed Jul 15, 2013
1 parent 9d2f949 commit cf16188
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 55 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*.swp
*~
.bundle
bin/
db/*.sqlite3
gemfiles/
log/*.log
Expand Down
6 changes: 3 additions & 3 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if RUBY_VERSION >= '2.0'
rails_versions = ['~> 3.2.13']
if RUBY_VERSION >= '1.9.3'
rails_versions = ['~> 3.2.13', '~> 4.0.0']
else
rails_versions = ['~> 3.0.20', '~> 3.1.12', '~> 3.2.13']
rails_versions = ['~> 3.1.12']
end

rails_versions.each do |rails_version|
Expand Down
15 changes: 15 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
source 'https://rubygems.org'

gemspec

gem 'appraisal', '~> 0.5'
gem 'aruba', '~> 0.5'
gem 'bourne', '~> 1.4'
gem 'bundler', '~> 1.3'
gem 'capybara', '~> 2.0.3'
gem 'cucumber-rails', '~> 1.3'
gem 'database_cleaner', '~> 1.0'
gem 'factory_girl_rails', '~> 4.2'
gem 'jbuilder', '~> 1.2'
gem 'rspec-rails', '~> 2.13'
gem 'sdoc'
gem 'shoulda-matchers', github: 'thoughtbot/shoulda-matchers' , branch: 'dp-rails-four'
gem 'sqlite3', '~> 1.3'
gem 'timecop', '~> 0.6'
29 changes: 19 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
GIT
remote: git://github.com/thoughtbot/shoulda-matchers.git
revision: 96e734d8946151ebf0e0d4488d05f2da30fdb59a
branch: dp-rails-four
specs:
shoulda-matchers (2.1.0)
activesupport (>= 3.0.0)

PATH
remote: .
specs:
clearance (1.0.0.rc7)
bcrypt-ruby
email_validator (~> 1.4)
rails (>= 3.0)
rails (>= 3.1)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -44,7 +52,7 @@ GEM
childprocess (>= 0.3.6)
cucumber (>= 1.1.1)
rspec-expectations (>= 2.7.0)
bcrypt-ruby (3.0.1)
bcrypt-ruby (3.1.1)
bourne (1.4.0)
mocha (~> 0.13.2)
builder (3.0.4)
Expand Down Expand Up @@ -82,6 +90,9 @@ GEM
multi_json (~> 1.3)
hike (1.2.3)
i18n (0.6.4)
jbuilder (1.4.2)
activesupport (>= 3.0.0)
multi_json (>= 1.2.0)
journey (1.0.4)
json (1.8.0)
mail (2.4.4)
Expand Down Expand Up @@ -122,10 +133,6 @@ GEM
rake (10.1.0)
rdoc (3.12.2)
json (~> 1.4)
rspec (2.13.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
Expand All @@ -138,13 +145,14 @@ GEM
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
rubyzip (0.9.9)
sdoc (0.3.20)
json (>= 1.1.3)
rdoc (~> 3.10)
selenium-webdriver (2.33.0)
childprocess (>= 0.2.5)
multi_json (~> 1.0)
rubyzip
websocket (~> 1.0.4)
shoulda-matchers (2.2.0)
activesupport (>= 3.0.0)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
Expand Down Expand Up @@ -175,8 +183,9 @@ DEPENDENCIES
cucumber-rails (~> 1.3)
database_cleaner (~> 1.0)
factory_girl_rails (~> 4.2)
rspec (~> 2.13)
jbuilder (~> 1.2)
rspec-rails (~> 2.13)
shoulda-matchers (~> 2.2)
sdoc
shoulda-matchers!
sqlite3 (~> 1.3)
timecop (~> 0.6)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Read [CONTRIBUTING.md](/CONTRIBUTING.md) to contribute.
Install
-------

Clearance is a Rails engine tested against Rails 3.x on Ruby 1.9.x and
Clearance is a Rails engine tested against Rails `>= 3.1` on Ruby 1.9.x, and
Rails `>= 3.2.13` on Ruby 2.0

Include the gem in your Gemfile:
Expand Down
16 changes: 1 addition & 15 deletions clearance.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,5 @@ Gem::Specification.new do |s|

s.add_dependency 'bcrypt-ruby'
s.add_dependency 'email_validator', '~> 1.4'
s.add_dependency 'rails', '>= 3.0'

s.add_development_dependency 'appraisal', '~> 0.5'
s.add_development_dependency 'aruba', '~> 0.5'
s.add_development_dependency 'bourne', '~> 1.4'
s.add_development_dependency 'bundler', '~> 1.3'
s.add_development_dependency 'capybara', '~> 2.0.3'
s.add_development_dependency 'cucumber-rails', '~> 1.3'
s.add_development_dependency 'database_cleaner', '~> 1.0'
s.add_development_dependency 'factory_girl_rails', '~> 4.2'
s.add_development_dependency 'rspec', '~> 2.13'
s.add_development_dependency 'rspec-rails', '~> 2.13'
s.add_development_dependency 'shoulda-matchers', '~> 2.2'
s.add_development_dependency 'sqlite3', '~> 1.3'
s.add_development_dependency 'timecop', '~> 0.6'
s.add_dependency 'rails', '>= 3.1'
end
28 changes: 16 additions & 12 deletions features/step_definitions/configuration_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
step "I successfully run `bundle exec rails new testapp --skip-bundle --skip-javascript --skip-sprockets`"
end

step 'I cd to "testapp"'

unless Clearance::Testing.rails4?
step 'I remove the file "public/index.html"'
end

steps %Q{
When I cd to "testapp"
And I remove the file "public/index.html"
And I remove the file "app/views/layouts/application.html.erb"
And I configure ActionMailer to use "localhost" as a host
And I configure a root route
Expand Down Expand Up @@ -62,19 +66,11 @@ def show
'clearance.rb'
)
steps %Q{
And I write to "test/test_helper.rb" with:
When I append to "test/test_helper.rb" with:
"""
ENV['RAILS_ENV'] = 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
fixtures :all
end
require 'clearance/testing'
"""
And I write to "test/functional/posts_controller_test.rb" with:
And I overwrite "test/#{controller_test_dir}/posts_controller_test.rb" with:
"""
require 'test_helper'
Expand Down Expand Up @@ -136,3 +132,11 @@ def self.down
"""
}
end

def controller_test_dir
if Clearance::Testing.rails4?
'controllers'
else
'functional'
end
end
26 changes: 13 additions & 13 deletions lib/clearance/testing/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ module Clearance
module Testing
APP_ROOT = File.expand_path('..', __FILE__).freeze

def self.rails4?
Rails::VERSION::MAJOR == 4
end

class Application < Rails::Application
config.action_controller.allow_forgery_protection = false
config.action_controller.perform_caching = false
config.action_dispatch.show_exceptions = false
config.action_mailer.default_url_options = { :host => 'localhost' }
config.action_mailer.delivery_method = :test
config.active_support.deprecation = :stderr
config.assets.enabled = true
config.cache_classes = true
config.consider_all_requests_local = true
config.eager_load = false
config.encoding = 'utf-8'
config.paths['app/controllers'] << "#{APP_ROOT}/app/controllers"
config.paths['app/views'] << "#{APP_ROOT}/app/views"
config.paths['config/database'] = "#{APP_ROOT}/config/database.yml"
config.paths['log'] = 'tmp/log/development.log'
config.secret_token = 'SECRET_TOKEN_IS_MIN_30_CHARS_LONG'
config.whiny_nils = true

if Rails::VERSION::MAJOR >= 3 && Rails::VERSION::MINOR >= 1
config.assets.enabled = true
config.paths['app/controllers'] << "#{APP_ROOT}/app/controllers"
config.paths['app/views'] << "#{APP_ROOT}/app/views"
config.paths['config/database'] = "#{APP_ROOT}/config/database.yml"
config.paths['config/routes'] << "#{APP_ROOT}/config/routes.rb"
config.paths['log'] = 'tmp/log/development.log'
if Clearance::Testing.rails4?
config.paths.add 'config/routes.rb', with: "#{APP_ROOT}/config/routes.rb"
else
config.paths.app.controllers << "#{APP_ROOT}/app/controllers"
config.paths.app.views << "#{APP_ROOT}/app/views"
config.paths.config.database = "#{APP_ROOT}/config/database.yml"
config.paths.config.routes << "#{APP_ROOT}/config/routes.rb"
config.paths.log = 'tmp/log'
config.paths.add 'config/routes', with: "#{APP_ROOT}/config/routes.rb"
end

def require_environment!
Expand Down

0 comments on commit cf16188

Please sign in to comment.