Skip to content

Commit

Permalink
Temporarily disable generation of all but model and request specs
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Feb 7, 2010
1 parent 35e3e6c commit d5f2e47
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
7 changes: 4 additions & 3 deletions example_app_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
run('bundle install')

run('script/rails g rspec:install')
run('script/rails g model thing name:string')
run('script/rails g controller widgets index')
run('script/rails g integration_test widgets')
# run('script/rails g model thing name:string')
run('script/rails g scaffold wombats name:string')
# run('script/rails g controller widgets index')
# run('script/rails g integration_test widgets')

run('rake db:migrate')
run('rake db:test:prepare')
Expand Down
7 changes: 6 additions & 1 deletion lib/generators/rspec/controller/controller_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ class ControllerGenerator < Base
argument :actions, :type => :array, :default => [], :banner => "action action"

class_option :template_engine, :desc => "Template engine to generate view files"
class_option :views, :type => :boolean, :default => false
class_option :controllers, :type => :boolean, :default => false
class_option :views, :type => :boolean, :default => false

def create_controller_files
return unless options[:controllers]

template 'controller_spec.rb',
File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")
end

def create_view_files
return unless options[:views]

empty_directory File.join("spec", "views", file_path)

actions.each do |action|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<%= app_name %>.configure do
# We're still in alpha, so we're only generating model specs
# and request (integration) specs. We'll change these defaults
# as we add support for controller specs, etc.
config.generators do |g|
g.integration_tool :rspec
g.test_framework :rspec,
:fixture => false,
:controllers => false,
:views => false,
:routes => false,
:integration => true
Expand Down
11 changes: 7 additions & 4 deletions lib/generators/rspec/scaffold/scaffold_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ class ScaffoldGenerator < Base
class_option :template_engine, :desc => "Template engine to generate view files"
class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller"

class_option :views, :type => :boolean, :default => false
class_option :routes, :type => :boolean, :default => false
class_option :controllers, :type => :boolean, :default => false
class_option :views, :type => :boolean, :default => false
class_option :routes, :type => :boolean, :default => false

def copy_controller_files
return unless options[:controllers]

template 'controller_spec.rb',
File.join('spec/controllers', controller_class_path, "#{controller_file_name}_controller_spec.rb")
end
Expand Down Expand Up @@ -80,7 +83,7 @@ def mock_file_name(hash=nil)
# should! orm_class.find(User, "37")
# #=> User.should_receive(:get).with(37)
#
def should!(chain)
def should_receive!(chain)
stub_or_should_chain(:should_receive, chain)
end

Expand All @@ -95,7 +98,7 @@ def should!(chain)
# #=> User.stub!(:get).with(37)
#
def stub!(chain)
stub_or_should_chain(:stub!, chain)
stub_or_should_chain(:stub, chain)
end

def stub_or_should_chain(mode, chain)
Expand Down
6 changes: 3 additions & 3 deletions lib/rspec/rails/example/controller_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ def app

%w[get post put delete head].map do |method|
eval <<-CODE
def #{method}(action)
@_action = action
def #{method}(*args)
@_action = args.shift
super '/'
end
CODE
end

Rspec::Core.configure do |c|
c.include self, :behaviour => { :describes => lambda {|c| c < ::ActionController::Base} }
c.include self, :example_group => { :file_path => /\/spec\/controllers\// }
end
end
2 changes: 1 addition & 1 deletion lib/rspec/rails/example/request_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ def last_response
end

Rspec::Core.configure do |c|
c.include self, :behaviour => { :describes => /^\// }
c.include self, :example_group => { :file_path => /\/spec\/requests\// }
end
end

0 comments on commit d5f2e47

Please sign in to comment.