Skip to content

Commit

Permalink
Merge pull request #21 from corgibytes/add-acceptance-and-unit-testing
Browse files Browse the repository at this point in the history
Add acceptance and unit testing
  • Loading branch information
stevespringett authored Apr 6, 2023
2 parents 4e5e4eb + f510a03 commit dd3f29e
Show file tree
Hide file tree
Showing 25 changed files with 912 additions and 15 deletions.
30 changes: 20 additions & 10 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
name: Ruby CI
name: Ruby

on: [push, pull_request]
on:
push:
branches:
- main

pull_request:

jobs:
build:

runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }}
strategy:
matrix:
ruby:
- '3.2.2'
- '3.1.4'
- '3.0.6'
- '2.7.7'

steps:
- uses: actions/checkout@v3
- name: Set up Ruby 2.6
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.6'
- name: Build and test with Rake
run: |
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rake
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run the default task
run: bundle exec rake
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.idea
.idea
/Gemfile.lock
/tmp/aruba
/coverage
17 changes: 17 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
AllCops:
NewCops: enable
TargetRubyVersion: 2.7

inherit_from: .rubocop_todo.yml

# The behavior of RuboCop can be controlled via the .rubocop.yml
# configuration file. It makes it possible to enable/disable
# certain cops (checks) and to alter their behavior if they accept
# any parameters. The file can be placed either in your home
# directory or in some project directory.
#
# RuboCop will start looking for the configuration file in the directory
# where the inspected file is and continue its way up to the root directory.
#
# See https://docs.rubocop.org/rubocop/configuration

290 changes: 290 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-04-05 19:57:43 UTC using RuboCop version 1.49.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/DeprecatedAttributeAssignment:
Exclude:
- 'cyclonedx-ruby.gemspec'

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
# Include: **/*.gemspec
Gemspec/OrderedDependencies:
Exclude:
- 'cyclonedx-ruby.gemspec'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/RequireMFA:
Exclude:
- 'cyclonedx-ruby.gemspec'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLineAfterMagicComment:
Exclude:
- 'lib/bom_builder.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: around, only_before
Layout/EmptyLinesAroundAccessModifier:
Exclude:
- 'lib/bom_builder.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLinesAroundMethodBody:
Exclude:
- 'lib/bom_component.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
Layout/ExtraSpacing:
Exclude:
- 'cyclonedx-ruby.gemspec'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
Layout/FirstArrayElementIndentation:
Exclude:
- 'lib/bom_component.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/LeadingEmptyLines:
Exclude:
- 'lib/bom_component.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: final_newline, final_blank_line
Layout/TrailingEmptyLines:
Exclude:
- 'Rakefile'
- 'lib/bom_component.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
Exclude:
- 'Rakefile'
- 'spec/bom_component_spec.rb'

# Offense count: 2
Lint/IneffectiveAccessModifier:
Exclude:
- 'lib/bom_builder.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Lint/ScriptPermission:
Exclude:
- 'Rakefile'

# Offense count: 1
Lint/ShadowingOuterLocalVariable:
Exclude:
- 'lib/bom_builder.rb'

# Offense count: 19
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: strict, consistent
Lint/SymbolConversion:
Exclude:
- 'lib/bom_component.rb'
- 'lib/bom_helpers.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'lib/bom_builder.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier:
Exclude:
- 'lib/bom_builder.rb'

# Offense count: 4
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 67

# Offense count: 4
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 38

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 128

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 9

# Offense count: 6
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 68

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 12

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: PreferredName.
Naming/RescuedExceptionsVariableName:
Exclude:
- 'Rakefile'

# Offense count: 3
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'Rakefile'
- 'lib/bom_builder.rb'
- 'lib/bom_component.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedVars.
Style/FetchEnvVar:
Exclude:
- 'lib/bom_helpers.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/FileWrite:
Exclude:
- 'lib/bom_builder.rb'

# Offense count: 12
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Exclude:
- '.simplecov'
- 'Gemfile'
- 'Rakefile'
- 'features/fixtures/simple/Gemfile'
- 'features/step_definitions/json_bom_matching.rb'
- 'features/step_definitions/xml_bom_matching.rb'
- 'features/support/env.rb'
- 'features/support/simplecov_support.rb'
- 'lib/bom_component.rb'
- 'spec/bom_component_spec.rb'
- 'spec/bom_helpers_spec.rb'
- 'spec/spec_helper.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedMethods, AllowedPatterns.
Style/MethodCallWithoutArgsParentheses:
Exclude:
- 'lib/bom_helpers.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: literals, strict
Style/MutableConstant:
Exclude:
- 'lib/bom_builder.rb'

# Offense count: 2
Style/OpenStructUse:
Exclude:
- 'lib/bom_builder.rb'
- 'spec/bom_component_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
- 'Rakefile'

# Offense count: 19
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: .
# SupportedStyles: same_as_string_literals, single_quotes, double_quotes
Style/QuotedSymbols:
EnforcedStyle: double_quotes

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantBegin:
Exclude:
- 'Rakefile'

# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantRegexpEscape:
Exclude:
- 'features/step_definitions/json_bom_matching.rb'
- 'features/step_definitions/xml_bom_matching.rb'

# Offense count: 20
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- '.simplecov'
- 'Rakefile'
- 'cyclonedx-ruby.gemspec'
- 'lib/bom_component.rb'
- 'lib/bom_helpers.rb'
- 'spec/bom_component_spec.rb'
- 'spec/bom_helpers_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinSize.
# SupportedStyles: percent, brackets
Style/SymbolArray:
EnforcedStyle: brackets

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Style/SymbolLiteral:
Exclude:
- 'lib/bom_component.rb'

# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 237
38 changes: 38 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copied from https://github.com/cucumber/aruba/blob/3b1a6cea6e3ba55370c3396eef0a955aeb40f287/.simplecov
# Licensed under MIT - https://github.com/cucumber/aruba/blob/3b1a6cea6e3ba55370c3396eef0a955aeb40f287/LICENSE

SimpleCov.configure do
enable_for_subprocesses true

# Activate branch coverage
enable_coverage :branch

# ignore this file
add_filter ".simplecov"
add_filter "features"

# Rake tasks aren't tested with rspec
add_filter "Rakefile"
add_filter "lib/tasks"

#
# Changed Files in Git Group
# @see http://fredwu.me/post/35625566267/simplecov-test-coverage-for-changed-files-only
untracked = `git ls-files --exclude-standard --others`
unstaged = `git diff --name-only`
staged = `git diff --name-only --cached`
all = untracked + unstaged + staged
changed_filenames = all.split("\n")

add_group "Changed" do |source_file|
changed_filenames.select do |changed_filename|
source_file.filename.end_with?(changed_filename)
end
end

add_group "Libraries", "lib"

# Specs are reported on to ensure that all examples are being run and all
# lets, befores, afters, etc are being used.
add_group "Specs", "spec/"
end
Loading

0 comments on commit dd3f29e

Please sign in to comment.