Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

automatically generate rspec tests when spec directory is used - closes

  • Loading branch information...
commit 7a512f69d0d3d02f1e4d09452d224ddb9f188d9f 1 parent d101f02
@ryanb ryanb authored
View
6 features/nifty_scaffold.feature
@@ -21,13 +21,17 @@ Feature: Nifty Scaffold Generator
And I should successfully run "rails g nifty:scaffold Project -f"
And I add "gem 'mocha', :group => :test" to file "Gemfile"
Then I should successfully run "rake test"
-
+@focus
Scenario: Generate scaffold with rspec tests
Given a new Rails app
When I run "rails g nifty:scaffold Project name:string --rspec"
Then I should see the following files
| spec/models/project_spec.rb |
| spec/controllers/projects_controller_spec.rb |
+ When I run "rails g nifty:scaffold Task project_id:integer"
+ Then I should see the following files
+ | spec/models/task_spec.rb |
+ | spec/controllers/tasks_controller_spec.rb |
And I should see "resources :projects" in file "config/routes.rb"
When I run "rails g nifty:layout -f"
And I run "rake db:migrate"
View
4 lib/generators/nifty/scaffold/scaffold_generator.rb
@@ -64,7 +64,7 @@ def initialize(*args, &block)
def create_model
unless @skip_model
template 'model.rb', "app/models/#{singular_name}.rb"
- if options.rspec?
+ if test_framework == :rspec
template "tests/rspec/model.rb", "spec/models/#{singular_name}_spec.rb"
template 'fixtures.yml', "spec/fixtures/#{plural_name}.yml"
else
@@ -98,7 +98,7 @@ def create_controller
route "resources #{plural_name.to_sym.inspect}"
- if options.rspec?
+ if test_framework == :rspec
template "tests/#{test_framework}/controller.rb", "spec/controllers/#{plural_name}_controller_spec.rb"
else
template "tests/#{test_framework}/controller.rb", "test/functional/#{plural_name}_controller_test.rb"
Please sign in to comment.
Something went wrong with that request. Please try again.