Skip to content

Commit

Permalink
Fix hanami generate model when the given name is CamelCase
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Feb 24, 2016
1 parent 602ebee commit 11a3bc6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
5 changes: 0 additions & 5 deletions test/application_name_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
application_name = Hanami::ApplicationName.new('my app')
application_name.to_s.must_equal 'my_app'
end

it 'renders with underscores de-duplicated' do
application_name = Hanami::ApplicationName.new('my _app')
application_name.to_s.must_equal 'my_app'
end
end

describe '#to_env_s' do
Expand Down
8 changes: 4 additions & 4 deletions test/commands/generate/model_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
end
end

describe 'sanitizes model name' do
it 'downcases it' do
describe 'with CamelCase model name' do
it 'underscores it' do
with_temp_dir do |original_wd|
command = Hanami::Commands::Generate::Model.new({}, 'CaR')
command = Hanami::Commands::Generate::Model.new({}, 'BrokenCar')
capture_io { command.start }
assert_generated_file(original_wd.join('test/fixtures/commands/generate/model/car.rb'), 'lib/test_app/entities/car.rb')
assert_generated_file(original_wd.join('test/fixtures/commands/generate/model/broken_car.rb'), 'lib/test_app/entities/broken_car.rb')
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions test/commands/new/container_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
end

describe 'with valid arguments' do
it 'application name with dash' do
it 'project name with dash' do
with_temp_dir do |original_wd|
command = Hanami::Commands::New::Container.new({}, 'new-container')
capture_io { command.start }
Dir.chdir('new-container') do
Dir.chdir('new_container') do
actual_content = File.read('.env.development')
actual_content.must_include 'DATABASE_URL="file:///db/new_container_development"'

Expand All @@ -66,12 +66,12 @@
end
end

describe 'application name is a point' do
describe 'project name is a point' do
it 'generates application in current folder' do
with_temp_dir do |original_wd|
command = Hanami::Commands::New::Container.new({}, '.')
command = Hanami::Commands::New::Container.new({}, '.')
capture_io { command.start }
Dir.chdir('.') do
Dir.chdir('test_app') do
actual_content = File.read('.env.development')
actual_content.must_include 'DATABASE_URL="file:///db/test_app_development"'

Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/commands/generate/model/broken_car.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class BrokenCar
include Hanami::Entity
end

0 comments on commit 11a3bc6

Please sign in to comment.