Skip to content

Commit

Permalink
Get tests passing after gem updates
Browse files Browse the repository at this point in the history
- Lock sqlite3 to 1.3.x
- Downgrade to bundler 1.x
- Test non-EOL ruby versions
- Move make_site.sh to scripts/
- Add scripts/run_tests.sh
  • Loading branch information
drewish committed Apr 1, 2019
1 parent f8fb9d4 commit 8d9ab25
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ Style/IndentationConsistency:
Style/IndentationWidth:
Description: 'Use 2 spaces for indentation.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-indentation'
Enabled: false
Enabled: true

Style/IndentArray:
Description: >-
Expand Down Expand Up @@ -708,7 +708,7 @@ Style/LambdaCall:
Style/LeadingCommentSpace:
Description: 'Comments should start with a space.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-space'
Enabled: false
Enabled: true

Style/LineEndConcatenation:
Description: >-
Expand Down
15 changes: 11 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
language: ruby
rvm:
- 2.2
- 2.3
- 2.4
- 2.5
- 2.6
env:
- RAILS_VERSION=3.2.0
- RAILS_VERSION=4.2.0
- RAILS_VERSION=5.1.0
- RAILS_VERSION=5.2.0
cache: bundler
install: ./make_site.sh
script: bundle exec rspec
before_install:
# Revert to bundler 1.x for compatibility with Rails 4.2 on Ruby 2.5
- "find /home/travis/.rvm/rubies -wholename '*default/bundler-*.gemspec' -delete"
- rvm @global do gem uninstall bundler -a -x -I || true
- gem install bundler -v '~> 1.17'
install: scripts/make_site.sh
script: scripts/run_tests.sh
matrix:
exclude:
- rvm: 2.4
env: RAILS_VERSION=3.2.0
- rvm: 2.5
env: RAILS_VERSION=3.2.0
- rvm: 2.6
env: RAILS_VERSION=3.2.0
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

## Running tests

The `make_site.sh` script will create a test site for a specific version of
Rails and run the tests:
The `scripts/make_site.sh` script will create a test site for a specific version of
Rails:
```
RAILS_VERSION=4.2.0
./make_site.sh
export RAILS_VERSION=4.2.0
scripts/make_site.sh
```

Once the test site is created you can just re-run the tests:
Once the test site is created you can run the tests:
```
bundle exec rspec
scripts/run_tests.sh
```
29 changes: 15 additions & 14 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ source "https://rubygems.org"
gemspec

# Allow the rails version to come from an ENV setting so Tavis can test multiple
# versions. Inspired by http://www.schneems.com/post/50991826838/testing-against-multiple-rails-versions/
rails_version = ENV['RAILS_VERSION'] || '3.2.22'
# versions.
rails_version = ENV['RAILS_VERSION'] || '5.2.0'
rails_major = rails_version.split('.').first
rails_gem = case rails_version
when "default" then
"~> 5.0.0"
else
"~> #{rails_version}"
end

gem 'rails', rails_gem
gem 'sqlite3'
gem 'rails', "~> #{rails_version}"
gem 'pry'
gem 'pry-byebug'
gem 'sqlite3', '~> 1.3.13'

# Rails 3 requires this but it was removed in Ruby 2.2
gem 'test-unit', '~> 3.0' if rails_major == '3'
# Need this for Rails 4 to get the JSON responses from the scaffold
gem 'jbuilder' if rails_major == '4'
case rails_major
when '3'
# Rails 3 requires this but it was removed in Ruby 2.2
gem 'test-unit', '~> 3.0'
when '4'
# Need this for Rails 4 to get the JSON responses from the scaffold
gem 'jbuilder'
when '5'
# Required for 5.2+
gem 'bootsnap'
end
15 changes: 4 additions & 11 deletions make_site.sh → scripts/make_site.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
#!/bin/bash
set -x
set -x -e

# export RAILS_VERSION=3.2.0
# export RAILS_VERSION=4.0.0
# export RAILS_VERSION=5.0.0
major=$(echo $RAILS_VERSION | cut -d '.' -f1)

rm Gemfile.lock
rm Gemfile.lock || true
bundle install

rm -r spec/testapp
rm -r spec/testapp || true
bundle exec rails new spec/testapp --api -d sqlite3 --skip-gemfile --skip-bundle --skip-test-unit --skip-action-mailer --skip-puma --skip-action-cable --skip-sprockets --skip-javascript --skip-spring --skip-listen
cd spec/testapp

bundle exec rails generate scaffold Post title:string body:text
rm -r spec
rm -r spec || true

if [ $major -eq 5 ]
then
Expand All @@ -26,7 +23,3 @@ else
fi

cd -

bundle exec rspec
# Duplicating the body of the rake task. Need to figure out how to call it directly.
bundle exec rspec -f RSpec::Rails::Swagger::Formatter --order defined -t swagger_object
6 changes: 6 additions & 0 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -x -e

bundle exec rspec
# Duplicating the body of the rake task. Need to figure out how to call it directly.
bundle exec rspec -f RSpec::Rails::Swagger::Formatter --order defined -t swagger_object

0 comments on commit 8d9ab25

Please sign in to comment.