Skip to content

Commit d919e0d

Browse files
committed
[test] puts CURRENT_LIB and note on how filtering works
1 parent 2382b95 commit d919e0d

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/spec/ruby/spec_helper.rb

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
2-
require 'java'
3-
41
target = File.expand_path('target', "#{File.dirname(__FILE__)}/../../..")
52
jars = File.exist?(lib = "#{target}/lib") && ( Dir.entries(lib) - [ '.', '..' ] )
63
raise "missing .jar dependencies please run `rake test_prepare'" if ! jars || jars.empty?
74
$CLASSPATH << File.expand_path('classes', target)
85
$CLASSPATH << File.expand_path('test-classes', target)
96
jars.each { |jar| $CLASSPATH << File.expand_path(jar, lib) }
107

11-
puts "using JRuby #{JRUBY_VERSION} (#{RUBY_VERSION})"
12-
138
java_import 'javax.servlet.http.HttpServletRequest'
149
java_import 'javax.servlet.http.HttpServletResponse'
1510

@@ -171,30 +166,28 @@ def should_not_eval_as_nil(code, runtime = @runtime) # alias
171166
end
172167

173168
# current 'library' environment (based on appraisals) e.g. :rails72
174-
CURRENT_LIB = defined?(Rails::VERSION) ?
175-
:"rails#{Rails::VERSION::MAJOR}#{Rails::VERSION::MINOR}" : :stub
169+
CURRENT_LIB = defined?(Rails::VERSION) ? :"rails#{Rails::VERSION::MAJOR}#{Rails::VERSION::MINOR}" : :stub
170+
171+
puts "using JRuby #{JRUBY_VERSION} (#{RUBY_VERSION}) CURRENT_LIB: #{CURRENT_LIB.inspect}"
176172

177173
RSpec.configure do |config|
178174

179175
config.include SharedHelpers
180176

181-
config.before :each do
177+
config.before(:each) do
182178
@env_save = ENV.to_hash
183179
mock_servlet_context
184180
end
185181

186-
config.after :each do
182+
config.after(:each) do
187183
(ENV.keys - @env_save.keys).each {|k| ENV.delete k}
188184
@env_save.each {|k,v| ENV[k] = v}
189185
Dir.chdir(WD_START) unless Dir.getwd == WD_START
190186
$servlet_context = nil if defined? $servlet_context
191187
end
192188

193-
config.filter_run_excluding :lib => lambda { |lib|
194-
return false if lib.nil? # no :lib => specified run with all
195-
lib = lib.is_a?(Array) ? lib : [ lib ]
196-
return ! lib.include?(CURRENT_LIB)
197-
}
189+
# NOTE: only works when no other example filtering is in place: e.g. `rspec ... --example=logger` won't filter here
190+
config.filter_run_excluding lib: lambda { |lib| lib.nil? ? false : !Array(lib).include?(CURRENT_LIB) }
198191

199192
config.backtrace_exclusion_patterns = [
200193
/bin\//,

0 commit comments

Comments
 (0)