5
5
BASE = File . join ( File . dirname ( __FILE__ ) , '../..' )
6
6
TMP_BASE = File . join ( BASE , 'tmp' )
7
7
8
+ def check_call ( cmd , **opts )
9
+ puts "Executing #{ cmd . join ( ' ' ) } "
10
+ Mrss ::ChildProcessHelper . check_call ( cmd , **opts )
11
+ end
12
+
8
13
describe 'Mongoid application tests' do
9
14
before ( :all ) do
10
15
unless SpecConfig . instance . app_tests?
@@ -87,14 +92,14 @@ def start_app(cmd, port, timeout)
87
92
88
93
Dir . chdir ( TMP_BASE ) do
89
94
FileUtils . rm_rf ( 'mongoid-test' )
90
- Mrss :: ChildProcessHelper . check_call ( %w( rails new mongoid-test --skip-spring --skip-active-record ) , env : clean_env )
95
+ check_call ( %w( rails new mongoid-test --skip-spring --skip-active-record ) , env : clean_env )
91
96
92
97
Dir . chdir ( 'mongoid-test' ) do
93
98
adjust_app_gemfile
94
- Mrss :: ChildProcessHelper . check_call ( %w( bundle install ) , env : clean_env )
99
+ check_call ( %w( bundle install ) , env : clean_env )
95
100
96
- Mrss :: ChildProcessHelper . check_call ( %w( rails g model post ) , env : clean_env )
97
- Mrss :: ChildProcessHelper . check_call ( %w( rails g model comment post:belongs_to ) , env : clean_env )
101
+ check_call ( %w( rails g model post ) , env : clean_env )
102
+ check_call ( %w( rails g model comment post:belongs_to ) , env : clean_env )
98
103
99
104
# https://jira.mongodb.org/browse/MONGOID-4885
100
105
comment_text = File . read ( 'app/models/comment.rb' )
@@ -109,16 +114,16 @@ def start_app(cmd, port, timeout)
109
114
110
115
Dir . chdir ( TMP_BASE ) do
111
116
FileUtils . rm_rf ( 'mongoid-test-config' )
112
- Mrss :: ChildProcessHelper . check_call ( %w( rails new mongoid-test-config --skip-spring --skip-active-record ) , env : clean_env )
117
+ check_call ( %w( rails new mongoid-test-config --skip-spring --skip-active-record ) , env : clean_env )
113
118
114
119
Dir . chdir ( 'mongoid-test-config' ) do
115
120
adjust_app_gemfile
116
- Mrss :: ChildProcessHelper . check_call ( %w( bundle install ) , env : clean_env )
121
+ check_call ( %w( bundle install ) , env : clean_env )
117
122
118
123
mongoid_config_file = File . join ( TMP_BASE , 'mongoid-test-config/config/mongoid.yml' )
119
124
120
125
File . exist? ( mongoid_config_file ) . should be false
121
- Mrss :: ChildProcessHelper . check_call ( %w( rails g mongoid:config ) , env : clean_env )
126
+ check_call ( %w( rails g mongoid:config ) , env : clean_env )
122
127
File . exist? ( mongoid_config_file ) . should be true
123
128
124
129
config_text = File . read ( mongoid_config_file )
@@ -130,10 +135,11 @@ def start_app(cmd, port, timeout)
130
135
end
131
136
132
137
def install_rails
133
- Mrss :: ChildProcessHelper . check_call ( %w( gem uni rails -a ) )
138
+ check_call ( %w( gem uni rails -a ) )
134
139
if ( rails_version = SpecConfig . instance . rails_version ) == 'master'
135
140
else
136
- Mrss ::ChildProcessHelper . check_call ( %w( gem install rails --no-document -v ) + [ rails_version ] )
141
+ check_call ( %w( gem list ) )
142
+ check_call ( %w( gem install rails --no-document -v ) + [ "~> #{ rails_version } .0" ] )
137
143
end
138
144
end
139
145
@@ -157,7 +163,7 @@ def install_rails
157
163
before do
158
164
Dir . chdir ( APP_PATH ) do
159
165
remove_bundler_req
160
- Mrss :: ChildProcessHelper . check_call ( %w( bundle install ) , env : env )
166
+ check_call ( %w( bundle install ) , env : env )
161
167
write_mongoid_yml
162
168
end
163
169
@@ -171,7 +177,7 @@ def install_rails
171
177
end
172
178
index . should be nil
173
179
174
- Mrss :: ChildProcessHelper . check_call ( %w( bundle exec rake db:mongoid:create_indexes ) ,
180
+ check_call ( %w( bundle exec rake db:mongoid:create_indexes -t ) ,
175
181
cwd : APP_PATH , env : env )
176
182
177
183
index = client [ 'posts' ] . indexes . detect do |index |
@@ -189,11 +195,11 @@ def install_rails
189
195
def clone_application ( repo_url , subdir : nil )
190
196
Dir . chdir ( TMP_BASE ) do
191
197
FileUtils . rm_rf ( File . basename ( repo_url ) )
192
- Mrss :: ChildProcessHelper . check_call ( %w( git clone ) + [ repo_url ] )
198
+ check_call ( %w( git clone ) + [ repo_url ] )
193
199
Dir . chdir ( File . join ( *[ File . basename ( repo_url ) , subdir ] . compact ) ) do
194
200
adjust_app_gemfile
195
201
adjust_rails_defaults
196
- Mrss :: ChildProcessHelper . check_call ( %w( bundle install ) , env : clean_env )
202
+ check_call ( %w( bundle install ) , env : clean_env )
197
203
puts `git diff`
198
204
199
205
write_mongoid_yml
@@ -316,7 +322,7 @@ def remove_spring
316
322
# in `initialize': too long unix socket path (126bytes given but 108bytes max) (ArgumentError)
317
323
# Is it trying to create unix sockets in current directory?
318
324
# https://stackoverflow.com/questions/30302021/rails-runner-without-spring
319
- Mrss :: ChildProcessHelper . check_call ( %w( bin/spring binstub --remove --all ) , env : clean_env )
325
+ check_call ( %w( bin/spring binstub --remove --all ) , env : clean_env )
320
326
end
321
327
322
328
def clean_env
0 commit comments