-
Notifications
You must be signed in to change notification settings - Fork 553
/
simplecov_steps.rb
111 lines (97 loc) · 3.12 KB
/
simplecov_steps.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# frozen_string_literal: true
# Just a shortcut to make framework setup more readable
# The test project is using separate config files to avoid specifying all of
# test/spec_helper in the features every time.
Given /^SimpleCov for (.*) is configured with:$/ do |framework, config_body|
framework_dir =
case framework
when /RSpec/i
"spec"
when /Test\/Unit/i
"test"
when /Cucumber/i
"features/support"
when /Minitest/i
"minitest"
else
raise ArgumentError, "Could not identify test framework #{framework}!"
end
steps %(
Given a file named "#{framework_dir}/simplecov_config.rb" with:
"""
#{config_body}
"""
)
end
When /^I open the coverage report generated with `([^`]+)`$/ do |command|
steps %(
When I successfully run `#{command}`
Then a coverage report should have been generated
When I open the coverage report
)
end
Then /^a coverage report should have been generated(?: in "([^"]*)")?$/ do |coverage_dir|
coverage_dir ||= "coverage"
steps %(
Then the output should contain "Coverage report generated"
And a directory named "#{coverage_dir}" should exist
And the following files should exist:
| #{coverage_dir}/index.html |
| #{coverage_dir}/.resultset.json |
)
end
Then /^a JSON coverage report should have been generated(?: in "([^"]*)")?$/ do |coverage_dir|
coverage_dir ||= "coverage"
steps %(
Then the output should contain "Coverage report generated"
And a directory named "#{coverage_dir}" should exist
And the following files should exist:
| #{coverage_dir}/coverage.json |
)
end
Then /^no coverage report should have been generated(?: in "([^"]*)")?$/ do |coverage_dir|
coverage_dir ||= "coverage"
steps %(
Then the output should not contain "Coverage report generated"
And a directory named "#{coverage_dir}" should not exist
And the following files should not exist:
| #{coverage_dir}/index.html |
| #{coverage_dir}/.resultset.json |
)
end
Then /^the report should be based upon:$/ do |table|
frameworks = table.raw.flatten
steps %(
Then the output should contain "Coverage report generated for #{frameworks.join(', ')}"
And I should see "using #{frameworks.join(', ')}" within "#footer"
)
end
# This is necessary to ensure timing-dependant tests like the merge timeout
# do not fail on powerful machines.
When /^I wait for (\d+) seconds$/ do |seconds|
sleep seconds.to_i
end
Then "the overlay should be open" do
expect(page).to have_css("#cboxContent")
end
When "I install dependencies" do
# bundle may take its time
steps %(
When I successfully run `bundle` for up to 120 seconds
)
end
When "I pry" do
require "pry"
# rubocop:disable Lint/Debugger
binding.pry
# rubocop:enable Lint/Debugger
end
Given "I'm working on the project {string}" do |project_name|
this_dir = File.dirname(__FILE__)
# Clean up and create blank state for project
cd(".") do
FileUtils.rm_rf "project"
FileUtils.cp_r File.join(this_dir, "../../test_projects/#{project_name}/"), "project"
end
step 'I cd to "project"'
end