-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a file repro app to test the fix on fixture_support name
- Loading branch information
Showing
3 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
31 changes: 31 additions & 0 deletions
31
spec/rspec/rails/features/rails_app/partial_active_record_false.rb
This file contains 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,31 @@ | ||
require "bundler/inline" | ||
|
||
gemfile(true) do | ||
source "https://rubygems.org" | ||
|
||
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | ||
|
||
gem "rails", (ENV["RAILS_VERSION"] || "~> 6.0.0") | ||
gem "rspec-rails", path: "./" | ||
gem "sqlite3" | ||
gem "ammeter" | ||
end | ||
|
||
require "active_record/railtie" | ||
|
||
require "ammeter" | ||
require "rspec/autorun" | ||
require "rspec/rails" | ||
|
||
class Command | ||
end | ||
|
||
RSpec.configure do |config| | ||
config.use_active_record = false | ||
end | ||
|
||
RSpec.describe Command do | ||
it 'should not break' do | ||
Command.new | ||
end | ||
end |
30 changes: 30 additions & 0 deletions
30
spec/rspec/rails/features/rails_app/partial_active_record_false_spec.rb
This file contains 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,30 @@ | ||
RSpec.describe 'Rails app with use_active_record = false but active record railties loaded' do | ||
it 'properly handles name scope in fixture_support' do | ||
cmd = 'ruby spec/rspec/rails/features/rails_app/partial_active_record_false.rb' | ||
cmd_status = ruby_script_runner(cmd) | ||
expect(cmd_status[:stdout].last&.chomp).to eq("1 example, 0 failures") | ||
expect(cmd_status[:exitstatus]).to eq(0) | ||
end | ||
|
||
def ruby_script_runner(cmd) | ||
require 'open3' | ||
cmd_status = { stdout: [], exitstatus: nil } | ||
Open3.popen2(cmd) do |_stdin, stdout, wait_thr| | ||
frame_stdout do | ||
while line = stdout.gets | ||
puts "| #{line}" | ||
cmd_status[:stdout] << line if line =~ /\d+ (example|examples), \d+ failure/ | ||
end | ||
end | ||
cmd_status[:exitstatus] = wait_thr.value.exitstatus | ||
end | ||
cmd_status | ||
end | ||
|
||
def frame_stdout | ||
puts | ||
puts '-' * 50 | ||
yield | ||
puts '-' * 50 | ||
end | ||
end |