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

[WIP]: Проверка покрытия тестами изменений в PR #81

Open
wants to merge 5 commits 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,9 @@ jobs:
if: github.ref == 'refs/heads/main'
run: ./cc-test-reporter upload-coverage
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}

- name: Check code changes coverage
run: |
git fetch --update-head-ok origin main:main
./bin/undercover -c main
20 changes: 20 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require "simplecov-lcov"
require "undercover"
require "simplecov_json_formatter"

SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true

SimpleCov.start do
add_filter "/spec/"
add_filter "/features/"

formatter(
SimpleCov::Formatter::MultiFormatter.new(
[
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::JSONFormatter,
SimpleCov::Formatter::LcovFormatter
]
)
)
end
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,7 @@ group :test do
gem "selenium-webdriver"
gem "simplecov", "~> 0.21", require: false
gem "simplecov-json", require: false
gem "simplecov-lcov", "~> 0.8", require: false
gem "shoulda-matchers", "~> 6.2"
gem "undercover", "~> 0.5"
end
11 changes: 11 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ GEM
image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
imagen (0.1.8)
parser (>= 2.5, != 2.5.1.1)
importmap-rails (2.0.1)
actionpack (>= 6.0.0)
activesupport (>= 6.0.0)
Expand Down Expand Up @@ -313,6 +315,7 @@ GEM
ruby-vips (2.1.4)
ffi (~> 1.12)
rubyzip (2.3.2)
rugged (1.7.2)
selenium-webdriver (4.21.1)
base64 (~> 0.2)
rexml (~> 3.2, >= 3.2.5)
Expand All @@ -328,6 +331,7 @@ GEM
simplecov-json (0.2.3)
json
simplecov
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
Expand All @@ -350,6 +354,11 @@ GEM
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
undercover (0.5.0)
bigdecimal
imagen (>= 0.1.8)
rainbow (>= 2.1, < 4.0)
rugged (>= 0.27, < 1.8)
unicode-display_width (2.5.0)
web-console (4.2.1)
actionview (>= 6.0.0)
Expand Down Expand Up @@ -394,10 +403,12 @@ DEPENDENCIES
shoulda-matchers (~> 6.2)
simplecov (~> 0.21)
simplecov-json
simplecov-lcov (~> 0.8)
sprockets-rails
stimulus-rails
turbo-rails
tzinfo-data
undercover (~> 0.5)
web-console

RUBY VERSION
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/stories_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
class StoriesController < ApplicationController
before_action :set_story, only: %i[ show edit update destroy ]

def new_test_endpoint
random_number = rand(100)
sleep(2)

Array.new(20) { random_number + rand(3) }
end

# GET /stories or /stories.json
def index
@stories = Story.all
Expand Down
6 changes: 6 additions & 0 deletions bin/undercover
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby

require "rubygems"
require "bundler/setup"

load Gem.bin_path("undercover", "undercover")
2 changes: 0 additions & 2 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# files.

require 'simplecov'
SimpleCov.start

require 'cucumber/rails'

# By default, any exception happening in your Rails application will bubble up
Expand Down
10 changes: 0 additions & 10 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
require 'pathname'
require 'simplecov'
require "simplecov_json_formatter"

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::JSONFormatter
])

SimpleCov.start do
add_filter '/spec/'
end

class RootPath
def pathname
Expand Down
Loading