Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ab41d70
Improve controller template when no action
Oct 20, 2020
0769933
fix pr according to @pirj remarks
mustapha-stockoss Oct 20, 2020
5f6a713
Merge pull request #1 from mustapha-stockoss/feat/ticket-2375
ThHareau Oct 21, 2020
14ed3ca
Fix rubocop error
Oct 21, 2020
ed75485
Update expected rspec versions
JonRowe Oct 30, 2020
ea09924
Merge pull request #2399 from ThHareau/feat/ticket-2375
pirj Oct 31, 2020
f057558
Changelog for #2399
JonRowe Nov 1, 2020
934276b
Add exception for rspec ci
JonRowe Nov 17, 2020
fb018f1
Move MRI build to Github Actions
benoittgt Nov 3, 2020
1d12c96
Avoid 'mountable_engine?' stub to leak to next specs in the same file
benoittgt Nov 20, 2020
6b7eec0
Run the same branch on GA and Travis
benoittgt Nov 21, 2020
08bdd11
Share env variables to other steps with RSpec scripts
benoittgt Nov 21, 2020
7667604
Fix argument error on Ruby3.0.preview1 and ActionMailer
benoittgt Nov 21, 2020
e265a35
Reduce dup by moving env and continue-on-error before steps
benoittgt Nov 21, 2020
6394472
Revert to previous working commands to install dependencies
benoittgt Nov 22, 2020
67a9899
Set explicit hash as last arg to avoid "wrong number of arguments" error
benoittgt Nov 22, 2020
029416b
continue-on-error seems to work only when defined in step
benoittgt Nov 22, 2020
9217638
Merge pull request #2404 from rspec/move-to-github-actions
JonRowe Nov 23, 2020
2b41dc9
Setup rails 6.1 builds
JonRowe Oct 15, 2020
34f37c3
Switch accessor for fixture path in file upload support for 6.1
JonRowe Oct 15, 2020
fdd88df
Fix controller spec on Rails 6.1
JonRowe Oct 16, 2020
c7e14ea
Fix view specs on Rails 6.1
JonRowe Oct 16, 2020
05f3a2c
Prevent undefined method 'parent' for ExampleApp::Application:Class
benoittgt Nov 1, 2020
693116d
Skip test for deprecated support of relative paths to `render file:`
benoittgt Nov 1, 2020
b1a0a5a
Switch to first release candidate of Rails
benoittgt Nov 3, 2020
3fe8fca
Use mailbox_for when available
benoittgt Nov 3, 2020
5da7f4e
Add missing jRuby from rails 6.1 first release candidtate
benoittgt Nov 8, 2020
2163b2e
Add Rails 6.1 rc1 to Github Action CI
benoittgt Nov 23, 2020
6c4c061
Merge branch 'rails-6-1-dev' into wip-rails-6-1-dev
benoittgt Nov 24, 2020
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
106 changes: 106 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: RSpec CI
on:
push:
branches:
- 'main'
- '*-maintenance'
- '*-dev'
pull_request:
branches:
- '*'
jobs:
test:
name: 'Ruby: ${{ matrix.ruby }}, Rails: ${{ matrix.env.RAILS_VERSION }}'
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
# Rails 6.1.0.rc1 builds >= 2.5.0
- ruby: 3.0.0-preview1
env:
RAILS_VERSION: '6.1.0.rc1'
- ruby: 2.7
env:
RAILS_VERSION: '6.1.0.rc1'
- ruby: 2.6
env:
RAILS_VERSION: '6.1.0.rc1'
- ruby: 2.5
env:
RAILS_VERSION: '6.1.0.rc1'
# Rails 6.0 builds >= 2.5.0
- ruby: 3.0.0-preview1
env:
RAILS_VERSION: '~> 6.0.0'
- ruby: 2.7
env:
RAILS_VERSION: '~> 6.0.0'
- ruby: 2.6
env:
RAILS_VERSION: '~> 6.0.0'
- ruby: 2.5
env:
RAILS_VERSION: '~> 6.0.0'
# Rails 5.2 builds >= 2.2.2
- ruby: 2.6.6
env:
RAILS_VERSION: '~> 5.2.0'
- ruby: 2.5.8
env:
RAILS_VERSION: '~> 5.2.0'
- ruby: 2.4.10
env:
RAILS_VERSION: '~> 5.2.0'
- ruby: 2.3.8
env:
RAILS_VERSION: '~> 5.2.0'
- ruby: 2.2.10
allow_failure: true
env:
RAILS_VERSION: '~> 5.2.0'
- ruby: 2.2.10
env:
RAILS_VERSION: '5-2-stable'
# Rails 5.1 Builds >= 2.2.2
- ruby: 2.6.6
env:
RAILS_VERSION: '~> 5.1.0'
- ruby: 2.5.8
env:
RAILS_VERSION: '~> 5.1.0'
- ruby: 2.4.10
env:
RAILS_VERSION: '~> 5.1.0'
- ruby: 2.3.8
env:
RAILS_VERSION: '~> 5.1.0'
- ruby: 2.2.10
env:
RAILS_VERSION: '~> 5.1.0'
# Rails 5.0 Builds >= 2.2.2
- ruby: 2.6.6
env:
RAILS_VERSION: '~> 5.0.0'
- ruby: 2.5.8
env:
RAILS_VERSION: '~> 5.0.0'
- ruby: 2.4.10
env:
RAILS_VERSION: '~> 5.0.0'
- ruby: 2.3.8
env:
RAILS_VERSION: '~> 5.0.0'
- ruby: 2.2.10
env:
RAILS_VERSION: '~> 5.0.0'
env: ${{ matrix.env }}
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- run: script/clone_all_rspec_repos
- run: bundle install --binstubs
- run: script/run_build
continue-on-error: ${{ matrix.allow_failure || false }}
67 changes: 8 additions & 59 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,82 +38,31 @@ script: "script/run_build 2>&1"

matrix:
include:
# Rails 6.1 builds >= 2.5
- rvm: ruby-3.0.0-preview1
env: RAILS_VERSION='master'
allow_failure: true
- rvm: 2.7.1
env: RAILS_VERSION='master'
- rvm: 2.6.6
env: RAILS_VERSION='master'
- rvm: 2.5.8
env: RAILS_VERSION='master'
- rvm: jruby-head
jdk: oraclejdk11
env:
- RAILS_VERSION='master'
- RAILS_VERSION='6.1.0.rc1'
- JRUBY_OPT=--dev
- JAVA_OPTS="--add-opens java.base/sun.nio.ch=org.jruby.dist --add-opens java.base/java.io=org.jruby.dist --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/java.util.zip=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util.regex=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/javax.crypto=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED"

# Rails 6.0 builds >= 2.5.0
- rvm: jruby-head
jdk: oraclejdk11
env:
- RAILS_VERSION='~> 6.0.0'
- JRUBY_OPT=--dev
- JAVA_OPTS="--add-opens java.base/sun.nio.ch=org.jruby.dist --add-opens java.base/java.io=org.jruby.dist --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/java.util.zip=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util.regex=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/javax.crypto=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED"
- rvm: ruby-3.0.0-preview1
env: RAILS_VERSION='~> 6.0.0'
allow_failure: true
- rvm: 2.7.1
env: RAILS_VERSION='~> 6.0.0'
- rvm: 2.6.6
env: RAILS_VERSION='~> 6.0.0'
- rvm: 2.5.8
env: RAILS_VERSION='~> 6.0.0'

# Rails 5.2 builds >= 2.2.2
- rvm: jruby-head
jdk: oraclejdk11
env:
- RAILS_VERSION='~> 5.2.0'
- JRUBY_OPT=--dev
- JAVA_OPTS="--add-opens java.base/sun.nio.ch=org.jruby.dist --add-opens java.base/java.io=org.jruby.dist --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/java.util.zip=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util.regex=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/javax.crypto=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED"
- rvm: 2.6.6
env: RAILS_VERSION='~> 5.2.0'
- rvm: 2.5.8
env: RAILS_VERSION='~> 5.2.0'
- rvm: 2.4.10
env: RAILS_VERSION='~> 5.2.0'
- rvm: 2.3.8
env: RAILS_VERSION='~> 5.2.0'
- rvm: 2.2.10
env: RAILS_VERSION='~> 5.2.0'
allow_failure: true
- rvm: 2.2.10
env: RAILS_VERSION='5-2-stable'

# Rails 5.1 Builds >= 2.2.2
- rvm: 2.6.6
env: RAILS_VERSION='~> 5.1.0'
- rvm: 2.5.8
env: RAILS_VERSION='~> 5.1.0'
- rvm: 2.4.10
env: RAILS_VERSION='~> 5.1.0'
- rvm: 2.3.8
env: RAILS_VERSION='~> 5.1.0'
- rvm: 2.2.10
env: RAILS_VERSION='~> 5.1.0'

# Rails 5.0 Builds >= 2.2.2
- rvm: 2.6.6
env: RAILS_VERSION='~> 5.0.0'
- rvm: 2.5.8
env: RAILS_VERSION='~> 5.0.0'
- rvm: 2.4.10
env: RAILS_VERSION='~> 5.0.0'
- rvm: 2.3.8
env: RAILS_VERSION='~> 5.0.0'
- rvm: 2.2.10
env: RAILS_VERSION='~> 5.0.0'

fast_finish: true

branches:
only:
- master
- /^\d+-\d+-maintenance$/
- /^\d+-\d+-dev$/
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Enhancements:
(Eloy Espinaco, Luka Lüdicke, #2355, #2356, #2378)
* Generated scaffold now includes engine route helpers when inside a mountable engine.
(Andrew W. Lee, #2372)
* Improve request spec "controller" scafold when no action is specified.
(Thomas Hareau, #2399)

Bug Fixes:

Expand Down
6 changes: 0 additions & 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,9 @@
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 Author

Choose a reason for hiding this comment

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

Why are we doing this? It should be replaced not removed no?

Copy link
Member

Choose a reason for hiding this comment

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

We had errors like undefined method 'parent' for ExampleApp::Application:Class . I noticed that this gsub is not needed anymore.

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
10 changes: 5 additions & 5 deletions features/matchers/have_broadcasted_matcher.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Feature: have_broadcasted matcher
it "matches with stream name" do
expect {
ActionCable.server.broadcast(
"notifications", text: 'Hello!'
"notifications", { text: "Hello!" }
)
}.to have_broadcasted_to("notifications")
end
Expand All @@ -34,7 +34,7 @@ Feature: have_broadcasted matcher
it "matches with message" do
expect {
ActionCable.server.broadcast(
"notifications", text: 'Hello!'
"notifications", { text: "Hello!" }
)
}.to have_broadcasted_to("notifications").with(text: 'Hello!')
end
Expand All @@ -52,7 +52,7 @@ Feature: have_broadcasted matcher
it "matches with message" do
expect {
ActionCable.server.broadcast(
"notifications", text: 'Hello!', user_id: 12
"notifications", { text: 'Hello!', user_id: 12 }
)
}.to have_broadcasted_to("notifications").with(a_hash_including(text: 'Hello!'))
end
Expand All @@ -70,7 +70,7 @@ Feature: have_broadcasted matcher
it "matches with message" do
expect {
ActionCable.server.broadcast(
"notifications", text: 'Hello!', user_id: 12
"notifications", { text: 'Hello!', user_id: 12 }
)
}.to have_broadcasted_to("notifications").with { |data|
expect(data['user_id']).to eq 12
Expand All @@ -90,7 +90,7 @@ Feature: have_broadcasted matcher
it "matches with stream name" do
expect {
ActionCable.server.broadcast(
"notifications", text: 'Hello!'
"notifications", { text: 'Hello!' }
)
}.to broadcast_to("notifications")
end
Expand Down
7 changes: 6 additions & 1 deletion lib/generators/rspec/controller/templates/request_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
require 'rails_helper'

RSpec.describe "<%= class_name.pluralize %>", <%= type_metatag(:request) %> do
<% namespaced_path = regular_class_path.join('/') %>
<% namespaced_path = regular_class_path.join('/') -%>
<% if actions.empty? -%>
describe "GET /index" do
pending "add some examples (or delete) #{__FILE__}"
end
<% end -%>
<% for action in actions -%>
describe "GET /<%= action %>" do
it "returns http success" do
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/rails/example/mailbox_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module MailboxExampleGroup
def self.create_inbound_email(arg)
case arg
when Hash
create_inbound_email_from_mail(arg)
create_inbound_email_from_mail(**arg)
else
create_inbound_email_from_source(arg.to_s)
end
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
4 changes: 3 additions & 1 deletion rspec-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ Gem::Specification.new do |s|
# that we want. These will need to change from time to time as new RSpecs
# get released.
%w[core expectations mocks support].each do |name|
if RSpec::Rails::Version::STRING =~ /pre/ # prerelease builds
if ENV['RSPEC_CI']
s.add_runtime_dependency "rspec-#{name}", "= 4.0.0.pre"
elsif RSpec::Rails::Version::STRING =~ /pre/ # prerelease builds
expected_rspec_version = "3.11.0.pre"
s.add_runtime_dependency "rspec-#{name}", "= #{expected_rspec_version}"
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
it { is_expected.to exist }
it { is_expected.to contain(/require 'rails_helper'/) }
it { is_expected.to contain(/^RSpec.describe "Posts", #{type_metatag(:request)}/) }
it { is_expected.to contain('pending') }
end
end

Expand Down
13 changes: 8 additions & 5 deletions spec/generators/rspec/scaffold/scaffold_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Generators are not automatically loaded by Rails
require 'generators/rspec/scaffold/scaffold_generator'
require 'support/generators'
require 'rspec/support/spec/in_sub_process'

RSpec.describe Rspec::Generators::ScaffoldGenerator, type: :generator do
include RSpec::Support::InSubProcess
setup_default_destination

describe 'standard request specs' do
Expand Down Expand Up @@ -41,12 +43,13 @@
end

describe 'in an engine' do
before do
allow_any_instance_of(::Rails::Generators::NamedBase).to receive(:mountable_engine?).and_return(true)
run_generator %w[posts --request_specs]
it 'generates files with Engine url_helpers' do
in_sub_process do
allow_any_instance_of(::Rails::Generators::NamedBase).to receive(:mountable_engine?).and_return(true)
run_generator %w[posts --request_specs]
is_expected.to contain('Engine.routes.url_helpers')
end
end

it { is_expected.to contain('Engine.routes.url_helpers') }
end
end

Expand Down