Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration test for groups in simplecov_json_formatter #1015

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ source "https://rubygems.org"

gem "matrix"

gem "simplecov_json_formatter", github: "PragTob/simplecov_json_formatter", branch: "group-support"

group :development do
gem "apparition", github: "twalpole/apparition" # LOCKED: When this is released, use a released version https://github.com/twalpole/apparition/pull/79
gem "aruba", "~> 1.0"
Expand Down
9 changes: 8 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
GIT
remote: https://github.com/PragTob/simplecov_json_formatter.git
revision: 9c78d46bd6577b2e74fba91335f013750f57dd14
branch: group-support
specs:
simplecov_json_formatter (0.1.3)

GIT
remote: https://github.com/twalpole/apparition.git
revision: ca86be4d54af835d531dbcd2b86e7b2c77f85f34
Expand Down Expand Up @@ -148,7 +155,6 @@ GEM
parser (>= 3.0.1.1)
ruby-progressbar (1.11.0)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.3)
spoon (0.0.6)
ffi
sys-uname (1.2.2)
Expand Down Expand Up @@ -189,6 +195,7 @@ DEPENDENCIES
rspec (~> 3.2)
rubocop
simplecov!
simplecov_json_formatter!
test-unit
webrick

Expand Down
2 changes: 2 additions & 0 deletions features/config_json_formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Feature:

When I successfully run `bundle exec rake test`
Then a JSON coverage report should have been generated in "coverage"
And the JSON report should have the right content
And the output should contain "JSON Coverage report generated"

Scenario: When CC_TEST_REPORTER_ID is set in the environment
Expand All @@ -44,4 +45,5 @@ Feature:
When I successfully run `bundle exec rake test`

Then a JSON coverage report should have been generated in "coverage"
And the JSON report should have the right content
And the output should contain "JSON Coverage report generated"
164 changes: 164 additions & 0 deletions features/fixtures/json_formatter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
{
"meta": {
"simplecov_version": "STUB_VERSION"
},
"coverage": {
"/STUB_BASE_DIRECTORY/tmp/aruba/project/lib/faked_project.rb": {
"lines": [
null,
null,
1,
1,
1,
null,
null,
null,
5,
3,
null,
null,
1
]
},
"/STUB_BASE_DIRECTORY/tmp/aruba/project/lib/faked_project/framework_specific.rb": {
"lines": [
null,
null,
null,
null,
null,
1,
1,
1,
0,
null,
null,
1,
0,
null,
null,
1,
1,
null,
null,
null
]
},
"/STUB_BASE_DIRECTORY/tmp/aruba/project/lib/faked_project/meta_magic.rb": {
"lines": [
null,
null,
1,
1,
1,
1,
null,
null,
null,
1,
1,
1,
null,
null,
null,
1,
1,
1,
null,
1,
1,
1,
null,
null,
null,
null
]
},
"/STUB_BASE_DIRECTORY/tmp/aruba/project/lib/faked_project/some_class.rb": {
"lines": [
null,
null,
1,
1,
1,
null,
1,
2,
null,
null,
1,
1,
null,
null,
1,
1,
1,
null,
0,
null,
null,
0,
null,
null,
1,
null,
1,
0,
null,
null
]
},
"/STUB_BASE_DIRECTORY/tmp/aruba/project/test/meta_magic_test.rb": {
"lines": [
null,
null,
1,
null,
1,
1,
1,
null,
null,
1,
1,
1,
1,
null,
null
]
},
"/STUB_BASE_DIRECTORY/tmp/aruba/project/test/some_class_test.rb": {
"lines": [
null,
null,
1,
null,
1,
1,
2,
null,
null,
1,
1,
null,
null,
1,
1,
null,
null
]
}
},
"groups": {
"Libs": {
"lines": {
"covered_percent": 86.11111111111111
}
},
"Ungrouped": {
"lines": {
"covered_percent": 100.0
}
}
}
}
25 changes: 25 additions & 0 deletions features/step_definitions/simplecov_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,31 @@
)
end

# this is highly bound to the test itself right now and might need
# adjustments in the future
Then /^the JSON report should have the right content$/ do
with_file_content "coverage/coverage.json" do |content|
expect(JSON.parse(content)).to eq(json_fixture)
end
end

DEFAULT_WORKING_DIRECTORY = "STUB_BASE_DIRECTORY"
def use_current_working_directory(file)
current_working_directory = File.expand_path("../..", File.dirname(__FILE__))
file.gsub!("/#{DEFAULT_WORKING_DIRECTORY}/", "#{current_working_directory}/")

file
end

VERSION_STUB = "STUB_VERSION"
def json_fixture
content = File.read("features/fixtures/json_formatter.json")
content = use_current_working_directory(content)
content.gsub!("STUB_VERSION", SimpleCov::VERSION)

JSON.parse(content)
end

Then /^no coverage report should have been generated(?: in "([^"]*)")?$/ do |coverage_dir|
coverage_dir ||= "coverage"
steps %(
Expand Down