Skip to content

kettle-jem: .rspec merge replaces rails_helper require#61

Description

@pboling

Bug

kettle-jem templating damaged a destination .rspec file by replacing a Rails-specific loader flag instead of preserving it.

Bad template commit:

  • a17317beff6f4e643c0767ca0356d5586597fb51
  • commit subject: 馃帹 Template bootstrap by kettle-jem v7.1.0
  • affected repo/member: galtzo-floss/sanitize_email
  • affected file: .rspec

Bad diff shape:

 --format progress
 --color
 --order random
---require rails_helper
+--require spec_helper
+--exclude-pattern spec/tmp/**/*_spec.rb
 --warnings
 --format html
 --out results/test_results.html

Scenario

sanitize_email is a Rails/Combustion-style gem whose suite relies on .rspec loading rails_helper before specs execute. The generated/template .rspec wanted to add --exclude-pattern spec/tmp/**/*_spec.rb, but the merge also changed the existing loader from rails_helper to spec_helper.

That turned a valid destination-specific RSpec option into the template default. The later release/test failure made it look like individual specs needed require "rails_helper", but that was only a symptom of this .rspec template damage.

Observed downstream symptoms included Rails-dependent specs running without the Rails test boot path during kettle-release/kettle-changelog coverage generation, requiring manual workaround edits in spec files.

Expected Behavior

Templating should preserve destination-specific RSpec loader options.

For this input shape, the result should retain:

--require rails_helper

and still add managed template flags such as:

--exclude-pattern spec/tmp/**/*_spec.rb

It should not replace rails_helper with spec_helper.

Likely Cause

The current .rspec merge appears to treat lines textually, without understanding option flags and their arguments. --require rails_helper and --require spec_helper are not two arbitrary independent lines; they are --require flag/value records with loader semantics.

Fixing this properly likely requires a --flag aware parser for .rspec / RSpec option files. We do not currently have that parser.

Regression Test Shape

Add a fixture-based regression with:

Destination .rspec:

--format progress
--color
--order random
--require rails_helper
--warnings
--format html
--out results/test_results.html

Template .rspec containing the template default loader and additive temp-spec exclusion:

--format progress
--color
--order random
--require spec_helper
--exclude-pattern spec/tmp/**/*_spec.rb
--warnings
--format html
--out results/test_results.html

Expected merged .rspec should preserve --require rails_helper and add --exclude-pattern spec/tmp/**/*_spec.rb without downgrading the loader to spec_helper.

Acceptance Criteria

  • kettle-jem has a regression spec for the exact .rspec shape above.
  • .rspec merge logic is flag-aware enough to treat flag/value pairs as structured records.
  • Destination --require rails_helper survives templating.
  • The fix does not require adding require "rails_helper" to every affected spec file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions