Skip to content

Commit fee0cfe

Browse files
p-mongop
andauthored
Update spec/shared to current master (#4907)
* Update spec/shared to current master * RUBY-2428 use shared spec organizer & child process helper Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent 55e8aa5 commit fee0cfe

File tree

5 files changed

+41
-226
lines changed

5 files changed

+41
-226
lines changed

Rakefile

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ require "bundler"
44
require "bundler/gem_tasks"
55
Bundler.setup
66

7+
ROOT = File.expand_path(File.join(File.dirname(__FILE__)))
8+
9+
$: << File.join(ROOT, 'spec/shared/lib')
10+
711
require "rake"
812
require "rspec/core/rake_task"
13+
require 'mrss/spec_organizer'
914

1015
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
1116
require "mongoid/version"
@@ -38,11 +43,30 @@ RSpec::Core::RakeTask.new('spec:progress') do |spec|
3843
spec.pattern = "spec/**/*_spec.rb"
3944
end
4045

41-
task :ci do
42-
$LOAD_PATH.push File.expand_path("../spec", __FILE__)
43-
require 'support/spec_organizer'
46+
CLASSIFIERS = [
47+
[%r,^mongoid/attribute,, :attributes],
48+
[%r,^mongoid/association/[or],, :associations_referenced],
49+
[%r,^mongoid/association,, :associations],
50+
[%r,^mongoid,, :unit],
51+
[%r,^integration,, :integration],
52+
[%r,^rails,, :rails],
53+
]
54+
55+
RUN_PRIORITY = %i(
56+
unit attributes associations_referenced associations
57+
integration rails
58+
)
59+
60+
def spec_organizer
61+
Mrss::SpecOrganizer.new(
62+
root: ROOT,
63+
classifiers: CLASSIFIERS,
64+
priority_order: RUN_PRIORITY,
65+
)
66+
end
4467

45-
SpecOrganizer.new.run
68+
task :ci do
69+
spec_organizer.run
4670
end
4771

4872
task :default => :spec

spec/integration/app_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
end
1414

1515
require 'fileutils'
16-
require 'support/child_process_helper'
16+
require 'mrss/child_process_helper'
1717
require 'open-uri'
1818

1919
FileUtils.mkdir_p(TMP_BASE)
@@ -91,19 +91,19 @@
9191
['~> 5.1.0', '~> 5.2.0', '~> 6.0.0'].each do |rails_version|
9292
context "with rails #{rails_version}" do
9393
it 'creates' do
94-
ChildProcessHelper.check_call(%w(gem uni rails -a))
95-
ChildProcessHelper.check_call(%w(gem install rails --no-document -v) + [rails_version])
94+
Mrss::ChildProcessHelper.check_call(%w(gem uni rails -a))
95+
Mrss::ChildProcessHelper.check_call(%w(gem install rails --no-document -v) + [rails_version])
9696

9797
Dir.chdir(TMP_BASE) do
9898
FileUtils.rm_rf('mongoid-test')
99-
ChildProcessHelper.check_call(%w(rails new mongoid-test --skip-spring --skip-active-record), env: clean_env)
99+
Mrss::ChildProcessHelper.check_call(%w(rails new mongoid-test --skip-spring --skip-active-record), env: clean_env)
100100

101101
Dir.chdir('mongoid-test') do
102102
adjust_app_gemfile
103-
ChildProcessHelper.check_call(%w(bundle install), env: clean_env)
103+
Mrss::ChildProcessHelper.check_call(%w(bundle install), env: clean_env)
104104

105-
ChildProcessHelper.check_call(%w(rails g model post), env: clean_env)
106-
ChildProcessHelper.check_call(%w(rails g model comment post:belongs_to), env: clean_env)
105+
Mrss::ChildProcessHelper.check_call(%w(rails g model post), env: clean_env)
106+
Mrss::ChildProcessHelper.check_call(%w(rails g model comment post:belongs_to), env: clean_env)
107107

108108
# https://jira.mongodb.org/browse/MONGOID-4885
109109
comment_text = File.read('app/models/comment.rb')
@@ -136,7 +136,7 @@
136136
before do
137137
Dir.chdir(APP_PATH) do
138138
remove_bundler_req
139-
ChildProcessHelper.check_call(%w(bundle install), env: env)
139+
Mrss::ChildProcessHelper.check_call(%w(bundle install), env: env)
140140
write_mongoid_yml
141141
end
142142

@@ -150,7 +150,7 @@
150150
end
151151
index.should be nil
152152

153-
ChildProcessHelper.check_call(%w(rake db:mongoid:create_indexes),
153+
Mrss::ChildProcessHelper.check_call(%w(rake db:mongoid:create_indexes),
154154
cwd: APP_PATH, env: env)
155155

156156
index = client['posts'].indexes.detect do |index|
@@ -168,10 +168,10 @@
168168
def clone_application(repo_url, subdir: nil, rails_version: nil)
169169
Dir.chdir(TMP_BASE) do
170170
FileUtils.rm_rf(File.basename(repo_url))
171-
ChildProcessHelper.check_call(%w(git clone) + [repo_url])
171+
Mrss::ChildProcessHelper.check_call(%w(git clone) + [repo_url])
172172
Dir.chdir(File.join(*[File.basename(repo_url), subdir].compact)) do
173173
adjust_app_gemfile(rails_version: rails_version)
174-
ChildProcessHelper.check_call(%w(bundle install), env: clean_env)
174+
Mrss::ChildProcessHelper.check_call(%w(bundle install), env: clean_env)
175175
puts `git diff`
176176

177177
write_mongoid_yml
@@ -230,7 +230,7 @@ def remove_spring
230230
# in `initialize': too long unix socket path (126bytes given but 108bytes max) (ArgumentError)
231231
# Is it trying to create unix sockets in current directory?
232232
# https://stackoverflow.com/questions/30302021/rails-runner-without-spring
233-
ChildProcessHelper.check_call(%w(bin/spring binstub --remove --all), env: clean_env)
233+
Mrss::ChildProcessHelper.check_call(%w(bin/spring binstub --remove --all), env: clean_env)
234234
end
235235

236236
def clean_env

spec/shared

spec/support/child_process_helper.rb

Lines changed: 0 additions & 79 deletions
This file was deleted.

spec/support/spec_organizer.rb

Lines changed: 0 additions & 130 deletions
This file was deleted.

0 commit comments

Comments
 (0)