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

[Ruby] refactor: Introduce rubocop into CI pipeline #329

Open
wants to merge 7 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
12 changes: 12 additions & 0 deletions .github/workflows/test-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ on:
workflow_call:

jobs:
# TODO: LH - Implement this when ruby version for html-formatter becomes a minimum of v3.0
# This will save a lot of aggravation
# rubocop:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: ruby/setup-ruby@v1
# with:
# ruby-version: '2.6'
# bundler-cache: true
# - run: bundle exec rubocop

test-ruby:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Changed
- [Ruby] Alter asset template location scanner in codebase to be hardcoded (Was always only in one location) ([#329](https://github.com/cucumber/html-formatter/pull/329))

## [21.7.0] - 2024-08-12
### Changed
Expand Down
2 changes: 1 addition & 1 deletion ruby/cucumber-html-formatter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Gem::Specification.new do |s|
'source_code_uri' => 'https://github.com/cucumber/html-formatter'
}

s.add_runtime_dependency 'cucumber-messages', '> 19', '< 27'
s.add_dependency 'cucumber-messages', '> 19', '< 28'

s.add_development_dependency 'cucumber-compatibility-kit', '~> 15.2'
s.add_development_dependency 'rake', '~> 13.2'
Expand Down
2 changes: 1 addition & 1 deletion ruby/lib/cucumber/html_formatter/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def post_message
end

def template_writer
@template_writer ||= TemplateWriter.new(AssetsLoader.template)
@template_writer ||= TemplateWriter.new
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions ruby/lib/cucumber/html_formatter/template_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ module Cucumber
module HTMLFormatter
class TemplateWriter
attr_reader :template
private :template

def initialize(template)
@template = template
def initialize
@template = AssetsLoader.template
end

def write_between(from, to)
Expand Down
6 changes: 3 additions & 3 deletions ruby/spec/cucumber/html_formatter/assets_loader_spec.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# frozen_string_literal: true

describe Cucumber::HTMLFormatter::AssetsLoader do
describe '#template' do
describe '.template' do
it 'reads the content of assets/index.mustache.html' do
expect(File).to receive(:read).with(a_string_ending_with('assets/index.mustache.html'))

described_class.template
end
end

describe '#css' do
describe '.css' do
it 'reads the content of assets/main.css' do
expect(File).to receive(:read).with(a_string_ending_with('assets/main.css'))

described_class.css
end
end

describe '#script' do
describe '.script' do
it 'reads the content of assets/main.js' do
expect(File).to receive(:read).with(a_string_ending_with('assets/main.js'))

Expand Down
6 changes: 5 additions & 1 deletion ruby/spec/cucumber/html_formatter/template_writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

describe Cucumber::HTMLFormatter::TemplateWriter do
describe '#write_between' do
subject(:template_writer) { described_class.new(template) }
subject(:template_writer) { described_class.new }

before do
allow(Cucumber::HTMLFormatter::AssetsLoader).to receive(:template).and_return(template)
end

let(:template) { 'Some template {{here}} with content after' }

Expand Down