grimen / dry_scaffold

Rails: A Rails scaffold generator that generates DRYer, cleaner, and more useful code. IMPORTANT: Not maintained anymore.
MIT License
124 stars 14 forks source link

dry_scaffold not working (Can't convert nil to String) #17

Open Merovex opened 14 years ago

Merovex commented 14 years ago

The command I'm running is the line below. The line immediately following is the only response I get from the attempt. This is on an established project that has no other (apparent) issues.

generate dry_scaffold User name:string email:string can't convert nil into String

I'm running Rails 2.3.5.

grimen commented 14 years ago

Too little info I'm afraid.

Merovex commented 14 years ago

That's nice. How about you tell me what you need?

Merovex commented 14 years ago

Okay, so instead of having the rather expected --trace, there's a --backtrace.

It appears there's a :test_unit default that does not actually set anything; which leads me to assume you have a default in your environment that I don't have in mine (Ubuntu 10.9)

Here's the offending line (inside the 'skip tests' option block): controller_tests_path = File.join(TEST_PATHS[test_framework], FUNCTIONAL_TESTS_PATH[test_framework])

Specifically, "FUNCTIONAL_TESTS_PATH[test_framework]" is nil.

FUNCTIONAL_TESTS_PATH has the following values:

{:shoulda=>"functional", :rspec=>"controllers", :test=>"functional"}

test_framework had the following value :test_unit

This is because:

./lib/dry_generator.rb:68:  DEFAULT_TEST_FRAMEWORK =      :test_unit
./lib/dry_generator.rb:92:    @test_framework = options[:test_framework] ||  DEFAULT_TEST_FRAMEWORK

And doing a grep on your entire library for :test_unit I find:

./lib/dry_generator.rb:51:      :test_unit        => CONFIG_OPTIONS['test_unit']    || CONFIG_OPTIONS['tunit'] || true,
./lib/dry_generator.rb:57:      :test_unit        => 'test',
./lib/dry_generator.rb:63:      :test_unit        => 'test',
./lib/dry_generator.rb:68:  DEFAULT_TEST_FRAMEWORK =      :test_unit
./lib/dry_generator.rb:122:        options[:test_unit] = v
./lib/dry_generator.rb:123:        options[:test_framework] = :test_unit

All caused by this:

[bwilson@bwilson-laptop]~/RailsProjects/collaborate$ generate dry_scaffold fred test:string --backtrace can't convert nil into String /usr/lib/ruby/gems/1.8/gems/akitaonrails-dry_scaffold-0.3.3/generators/dry_scaffold/dry_scaffold_generator.rb:145:in join' /usr/lib/ruby/gems/1.8/gems/akitaonrails-dry_scaffold-0.3.3/generators /dry_scaffold/dry_scaffold_generator.rb:145:inmanifest' /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails_generator/base.rb:163:in record' /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails_generator/manifest.rb:21:ininitialize' /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails_generator/base.rb:163:in new' /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails_generator/base.rb:163:inrecord' /usr/lib/ruby/gems/1.8/gems/akitaonrails-dry_scaffold-0.3.3/generators/dry_scaffold/dry_scaffold_generator.rb:132:in manifest' /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails_generator/commands.rb:42:ininvoke!' /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails_generator/scripts/../scripts.rb:31:in run' /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/generate.rb:6 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' ./script//generate:3

So, is that enough for you?

Merovex commented 14 years ago

When I add the --rspec to the command, it works fine. However, the examples you provide suggest explicitly calling out a test framework is optional; with the default being the broken test_unit.

Also, I tried setting the test framework in the scaffold.yml; with no love.

grimen commented 14 years ago

Good info and ellaboration, thanks. Yea that's not good. I noticed I broke something while fixing something other, and so far had no spare-time to look at it. These issue reportings is bulking up though, so something must happen soon. If you got time it would be great if you could come up with a fast patch that I can pull in - otherwise this will have to wait until I'm done with my current achievements (current project with a upcoming deadline - and related open-source work). Sorry for being a bad maintainer lately. =|

Merovex commented 14 years ago

Sorry, I don't use Git; so it would take me longer to figure out how to use it than for you to set FUNCTIONAL_TESTS_PATH[:test_unit] when you set the other values. I mean, it is a constant, its a default setting, and it isn't set.