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
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/decko/commands/rspec_command/parser.rb', line 8
def initialize opts
super() do |parser|
parser.banner = "Usage: decko rspec [DECKO ARGS] -- [RSPEC ARGS]\n\n" \
"RSPEC ARGS"
parser.separator <<-EOT
DECKO ARGS
You don't have to give a full path for FILENAME, the basename is enough
If FILENAME does not include '_spec' rspec searches for the
corresponding spec file.
The line number always referes to example in the (corresponding) spec
file.
EOT
parser.on("-d", "--spec FILENAME(:LINE)",
"Run spec for a Decko deck file") do |file|
opts[:files] = find_spec_file(file, "#{Decko.root}/mod")
end
parser.on("-c", "--core-spec FILENAME(:LINE)",
"Run spec for a Decko core file") do |file|
opts[:files] = find_spec_file(file, Cardio.gem_root)
end
parser.on("-m", "--mod MODNAME",
"Run all specs for a mod or matching a mod") do |file|
opts[:files] =
if File.exist?("mod/#{file}")
"#{Cardio.gem_root}/mod/#{file}"
elsif File.exist?("#{Cardio.gem_root}/mod/#{file}")
"#{Cardio.gem_root}/mod/#{file}"
elsif (files = find_spec_file(file, "mod")) && files.present?
files
else
find_spec_file(file, "#{Cardio.gem_root}/mod")
end
end
parser.on("-s", "--[no-]simplecov", "Run with simplecov") do |s|
opts[:simplecov] = s ? "" : "COVERAGE=false"
end
parser.on("--rescue", "Run with pry-rescue") do
if opts[:executer] == "spring"
puts "Disabled pry-rescue. Not compatible with spring."
else
opts[:rescue] = "rescue "
end
end
parser.on("--[no-]spring", "Run with spring") do |spring|
if spring
opts[:executer] = "spring"
if opts[:rescue]
opts[:rescue] = ""
puts "Disabled pry-rescue. Not compatible with spring."
end
else
opts[:executer] = "bundle exec"
end
end
parser.separator "\n"
end
end
|