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 Original file line Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
run('bundle install') run('bundle install')


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


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


class_option :template_engine, :desc => "Template engine to generate view files" 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 def create_controller_files
return unless options[:controllers]

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


def create_view_files def create_view_files
return unless options[:views]

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


actions.each do |action| actions.each do |action|
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,8 +1,12 @@
<%= app_name %>.configure do <%= 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| config.generators do |g|
g.integration_tool :rspec g.integration_tool :rspec
g.test_framework :rspec, g.test_framework :rspec,
:fixture => false, :fixture => false,
:controllers => false,
:views => false, :views => false,
:routes => false, :routes => false,
:integration => true :integration => true
Expand Down
11 changes: 7 additions & 4 deletions lib/generators/rspec/scaffold/scaffold_generator.rb
Original file line number Original file line 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 :template_engine, :desc => "Template engine to generate view files"
class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller" class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller"


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


def copy_controller_files def copy_controller_files
return unless options[:controllers]

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


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


def stub_or_should_chain(mode, chain) 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 Original file line Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ def app


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


Rspec::Core.configure do |c| 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
end end
2 changes: 1 addition & 1 deletion lib/rspec/rails/example/request_example_group.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ def last_response
end end


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

0 comments on commit d5f2e47

Please sign in to comment.