From 7ac3fc6f0f6fef4da81e4b8d80d8c0bb6116e8a6 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Thu, 26 Feb 2015 17:08:16 -0500 Subject: [PATCH] Add test setup --- .gitignore | 1 + Gemfile | 2 ++ Gemfile.rails40 | 4 ++++ Gemfile.rails41 | 4 ++++ Gemfile.rails42 | 4 ++++ Rakefile | 8 ++++++++ test/turbolinks/test_helper.rb | 34 ++++++++++++++++++++++++++++++++++ turbolinks.gemspec | 4 +++- 8 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 Gemfile create mode 100644 Gemfile.rails40 create mode 100644 Gemfile.rails41 create mode 100644 Gemfile.rails42 create mode 100644 Rakefile create mode 100644 test/turbolinks/test_helper.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..c8e48944 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.lock \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..851fabc2 --- /dev/null +++ b/Gemfile @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gemspec diff --git a/Gemfile.rails40 b/Gemfile.rails40 new file mode 100644 index 00000000..17db9ef9 --- /dev/null +++ b/Gemfile.rails40 @@ -0,0 +1,4 @@ +source 'https://rubygems.org' +gemspec + +gem 'rails', '~> 4.0.0' diff --git a/Gemfile.rails41 b/Gemfile.rails41 new file mode 100644 index 00000000..cfa7a6db --- /dev/null +++ b/Gemfile.rails41 @@ -0,0 +1,4 @@ +source 'https://rubygems.org' +gemspec + +gem 'rails', '~> 4.1.0' diff --git a/Gemfile.rails42 b/Gemfile.rails42 new file mode 100644 index 00000000..751cd232 --- /dev/null +++ b/Gemfile.rails42 @@ -0,0 +1,4 @@ +source 'https://rubygems.org' +gemspec + +gem 'rails', '~> 4.2.0' diff --git a/Rakefile b/Rakefile new file mode 100644 index 00000000..4dca9c5b --- /dev/null +++ b/Rakefile @@ -0,0 +1,8 @@ +require 'rake/testtask' + +Rake::TestTask.new do |t| + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.warning = true + t.verbose = true +end diff --git a/test/turbolinks/test_helper.rb b/test/turbolinks/test_helper.rb new file mode 100644 index 00000000..ca5b8cca --- /dev/null +++ b/test/turbolinks/test_helper.rb @@ -0,0 +1,34 @@ +require 'rails' +require 'abstract_controller' +require 'abstract_controller/railties/routes_helpers' +require 'action_controller' +require 'turbolinks' + +require 'active_support/testing/autorun' +require 'active_support/test_case' +ActiveSupport::TestCase.test_order = :random if ActiveSupport::TestCase.respond_to?(:test_order=) + +class TestApplication < Rails::Application + config.secret_token = Digest::SHA1.hexdigest(Time.now.to_s) + config.secret_key_base = SecureRandom.hex + config.eager_load = false + + initialize! + + routes.draw do + get ':controller(/:action)' + end +end + +module ActionController + class Base + extend AbstractController::Railties::RoutesHelpers.with(TestApplication.routes) + end + + class TestCase + def before_setup + @routes = TestApplication.routes + super + end + end +end diff --git a/turbolinks.gemspec b/turbolinks.gemspec index 74b3e1f2..4019609e 100644 --- a/turbolinks.gemspec +++ b/turbolinks.gemspec @@ -9,6 +9,8 @@ Gem::Specification.new do |s| s.homepage = 'https://github.com/rails/turbolinks/' s.summary = 'Turbolinks makes following links in your web application faster (use with Rails Asset Pipeline)' s.files = Dir["lib/assets/javascripts/*.js.coffee", "lib/turbolinks.rb", "lib/turbolinks/*.rb", "README.md", "MIT-LICENSE", "test/*"] - + s.test_files = Dir["test/*"] + s.add_dependency 'coffee-rails' + s.add_development_dependency 'rake' end