-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Prevent collisions on let(:name) and let(:method_name) #2467
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version_file = File.expand_path('.rails-version', __dir__) | ||
RAILS_VERSION = ENV['RAILS_VERSION'] || (File.exist?(version_file) && File.read(version_file).chomp) || "" | ||
|
||
MAJOR = | ||
case RAILS_VERSION | ||
when /5-2-stable/ | ||
5 | ||
when /master/, /stable/, nil, false, '' | ||
6 | ||
else | ||
/(\d+)[\.|-]\d+/.match(RAILS_VERSION).captures.first.to_i | ||
end | ||
|
||
if MAJOR >= 6 | ||
# sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4` | ||
gem 'sqlite3', '~> 1.4', platforms: [:ruby] | ||
else | ||
# Similarly, Rails 5.0 only supports '~> 1.3.6'. Rails 5.1-5.2 support '~> 1.3', '>= 1.3.6' | ||
gem 'sqlite3', '~> 1.3.6', platforms: [:ruby] | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
( | ||
cd snippets | ||
# This is required to load `bundle/inline` | ||
unset RUBYOPT | ||
for snippet in *.rb; | ||
do | ||
echo Running $snippet | ||
ruby $snippet | ||
done | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
if __FILE__ =~ /^snippets/ | ||
fail "Snippets are supposed to be run from their own directory to avoid side " \ | ||
"effects as e.g. the root `Gemfile`, or `spec/spec_helpers.rb` to be " \ | ||
"loaded by the root `.rspec`." | ||
end | ||
|
||
# We opt-out from using RubyGems, but `bundler/inline` requires it | ||
require 'rubygems' | ||
|
||
require "bundler/inline" | ||
|
||
# We pass `false` to `gemfile` to skip the installation of gems, | ||
# because it may install versions that would conflict with versions | ||
# from the main `Gemfile.lock`. | ||
gemfile(false) do | ||
source "https://rubygems.org" | ||
|
||
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | ||
|
||
# Those Gemfiles carefully pick the right versions depending on | ||
# settings in the ENV, `.rails-version` and `maintenance-branch`. | ||
Dir.chdir('..') do | ||
eval_gemfile 'Gemfile-sqlite-dependencies' | ||
# This Gemfile expects `maintenance-branch` file to be present | ||
# in the current directory. | ||
eval_gemfile 'Gemfile-rspec-dependencies' | ||
# This Gemfile expects `.rails-version` file | ||
eval_gemfile 'Gemfile-rails-dependencies' | ||
end | ||
|
||
gem "rspec-rails", path: "../" | ||
end | ||
|
||
# Run specs at exit | ||
require "rspec/autorun" | ||
|
||
require "rails" | ||
require "active_record/railtie" | ||
require "rspec/rails" | ||
|
||
# This connection will do for database-independent bug reports | ||
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | ||
|
||
RSpec.configure do |config| | ||
config.use_transactional_fixtures = true | ||
end | ||
|
||
RSpec.describe 'Foo' do | ||
subject { true } | ||
|
||
# Rails 6.1 and after | ||
let(:name) { raise "Should never raise" } | ||
# Before Rails 6.1 | ||
let(:method_name) { raise "Should never raise" } | ||
|
||
it { is_expected.to be_truthy } | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
if __FILE__ =~ /^snippets/ | ||
fail "Snippets are supposed to be run from their own directory to avoid side " \ | ||
"effects as e.g. the root `Gemfile`, or `spec/spec_helpers.rb` to be " \ | ||
"loaded by the root `.rspec`." | ||
end | ||
|
||
# We opt-out from using RubyGems, but `bundler/inline` requires it | ||
require 'rubygems' | ||
|
||
require "bundler/inline" | ||
|
||
# We pass `false` to `gemfile` to skip the installation of gems, | ||
# because it may install versions that would conflict with versions | ||
# from the main `Gemfile.lock`. | ||
gemfile(false) do | ||
source "https://rubygems.org" | ||
|
||
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | ||
|
||
# Those Gemfiles carefully pick the right versions depending on | ||
# settings in the ENV, `.rails-version` and `maintenance-branch`. | ||
Dir.chdir('..') do | ||
eval_gemfile 'Gemfile-sqlite-dependencies' | ||
# This Gemfile expects `maintenance-branch` file to be present | ||
# in the current directory. | ||
eval_gemfile 'Gemfile-rspec-dependencies' | ||
# This Gemfile expects `.rails-version` file | ||
eval_gemfile 'Gemfile-rails-dependencies' | ||
end | ||
|
||
gem "rspec-rails", path: "../" | ||
end | ||
|
||
# Run specs at exit | ||
require "rspec/autorun" | ||
|
||
# This snippet describes the case when ActiveRecord is loaded, but | ||
# `use_active_record` is set to `false` in RSpec configuration. | ||
|
||
# Initialization | ||
require "active_record/railtie" | ||
require "rspec/rails" | ||
|
||
# This connection will do for database-independent bug reports | ||
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | ||
|
||
# RSpec configuration | ||
RSpec.configure do |config| | ||
config.use_active_record = false | ||
end | ||
|
||
# Rails project code | ||
class Foo | ||
end | ||
|
||
# Rails project specs | ||
RSpec.describe Foo do | ||
it 'does not not break' do | ||
Foo | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note that we have no support for snippets in
main
, the code to run them is inrails-6-1-dev
only.But if CI passes on
rails-6-1-dev
, the patch should most possibly work formain
, too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it easy-ish to backport that support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be easy. Looks like cherry-picking 040fecc and accepting the removed lines from
Gemfile
should do it.