Skip to content

Commit 111f536

Browse files
committed
Add Travis and testing of Rails 3.2, 4.1, 4.2, 5.0
1 parent 33f7feb commit 111f536

14 files changed

+139
-36
lines changed

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.DS_Store
2-
nbproject/*
32
*.gem
43
.idea/*
54
Gemfile.lock
6-
._test
5+
._test
6+
*.log

.travis.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
language: ruby
2+
3+
gemfile:
4+
- gemfiles/rails3_2.gemfile
5+
- gemfiles/rails4_1.gemfile
6+
- gemfiles/rails4_2.gemfile
7+
- gemfiles/rails5_0.gemfile
8+
9+
rvm:
10+
- 1.9.3
11+
- 2.0.0
12+
- 2.2.2
13+
- jruby-1.7.23
14+
- jruby-9.0.5.0
15+
16+
matrix:
17+
exclude:
18+
- rvm: 1.9.3
19+
gemfile: gemfiles/rails5_0.gemfile
20+
- rvm: 2.0.0
21+
gemfile: gemfiles/rails5_0.gemfile
22+
- rvm: jruby-1.7.23
23+
gemfile: gemfiles/rails5_0.gemfile
24+
25+
notifications:
26+
email: false
27+
28+
bundler_args: --without development
29+
30+
services:
31+
- mongodb
32+
33+
sudo: false
34+
35+
# Gitter integration
36+
notifications:
37+
webhooks:
38+
urls:
39+
- https://webhooks.gitter.im/e/4d6749e48eb60321640e
40+
on_success: change # options: [always|never|change] default: always
41+
on_failure: always # options: [always|never|change] default: always
42+
on_start: never # options: [always|never|change] default: always

Gemfile

+3-16
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
source 'https://rubygems.org'
1+
eval File.read(File.expand_path('../gemfiles/Gemfile.common.rb', __FILE__)), nil, 'Gemfile.common.rb'
22

3-
gemspec
4-
5-
gem 'rails', '~> 3.2.0'
3+
gem 'rails', '~> 5.0.0.beta3'
64

7-
gem 'rake', '~> 10.0'
8-
gem 'minitest'
9-
gem 'minitest-reporters'
10-
gem 'minitest-rails'
11-
gem 'awesome_print'
12-
gem 'awesome_print'
13-
# For Rails 3.2
14-
gem 'test-unit'
15-
16-
gem 'sqlite3', platform: :ruby
17-
gem 'jdbc-sqlite3', platform: :jruby
18-
gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
5+
gemspec

gemfiles/Gemfile.common.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'rake', '~> 10.0'
4+
gem 'minitest'
5+
gem 'minitest-reporters'
6+
gem 'minitest-stub_any_instance'
7+
gem 'awesome_print'
8+
9+
gem 'sqlite3', platform: :ruby
10+
gem 'jdbc-sqlite3', platform: :jruby
11+
gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby

gemfiles/rails3_2.gemfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
eval File.read(File.expand_path('../Gemfile.common.rb', __FILE__)), nil, 'Gemfile.common.rb'
2+
gemspec :path => '../'
3+
4+
gem 'rails', '~> 3.2.0'
5+
gem 'test-unit'
6+
gem 'minitest-rails'

gemfiles/rails4_1.gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
eval File.read(File.expand_path('../Gemfile.common.rb', __FILE__)), nil, 'Gemfile.common.rb'
2+
gemspec :path => '../'
3+
4+
gem 'rails', '~> 4.1.0'

gemfiles/rails4_2.gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
eval File.read(File.expand_path('../Gemfile.common.rb', __FILE__)), nil, 'Gemfile.common.rb'
2+
gemspec :path => '../'
3+
4+
gem 'rails', '~> 4.2.0'

gemfiles/rails5_0.gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
eval File.read(File.expand_path('../Gemfile.common.rb', __FILE__)), nil, 'Gemfile.common.rb'
2+
gemspec :path => '../'
3+
4+
gem 'rails', '~> 5.0.0.beta3'

test/active_job_test.rb

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require_relative 'test_helper'
2+
3+
class ActiveJobTest < Minitest::Test
4+
if defined?(ActiveJob)
5+
class MyJob < ActiveJob::Base
6+
queue_as :my_jobs
7+
8+
def perform(record)
9+
"Received: #{record}"
10+
end
11+
end
12+
end
13+
14+
describe 'ActiveJob' do
15+
before do
16+
skip 'Older rails does not support ActiveJob' unless defined?(ActiveJob)
17+
end
18+
19+
describe '.perform_now' do
20+
it 'sets the ActiveJob logger' do
21+
assert_kind_of SemanticLogger::Logger, MyJob.logger
22+
end
23+
24+
it 'runs the job' do
25+
MyJob.perform_now('hello')
26+
end
27+
end
28+
29+
end
30+
end

test/dummy/config/environments/development.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
config.action_dispatch.best_standards_support = :builtin
2424

2525
# Raise exception on mass assignment protection for Active Record models
26-
config.active_record.mass_assignment_sanitizer = :strict
26+
#config.active_record.mass_assignment_sanitizer = :strict
2727

2828
# Log the query plan for queries taking more than this (works
2929
# with SQLite, MySQL, and PostgreSQL)

test/dummy/config/environments/test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
# Configure static asset server for tests with Cache-Control for performance
1111
config.serve_static_assets = true
12-
config.static_cache_control = "public, max-age=3600"
1312

1413
# Log error messages when you accidentally call methods on nil
1514
config.whiny_nils = true
15+
config.eager_load = false
1616

1717
# Show full error reports and disable caching
1818
config.consider_all_requests_local = true
@@ -30,7 +30,7 @@
3030
config.action_mailer.delivery_method = :test
3131

3232
# Raise exception on mass assignment protection for Active Record models
33-
config.active_record.mass_assignment_sanitizer = :strict
33+
#config.active_record.mass_assignment_sanitizer = :strict
3434

3535
# Print deprecation notices to the stderr
3636
config.active_support.deprecation = :stderr

test/dummy/log/test.log

-9
This file was deleted.

test/rails_test.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
require_relative 'test_helper'
22

3-
class RailsTest < ActiveSupport::TestCase
4-
test 'truth' do
5-
assert_kind_of SemanticLogger::Logger, Rails.logger
3+
class RailsTest < Minitest::Test
4+
describe 'Rails' do
5+
describe '.logger' do
6+
it 'sets the Rails logger' do
7+
assert_kind_of SemanticLogger::Logger, Rails.logger
8+
end
9+
end
610
end
711
end

test/test_helper.rb

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
1+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
2+
13
# Configure Rails Environment
24
ENV['RAILS_ENV'] = 'test'
35

46
require File.expand_path('../dummy/config/environment.rb', __FILE__)
57
require 'rails/test_help'
68

7-
Rails.backtrace_cleaner.remove_silencers!
9+
#Rails.backtrace_cleaner.remove_silencers!
810

9-
require 'minitest/rails'
11+
require 'minitest/autorun'
1012
require 'minitest/reporters'
13+
require 'minitest/stub_any_instance'
14+
require 'awesome_print'
15+
require 'rails_semantic_logger'
1116

12-
# See every test and how long it took
1317
MiniTest::Reporters.use! MiniTest::Reporters::SpecReporter.new
18+
19+
# Rails 5
20+
#
21+
# ActiveRecord::Migrator.migrations_paths = [File.expand_path('../../test/dummy/db/migrate', __FILE__)]
22+
#
23+
# # Filter out Minitest backtrace while allowing backtrace from other libraries
24+
# # to be shown.
25+
# Minitest.backtrace_filter = Minitest::BacktraceFilter.new
26+
#
27+
# # Load fixtures from the engine
28+
# if ActiveSupport::TestCase.respond_to?(:fixture_path=)
29+
# ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
30+
# ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
31+
# ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files"
32+
# ActiveSupport::TestCase.fixtures :all
33+
# end

0 commit comments

Comments
 (0)