This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
runner.rb
executable file
·57 lines (51 loc) · 1.6 KB
/
runner.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
#
# Author:: HIGUCHI Daisuke (<d-higuchi@creationline.com>)
#
# Copyright (C) 2013-2014, HIGUCHI Daisuke
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'rake'
require 'rspec/core/rake_task'
require 'rbconfig'
base_path = File.expand_path(ARGV.shift)
RSpec::Core::RakeTask.new(:spec) do |t|
candidate_bindirs = []
# Current Ruby's default bindir
candidate_bindirs << RbConfig::CONFIG['bindir']
# Search all Gem paths bindirs
candidate_bindirs << Gem.paths.path.map do |gem_path|
File.join(gem_path, 'bin')
end
candidate_rspec_bins = candidate_bindirs.flatten.map do |bin_dir|
File.join(bin_dir, 'rspec')
end
rspec_bin = candidate_rspec_bins.find do |candidate_rspec_bin|
FileTest.exist?(candidate_rspec_bin) &&
FileTest.executable?(candidate_rspec_bin)
end
t.rspec_path = rspec_bin if rspec_bin
t.rspec_opts = [
'--color',
'--format documentation',
"--default-path #{base_path}",
]
t.ruby_opts = "-I#{base_path}"
t.pattern = "#{base_path}/**/*_spec.rb"
end
begin
Rake::Task['spec'].invoke
rescue RuntimeError
exit 1
end