Skip to content

Commit

Permalink
Fix tests and deprecations for Rails v6 to v7.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaskills committed May 21, 2023
1 parent 8cf317b commit ac6146d
Show file tree
Hide file tree
Showing 32 changed files with 598 additions and 498 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ jobs:
strategy:
matrix:
ruby:
- '2.5.x'
- '2.6.x'
- "3.0.x"
- "3.1.x"
- "3.2.x"
rails:
- 'rails_v5.1.x'
- 'rails_v5.2.x'
- 'rails_v6.0.x'
- "rails_v6.0.x"
- "rails_v6.1.x"
- "rails_v7.0.x"
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v3
- name: Setup System
run: |
sudo apt-get install libsqlite3-dev
Expand Down
17 changes: 5 additions & 12 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@

appraise 'rails-v5.1.x' do
gem 'rails', '~> 5.1.0'
# https://github.com/rails/rails/issues/29031
gem 'minitest', '5.10.1'
end

appraise 'rails-v5.2.x' do
gem 'rails', '~> 5.2.0'
appraise 'rails_v6.0.x' do
gem 'rails', '~> 6.0.0'
gem 'minitest'
end

appraise 'rails_v6.0.x' do
gem 'rails', '~> 6.0.0'
appraise 'rails_v6.1.x' do
gem 'rails', '~> 6.1.0'
gem 'minitest'
end

appraise 'rails_v7.0.x' do
gem 'rails', '~> 7.0.0.alpha2'
gem 'rails', '~> 7.0.0'
gem 'minitest'
gem 'view_component', require: 'view_component/engine'
end
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## 6.3.0
## 7.0.0

- Add support for ActionCable::Channel::TestCase. Fixed #117. Thanks @tijn
- Remove automated tests for Rails v5 and Ruby v2.
- Update all of our tests and examples to use non-global expectations.
- Remove `Rails.application.reloader.to_prepare` for `ActionViewBehavior`.

## 6.2.0

Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ This <a href="https://chriskottom.com/freebies/cheatsheets_free.pdf">cheat sheet
assert_equal 100, foo

# MiniTest::Spec Assertion Style:
foo.must_equal 100
expect(foo).must_equal 100
```


Expand All @@ -72,7 +72,7 @@ require 'test_helper'
class UserTest < ActiveSupport::TestCase
let(:user_ken) { User.create! :email => '[email protected]' }
it 'works' do
user_ken.must_be_instance_of User
expect(user_ken).must_be_instance_of User
end
end
```
Expand Down Expand Up @@ -152,9 +152,9 @@ class ActiveSupportCallbackTest < ActiveSupport::TestCase
before { @bat = 'biz' }

it 'works' do
@foo.must_equal 'foo'
@bar.must_equal 'bar'
@bat.must_equal 'biz'
expect(@foo).must_equal 'foo'
expect(@bar).must_equal 'bar'
expect(@bat).must_equal 'biz'
end

private
Expand Down Expand Up @@ -194,11 +194,11 @@ end
If you prefer the assertions provided by shoulda-context like `assert_same_elements`, then you may want to consider copying them [from here](https://github.com/thoughtbot/shoulda-context/blob/master/lib/shoulda/context/assertions.rb) and including them in `MiniTest::Spec` yourself. I personally recommend just replacing these assertions with something more modern. A few examples are below.

```ruby
assert_same_elements a, b # From
a.sort.must_equal b.sort # To
assert_same_elements a, b # From
expect(a.sort).must_equal b.sort # To

assert_does_not_contain a, b # From
a.wont_include b # To
expect(a).wont_include b # To
```

### Matchers
Expand Down Expand Up @@ -274,9 +274,9 @@ $ bundle exec appraisal rake test
We use the [appraisal](https://github.com/thoughtbot/appraisal) gem from Thoughtbot to help us generate the individual gemfiles for each Rails version and to run the tests locally against each generated Gemfile. The `rake appraisal test` command actually runs our test suite against all Rails versions in our `Appraisal` file. If you want to run the tests for a specific Rails version, use `bundle exec appraisal -h` for a list. For example, the following command will run the tests for Rails 4.1 only.

```shell
$ bundle exec appraisal rails-v5.1.x rake test
$ bundle exec appraisal rails-v5.2.x rake test
$ bundle exec appraisal rails-v6.0.x rake test
$ bundle exec appraisal rails_v6.0.x rake test
$ bundle exec appraisal rails_v6.1.x rake test
$ bundle exec appraisal rails_v7.0.x rake test
```

We have a few branches for each major Rails version.
Expand Down
8 changes: 0 additions & 8 deletions gemfiles/rails_v5.1.x.gemfile

This file was deleted.

130 changes: 0 additions & 130 deletions gemfiles/rails_v5.1.x.gemfile.lock

This file was deleted.

136 changes: 0 additions & 136 deletions gemfiles/rails_v5.2.x.gemfile.lock

This file was deleted.

Loading

0 comments on commit ac6146d

Please sign in to comment.