mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-11-09 00:50:33 +00:00
Match module naming conventions to their help text
bumpy produced camelCase and camel produced BumpyCase, the reverse of the help text. A convention given as a symbol, as YAML configuration supplies it, was ignored. The Subversion add check read $! where it needed $?, the exit status. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
2b80d1a357
commit
f03f932b68
@@ -182,9 +182,9 @@ class UnityModuleGenerator
|
||||
############################
|
||||
def create_filename(part1, part2 = '')
|
||||
name = part2.empty? ? part1 : "#{part1}_#{part2}"
|
||||
case @options[:naming]
|
||||
when 'bumpy' then neutralize_filename(name, start_cap: false).delete('_')
|
||||
when 'camel' then neutralize_filename(name).delete('_')
|
||||
case @options[:naming]&.to_s
|
||||
when 'bumpy' then neutralize_filename(name).delete('_')
|
||||
when 'camel' then neutralize_filename(name, start_cap: false).delete('_')
|
||||
when 'snake' then neutralize_filename(name).downcase
|
||||
when 'caps' then neutralize_filename(name).upcase
|
||||
else name
|
||||
@@ -221,7 +221,7 @@ class UnityModuleGenerator
|
||||
end
|
||||
if @options[:update_svn]
|
||||
`svn add \"#{file[:path]}\"`
|
||||
if $!.exitstatus.zero?
|
||||
if $?.exitstatus.zero?
|
||||
puts "File #{file[:path]} created and added to source control"
|
||||
else
|
||||
puts "File #{file[:path]} created but FAILED adding to source control!"
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
# =========================================================================
|
||||
# Unity - A Test Framework for C
|
||||
# ThrowTheSwitch.org
|
||||
# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
||||
# SPDX-License-Identifier: MIT
|
||||
# =========================================================================
|
||||
|
||||
require '../auto/generate_module.rb'
|
||||
|
||||
# Each naming convention produces the case its help text names, whether the
|
||||
# convention arrives as a string or, from YAML, as a symbol
|
||||
describe 'UnityModuleGenerator naming' do
|
||||
def filename(naming, name = 'mad_science')
|
||||
UnityModuleGenerator.new(naming: naming).create_filename(name)
|
||||
end
|
||||
|
||||
it 'makes bumpy names start with a capital' do
|
||||
expect(filename('bumpy')).to eq('MadScience')
|
||||
end
|
||||
|
||||
it 'makes camel names start with a lowercase letter' do
|
||||
expect(filename('camel')).to eq('madScience')
|
||||
end
|
||||
|
||||
it 'makes snake and caps names' do
|
||||
expect(filename('snake', 'MadScience')).to eq('mad_science')
|
||||
expect(filename('caps', 'MadScience')).to eq('MAD_SCIENCE')
|
||||
end
|
||||
|
||||
it 'accepts a convention given as a symbol' do
|
||||
expect(filename(:bumpy)).to eq('MadScience')
|
||||
expect(filename(:snake, 'MadScience')).to eq('mad_science')
|
||||
end
|
||||
|
||||
it 'keeps a name as given without a convention' do
|
||||
expect(filename(nil, 'MadScience')).to eq('MadScience')
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user