Class: Devformance::TestFramework::RSpec
- Inherits:
-
Base
- Object
- Base
- Devformance::TestFramework::RSpec
show all
- Defined in:
- lib/devformance/test_framework/rspec.rb
Instance Attribute Summary
Attributes inherited from Base
#root_path
Instance Method Summary
collapse
Methods inherited from Base
#available?, #initialize
Instance Method Details
#classify_line(line) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/devformance/test_framework/rspec.rb', line 33
def classify_line(line)
if line.match?(/(\d+)\s+examples?,\s+(\d+)\s+failures?/)
"summary"
elsif line.match?(/^\s*[·.]\s/) || line.strip.start_with?(".")
"pass"
elsif line.match?(/^\s*[F!]\s/) || line.strip.start_with?("F")
"fail"
elsif line.match?(/^\s*\*\s/) || line.strip.start_with?("*")
"pending"
elsif line.include?("ERROR") || line.include?("Error:")
"error"
elsif line.match?(/^\s{3,}/)
"pass"
else
"info"
end
end
|
#discover_files ⇒ Object
10
11
12
|
# File 'lib/devformance/test_framework/rspec.rb', line 10
def discover_files
@discover_files ||= Dir.glob(root_path.join(file_pattern)).sort
end
|
#file_pattern ⇒ Object
6
7
8
|
# File 'lib/devformance/test_framework/rspec.rb', line 6
def file_pattern
"spec/**/*_spec.rb"
end
|
#name ⇒ Object
51
52
53
|
# File 'lib/devformance/test_framework/rspec.rb', line 51
def name
"RSpec"
end
|
#parse_summary(output) ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/devformance/test_framework/rspec.rb', line 22
def parse_summary(output)
if output =~ /(\d+)\s+examples?,\s+(\d+)\s+failures?(?:,\s+(\d+)\s+pending)?/m
examples = $1.to_i
failures = $2.to_i
pending = $3.to_i rescue 0
{ examples: examples, failures: failures, pending: pending, passes: examples - failures - pending }
else
{ examples: 0, failures: 0, pending: 0, passes: 0 }
end
end
|
#run_command(file_path, coverage: false) ⇒ Object
14
15
16
|
# File 'lib/devformance/test_framework/rspec.rb', line 14
def run_command(file_path, coverage: false)
[ "bundle", "exec", "rspec", file_path, "--format", "documentation" ]
end
|
#runner_command ⇒ Object
18
19
20
|
# File 'lib/devformance/test_framework/rspec.rb', line 18
def runner_command
"bundle exec rspec"
end
|
#test_terminal_command(file_path) ⇒ Object
55
56
57
|
# File 'lib/devformance/test_framework/rspec.rb', line 55
def test_terminal_command(file_path)
"bundle exec rspec #{file_path} --format documentation"
end
|