Skip to content

Make rspec-rails compatible with Rails v6.1.0.rc2 #2408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ jobs:
fail-fast: false
matrix:
include:
# Rails 6.1 builds >= 2.5
# Rails Master builds >= 2.5
- ruby: ruby-3.0.0-preview1
allow_failure: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're adding Rails master builds as well as rc builds master should be allowed to fail.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

env:
RAILS_VERSION: 'master'
- ruby: 2.7.1
Expand All @@ -31,6 +30,20 @@ jobs:
env:
RAILS_VERSION: 'master'

# Rails 6.1.0.rc2 builds >= 2.5
- ruby: ruby-3.0.0-preview1
env:
RAILS_VERSION: '6.1.0.rc2'
- ruby: 2.7.1
env:
RAILS_VERSION: '6.1.0.rc2'
- ruby: 2.6.6
env:
RAILS_VERSION: '6.1.0.rc2'
- ruby: 2.5.8
env:
RAILS_VERSION: '6.1.0.rc2'

# Rails 6.0 builds >= 2.5.0
- ruby: 3.0.0-preview1
env:
Expand Down
7 changes: 1 addition & 6 deletions example_app_generator/generate_action_mailer_specs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,10 @@
end
end
CODE
gsub_file 'config/initializers/action_mailer.rb',
/ExampleApp/,
Rails.application.class.parent.to_s

copy_file 'spec/support/default_preview_path'
chmod 'spec/support/default_preview_path', 0755
gsub_file 'spec/support/default_preview_path',
/ExampleApp/,
Rails.application.class.parent.to_s

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm convinced these are still needed, its just the Rails 6.1 implementation might need to change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deep dive a little bit on this few weeks ago. The Rails.application.class.parent on previous Rails is ExampleApp. So I didn't understand why the gsub was needed.
Also if the CI pass isn't what we want?

if skip_active_record?
comment_lines 'spec/support/default_preview_path', /active_record/
comment_lines 'spec/support/default_preview_path', /active_storage/
Expand Down
2 changes: 2 additions & 0 deletions features/controller_specs/anonymous_controller.feature
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ Feature: anonymous controller
When I run `rspec spec`
Then the examples should all pass

# Deprecated support removed in https://github.com/rails/rails/commit/d52d7739468153bd6cb7c629f60bd5cd7ebea3eb
@rails_pre_6
Scenario: Specify error handling in `ApplicationController` with render :file
Given a file named "spec/controllers/application_controller_spec.rb" with:
"""ruby
Expand Down
19 changes: 14 additions & 5 deletions lib/rspec/rails/matchers/action_mailbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@ def initialize(message)
@inbound_email = create_inbound_email(message)
end

def matches?(mailbox)
@mailbox = mailbox
@receiver = ApplicationMailbox.router.send(:match_to_mailbox, inbound_email)
if defined?(::ApplicationMailbox) && ::ApplicationMailbox.router.respond_to?(:mailbox_for)
def matches?(mailbox)
@mailbox = mailbox
@receiver = ApplicationMailbox.router.mailbox_for(inbound_email)

@receiver == @mailbox
@receiver == @mailbox
end
else
def matches?(mailbox)
@mailbox = mailbox
@receiver = ApplicationMailbox.router.send(:match_to_mailbox, inbound_email)

@receiver == @mailbox
end
end

def failure_message
Expand All @@ -41,7 +50,7 @@ def failure_message_when_negated
"expected #{describe_inbound_email} not to route to #{mailbox}"
end

private
private

attr_reader :inbound_email, :mailbox, :receiver

Expand Down