diff options
author | Louise Crow <louise.crow@gmail.com> | 2011-02-23 12:06:34 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2011-02-23 12:06:34 +0000 |
commit | 4cd0de91754f07afd0afb58d137b3adcf5a07611 (patch) | |
tree | 1a16f0c5af85f5e7561012b027545183584e15b8 /vendor/plugins/rspec-rails/generators | |
parent | 44b78c1cd78607434b3666f5391ba68da647583f (diff) |
Removing rspec and rspec-rails plugins in favour of updated gems.
Diffstat (limited to 'vendor/plugins/rspec-rails/generators')
28 files changed, 0 insertions, 938 deletions
diff --git a/vendor/plugins/rspec-rails/generators/integration_spec/integration_spec_generator.rb b/vendor/plugins/rspec-rails/generators/integration_spec/integration_spec_generator.rb deleted file mode 100644 index 12a80e4fd..000000000 --- a/vendor/plugins/rspec-rails/generators/integration_spec/integration_spec_generator.rb +++ /dev/null @@ -1,10 +0,0 @@ -require File.dirname(__FILE__) + '/../rspec_default_values' - -class IntegrationSpecGenerator < ModelGenerator - def manifest - record do |m| - m.class_collisions class_path, class_name - m.template 'integration_spec.rb', File.join('spec/integration', class_path, "#{class_name.tableize}_spec.rb") - end - end -end diff --git a/vendor/plugins/rspec-rails/generators/integration_spec/templates/integration_spec.rb b/vendor/plugins/rspec-rails/generators/integration_spec/templates/integration_spec.rb deleted file mode 100644 index d4b91f87f..000000000 --- a/vendor/plugins/rspec-rails/generators/integration_spec/templates/integration_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'spec_helper' - -describe "<%= class_name.pluralize %>" do -end diff --git a/vendor/plugins/rspec-rails/generators/rspec/CHANGES b/vendor/plugins/rspec-rails/generators/rspec/CHANGES deleted file mode 100644 index 69f37090e..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec/CHANGES +++ /dev/null @@ -1 +0,0 @@ -Please refer to the CHANGES file for RSpec's core
\ No newline at end of file diff --git a/vendor/plugins/rspec-rails/generators/rspec/rspec_generator.rb b/vendor/plugins/rspec-rails/generators/rspec/rspec_generator.rb deleted file mode 100644 index 7dad53cbc..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec/rspec_generator.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'rbconfig' - -# This generator bootstraps a Rails project for use with RSpec -class RspecGenerator < Rails::Generator::Base - DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'], - Config::CONFIG['ruby_install_name']) - - def initialize(runtime_args, runtime_options = {}) - if test ?f, 'spec/spec_helper.rb' - - puts <<-HELPFUL_INSTRUCTIONS - -It looks like you are upgrading rspec-rails in this application. Please let -this script overwrite everything it wants to with the following exceptions, -*if* you have customized any of these files: - - * spec/spec.opts - * spec/rcov.opts - * spec/spec_helper.rb - -If you have customized spec/spec_helper.rb, please set aside a copy of that -file so that it can be updated and you can manually restore your changes. - -HELPFUL_INSTRUCTIONS - end - Dir.mkdir('lib/tasks') unless File.directory?('lib/tasks') - super - end - - def manifest - record do |m| - script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] } - - m.directory 'lib/tasks' - m.file 'rspec.rake', 'lib/tasks/rspec.rake' - - m.file 'script/autospec', 'script/autospec', script_options - m.file 'script/spec', 'script/spec', script_options - - m.directory 'spec' - m.file 'rcov.opts', 'spec/rcov.opts' - m.file 'spec.opts', 'spec/spec.opts' - m.template 'spec_helper.rb', 'spec/spec_helper.rb' - end - end - -protected - - def banner - "Usage: #{$0} rspec" - end - -end diff --git a/vendor/plugins/rspec-rails/generators/rspec/templates/previous_failures.txt b/vendor/plugins/rspec-rails/generators/rspec/templates/previous_failures.txt deleted file mode 100644 index e69de29bb..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec/templates/previous_failures.txt +++ /dev/null diff --git a/vendor/plugins/rspec-rails/generators/rspec/templates/rcov.opts b/vendor/plugins/rspec-rails/generators/rspec/templates/rcov.opts deleted file mode 100644 index 274ed51ad..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec/templates/rcov.opts +++ /dev/null @@ -1,2 +0,0 @@ ---exclude "spec/*,gems/*" ---rails
\ No newline at end of file diff --git a/vendor/plugins/rspec-rails/generators/rspec/templates/rspec.rake b/vendor/plugins/rspec-rails/generators/rspec/templates/rspec.rake deleted file mode 100644 index dba3ffcc1..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec/templates/rspec.rake +++ /dev/null @@ -1,144 +0,0 @@ -gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9 -rspec_gem_dir = nil -Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir| - rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb") -end -rspec_plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec') - -if rspec_gem_dir && (test ?d, rspec_plugin_dir) - raise "\n#{'*'*50}\nYou have rspec installed in both vendor/gems and vendor/plugins\nPlease pick one and dispose of the other.\n#{'*'*50}\n\n" -end - -if rspec_gem_dir - $LOAD_PATH.unshift("#{rspec_gem_dir}/lib") -elsif File.exist?(rspec_plugin_dir) - $LOAD_PATH.unshift("#{rspec_plugin_dir}/lib") -end - -# Don't load rspec if running "rake gems:*" -unless ARGV.any? {|a| a =~ /^gems/} - -begin - require 'spec/rake/spectask' -rescue MissingSourceFile - module Spec - module Rake - class SpecTask - def initialize(name) - task name do - # if rspec-rails is a configured gem, this will output helpful material and exit ... - require File.expand_path(File.join(File.dirname(__FILE__),"..","..","config","environment")) - - # ... otherwise, do this: - raise <<-MSG - -#{"*" * 80} -* You are trying to run an rspec rake task defined in -* #{__FILE__}, -* but rspec can not be found in vendor/gems, vendor/plugins or system gems. -#{"*" * 80} -MSG - end - end - end - end - end -end - -Rake.application.instance_variable_get('@tasks').delete('default') - -spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop -task :noop do -end - -task :default => :spec -task :stats => "spec:statsetup" - -desc "Run all specs in spec directory (excluding plugin specs)" -Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t| - t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] - t.spec_files = FileList['spec/**/*_spec.rb'] -end - -namespace :spec do - desc "Run all specs in spec directory with RCov (excluding plugin specs)" - Spec::Rake::SpecTask.new(:rcov) do |t| - t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] - t.spec_files = FileList['spec/**/*_spec.rb'] - t.rcov = true - t.rcov_opts = lambda do - IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten - end - end - - desc "Print Specdoc for all specs (excluding plugin specs)" - Spec::Rake::SpecTask.new(:doc) do |t| - t.spec_opts = ["--format", "specdoc", "--dry-run"] - t.spec_files = FileList['spec/**/*_spec.rb'] - end - - desc "Print Specdoc for all plugin examples" - Spec::Rake::SpecTask.new(:plugin_doc) do |t| - t.spec_opts = ["--format", "specdoc", "--dry-run"] - t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*') - end - - [:models, :controllers, :views, :helpers, :lib, :integration].each do |sub| - desc "Run the code examples in spec/#{sub}" - Spec::Rake::SpecTask.new(sub => spec_prereq) do |t| - t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] - t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"] - end - end - - desc "Run the code examples in vendor/plugins (except RSpec's own)" - Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t| - t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] - t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*") - end - - namespace :plugins do - desc "Runs the examples for rspec_on_rails" - Spec::Rake::SpecTask.new(:rspec_on_rails) do |t| - t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] - t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb'] - end - end - - # Setup specs for stats - task :statsetup do - require 'code_statistics' - ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models') - ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views') - ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers') - ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers') - ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib') - ::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing') - ::STATS_DIRECTORIES << %w(Integration\ specs spec/integration) if File.exist?('spec/integration') - ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models') - ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views') - ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers') - ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers') - ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib') - ::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing') - ::CodeStatistics::TEST_TYPES << "Integration specs" if File.exist?('spec/integration') - end - - namespace :db do - namespace :fixtures do - desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z." - task :load => :environment do - ActiveRecord::Base.establish_connection(Rails.env) - base_dir = File.join(Rails.root, 'spec', 'fixtures') - fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir - - require 'active_record/fixtures' - (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file| - Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*')) - end - end - end - end -end - -end diff --git a/vendor/plugins/rspec-rails/generators/rspec/templates/script/autospec b/vendor/plugins/rspec-rails/generators/rspec/templates/script/autospec deleted file mode 100644 index 837bbd7f4..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec/templates/script/autospec +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby -gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9 -ENV['RSPEC'] = 'true' # allows autotest to discover rspec -ENV['AUTOTEST'] = 'true' # allows autotest to run w/ color on linux -system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) || - $stderr.puts("Unable to find autotest. Please install ZenTest or fix your PATH") diff --git a/vendor/plugins/rspec-rails/generators/rspec/templates/script/spec b/vendor/plugins/rspec-rails/generators/rspec/templates/script/spec deleted file mode 100644 index 46fdbe6e4..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec/templates/script/spec +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env ruby -if ARGV.any? {|arg| %w[--drb -X --generate-options -G --help -h --version -v].include?(arg)} - require 'rubygems' unless ENV['NO_RUBYGEMS'] -else - gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9 - ENV["RAILS_ENV"] ||= 'test' - require File.expand_path(File.dirname(__FILE__) + "/../config/environment") unless defined?(RAILS_ROOT) -end -require 'spec/autorun' -exit ::Spec::Runner::CommandLine.run diff --git a/vendor/plugins/rspec-rails/generators/rspec/templates/spec.opts b/vendor/plugins/rspec-rails/generators/rspec/templates/spec.opts deleted file mode 100644 index 391705bf8..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec/templates/spec.opts +++ /dev/null @@ -1,4 +0,0 @@ ---colour ---format progress ---loadby mtime ---reverse diff --git a/vendor/plugins/rspec-rails/generators/rspec/templates/spec_helper.rb b/vendor/plugins/rspec-rails/generators/rspec/templates/spec_helper.rb deleted file mode 100644 index 0ba147062..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec/templates/spec_helper.rb +++ /dev/null @@ -1,54 +0,0 @@ -# This file is copied to ~/spec when you run 'ruby script/generate rspec' -# from the project root directory. -ENV["RAILS_ENV"] ||= 'test' -require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment')) -require 'spec/autorun' -require 'spec/rails' - -# Uncomment the next line to use webrat's matchers -#require 'webrat/integrations/rspec-rails' - -# Requires supporting files with custom matchers and macros, etc, -# in ./support/ and its subdirectories. -Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f} - -Spec::Runner.configure do |config| - # If you're not using ActiveRecord you should remove these - # lines, delete config/database.yml and disable :active_record - # in your config/boot.rb - config.use_transactional_fixtures = true - config.use_instantiated_fixtures = false - config.fixture_path = RAILS_ROOT + '/spec/fixtures/' - - # == Fixtures - # - # You can declare fixtures for each example_group like this: - # describe "...." do - # fixtures :table_a, :table_b - # - # Alternatively, if you prefer to declare them only once, you can - # do so right here. Just uncomment the next line and replace the fixture - # names with your fixtures. - # - # config.global_fixtures = :table_a, :table_b - # - # If you declare global fixtures, be aware that they will be declared - # for all of your examples, even those that don't use them. - # - # You can also declare which fixtures to use (for example fixtures for test/fixtures): - # - # config.fixture_path = RAILS_ROOT + '/spec/fixtures/' - # - # == Mock Framework - # - # RSpec uses it's own mocking framework by default. If you prefer to - # use mocha, flexmock or RR, uncomment the appropriate line: - # - # config.mock_with :mocha - # config.mock_with :flexmock - # config.mock_with :rr - # - # == Notes - # - # For more information take a look at Spec::Runner::Configuration and Spec::Runner -end diff --git a/vendor/plugins/rspec-rails/generators/rspec_controller/USAGE b/vendor/plugins/rspec-rails/generators/rspec_controller/USAGE deleted file mode 100755 index 1546c325d..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_controller/USAGE +++ /dev/null @@ -1,33 +0,0 @@ -Description: - The rspec_controller generator creates stub specs and files for a new - controller and its views. - - The generator takes a controller name and a list of views as arguments. - The controller name may be given in CamelCase or under_score and should - not be suffixed with 'Controller'. To create a controller within a - module, specify the controller name as 'module/controller'. - - The generator creates stubs for a controller (and spec), a view (and spec) - for each view in the argument list, plus a helper. - -Example: - ./script/generate rspec_controller dog bark fetch - ... - create spec/controllers/dog_controller_spec.rb - create app/controllers/dog_controller.rb - create app/helpers/dog_helper.rb - create spec/views/dog/bark_view_spec.rb - create app/views/dog/bark.rhtml - create spec/views/dog/fetch_view_spec.rb - create app/views/dog/fetch.rhtml - -Modules Example: - ./script/generate rspec_controller 'pets/dog' bark fetch - ... - create spec/controllers/pets/dog_controller_spec.rb - create app/controllers/pets/dog_controller.rb - create app/helpers/pets/dog_helper.rb - create spec/views/pets/dog/bark_view_spec.rb - create app/views/pets/dog/bark.rhtml - create spec/views/pets/dog/fetch_view_spec.rb - create app/views/pets/dog/fetch.rhtml diff --git a/vendor/plugins/rspec-rails/generators/rspec_controller/rspec_controller_generator.rb b/vendor/plugins/rspec-rails/generators/rspec_controller/rspec_controller_generator.rb deleted file mode 100755 index 0064986d2..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_controller/rspec_controller_generator.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'rails_generator/generators/components/controller/controller_generator' - -class RspecControllerGenerator < ControllerGenerator - - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions class_path, "#{class_name}Controller", "#{class_name}Helper" - - # Controller, helper, views, and spec directories. - m.directory File.join('app/controllers', class_path) - m.directory File.join('app/helpers', class_path) - m.directory File.join('app/views', class_path, file_name) - m.directory File.join('spec/controllers', class_path) - m.directory File.join('spec/helpers', class_path) - m.directory File.join('spec/views', class_path, file_name) - - @default_file_extension = "html.erb" - - # Controller spec, class, and helper. - m.template 'controller_spec.rb', - File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb") - - m.template 'helper_spec.rb', - File.join('spec/helpers', class_path, "#{file_name}_helper_spec.rb") - - m.template 'controller:controller.rb', - File.join('app/controllers', class_path, "#{file_name}_controller.rb") - - m.template 'controller:helper.rb', - File.join('app/helpers', class_path, "#{file_name}_helper.rb") - - - - # Spec and view template for each action. - actions.each do |action| - m.template 'view_spec.rb', - File.join('spec/views', class_path, file_name, "#{action}.#{@default_file_extension}_spec.rb"), - :assigns => { :action => action, :model => file_name } - path = File.join('app/views', class_path, file_name, "#{action}.#{@default_file_extension}") - m.template "controller:view.#{@default_file_extension}", - path, - :assigns => { :action => action, :path => path } - end - end - end -end diff --git a/vendor/plugins/rspec-rails/generators/rspec_controller/templates/controller_spec.rb b/vendor/plugins/rspec-rails/generators/rspec_controller/templates/controller_spec.rb deleted file mode 100755 index 9d13c49c6..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_controller/templates/controller_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe <%= class_name %>Controller do - -<% if actions.empty? -%> - #Delete this example and add some real ones -<% else -%> - #Delete these examples and add some real ones -<% end -%> - it "should use <%= class_name %>Controller" do - controller.should be_an_instance_of(<%= class_name %>Controller) - end - -<% unless actions.empty? -%> -<% for action in actions -%> - - describe "GET '<%= action %>'" do - it "should be successful" do - get '<%= action %>' - response.should be_success - end - end -<% end -%> -<% end -%> -end diff --git a/vendor/plugins/rspec-rails/generators/rspec_controller/templates/helper_spec.rb b/vendor/plugins/rspec-rails/generators/rspec_controller/templates/helper_spec.rb deleted file mode 100644 index ffdfd14f2..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_controller/templates/helper_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'spec_helper' - -describe <%= class_name %>Helper do - - #Delete this example and add some real ones or delete this file - it "should be included in the object returned by #helper" do - included_modules = (class << helper; self; end).send :included_modules - included_modules.should include(<%= class_name %>Helper) - end - -end diff --git a/vendor/plugins/rspec-rails/generators/rspec_controller/templates/view_spec.rb b/vendor/plugins/rspec-rails/generators/rspec_controller/templates/view_spec.rb deleted file mode 100644 index 31469c606..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_controller/templates/view_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -describe "/<%= class_name.underscore %>/<%= action %>" do - before(:each) do - render '<%= class_name.underscore %>/<%= action %>' - end - - #Delete this example and add some real ones or delete this file - it "should tell you where to find the file" do - response.should have_tag('p', %r[Find me in app/views/<%= class_name.underscore %>/<%= action %>]) - end -end diff --git a/vendor/plugins/rspec-rails/generators/rspec_default_values.rb b/vendor/plugins/rspec-rails/generators/rspec_default_values.rb deleted file mode 100644 index 162681a36..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_default_values.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Rails - module Generator - class GeneratedAttribute - def default_value - @default_value ||= case type - when :int, :integer then "1" - when :float then "1.5" - when :decimal then "9.99" - when :datetime, :timestamp, :time then "Time.now" - when :date then "Date.today" - when :string, :text then "\"value for #{@name}\"" - when :boolean then "false" - when :belongs_to, :references then "1" - else - "" - end - end - - def name_or_reference - if ::Rails::VERSION::STRING >= '2.2' - reference? ? :"#{name}_id" : name - else - name - end - end - end - end -end diff --git a/vendor/plugins/rspec-rails/generators/rspec_model/USAGE b/vendor/plugins/rspec-rails/generators/rspec_model/USAGE deleted file mode 100755 index a7b781414..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_model/USAGE +++ /dev/null @@ -1,18 +0,0 @@ -Description: - The rspec_model generator creates stubs for a new model. - - The generator takes a model name as its argument. The model name may be - given in CamelCase or under_score and should not be suffixed with 'Model'. - - The generator creates a model class in app/models, an RSpec spec in - spec/models, database fixtures in spec/fixtures/plural_name.yml, and a migration - in db/migrate. - -Example: - ./script/generate rspec_model Account - - This will create an Account model: - Model: app/models/account.rb - Spec: spec/models/account_spec.rb - Fixtures: spec/fixtures/accounts.yml - Migration: db/migrate/XXX_add_accounts.rb diff --git a/vendor/plugins/rspec-rails/generators/rspec_model/rspec_model_generator.rb b/vendor/plugins/rspec-rails/generators/rspec_model/rspec_model_generator.rb deleted file mode 100755 index 66e873e31..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_model/rspec_model_generator.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'rails_generator/generators/components/model/model_generator' -require File.dirname(__FILE__) + '/../rspec_default_values' - -class RspecModelGenerator < ModelGenerator - - def manifest - - record do |m| - # Check for class naming collisions. - m.class_collisions class_path, class_name - - # Model, spec, and fixture directories. - m.directory File.join('app/models', class_path) - m.directory File.join('spec/models', class_path) - unless options[:skip_fixture] - m.directory File.join('spec/fixtures', class_path) - end - - # Model class, spec and fixtures. - m.template 'model:model.rb', File.join('app/models', class_path, "#{file_name}.rb") - m.template 'model_spec.rb', File.join('spec/models', class_path, "#{file_name}_spec.rb") - unless options[:skip_fixture] - m.template 'model:fixtures.yml', File.join('spec/fixtures', "#{table_name}.yml") - end - - unless options[:skip_migration] - m.migration_template 'model:migration.rb', 'db/migrate', :assigns => { - :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}" - }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}" - end - - end - end - -end diff --git a/vendor/plugins/rspec-rails/generators/rspec_model/templates/model_spec.rb b/vendor/plugins/rspec-rails/generators/rspec_model/templates/model_spec.rb deleted file mode 100755 index c7cb1ce78..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_model/templates/model_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'spec_helper' - -describe <%= class_name %> do - before(:each) do - @valid_attributes = { - <%= attributes.map{|a| ":#{a.name_or_reference} => #{a.default_value}" }.join(",\n ") %> - } - end - - it "should create a new instance given valid attributes" do - <%= class_name %>.create!(@valid_attributes) - end -end diff --git a/vendor/plugins/rspec-rails/generators/rspec_scaffold/rspec_scaffold_generator.rb b/vendor/plugins/rspec-rails/generators/rspec_scaffold/rspec_scaffold_generator.rb deleted file mode 100644 index 0761c0031..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_scaffold/rspec_scaffold_generator.rb +++ /dev/null @@ -1,154 +0,0 @@ -require File.dirname(__FILE__) + '/../rspec_default_values' - -class RspecScaffoldGenerator < Rails::Generator::NamedBase - default_options :skip_migration => false - - attr_reader :controller_name, - :controller_class_path, - :controller_file_path, - :controller_class_nesting, - :controller_class_nesting_depth, - :controller_class_name, - :controller_singular_name, - :controller_plural_name, - :resource_edit_path, - :default_file_extension - alias_method :controller_file_name, :controller_singular_name - alias_method :controller_table_name, :controller_plural_name - - def initialize(runtime_args, runtime_options = {}) - super - - @controller_name = @name.pluralize - - base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name) - @controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name) - - if @controller_class_nesting.empty? - @controller_class_name = @controller_class_name_without_nesting - else - @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}" - end - - @default_file_extension = "html.erb" - end - - def manifest - record do |m| - - # Check for class naming collisions. - m.class_collisions(controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}Helper") - m.class_collisions(class_path, "#{class_name}") - - # Controller, helper, views, and spec directories. - m.directory(File.join('app/models', class_path)) - m.directory(File.join('app/controllers', controller_class_path)) - m.directory(File.join('app/helpers', controller_class_path)) - m.directory(File.join('app/views', controller_class_path, controller_file_name)) - m.directory(File.join('app/views/layouts', controller_class_path)) - m.directory(File.join('public/stylesheets', class_path)) - - m.directory(File.join('spec/controllers', controller_class_path)) - m.directory(File.join('spec/routing', controller_class_path)) - m.directory(File.join('spec/models', class_path)) - m.directory(File.join('spec/helpers', class_path)) - m.directory File.join('spec/fixtures', class_path) - m.directory File.join('spec/views', controller_class_path, controller_file_name) - m.directory File.join('spec/integration', class_path) - - # Layout and stylesheet. - m.template("scaffold:layout.html.erb", File.join('app/views/layouts', controller_class_path, "#{controller_file_name}.html.erb")) - m.template("scaffold:style.css", 'public/stylesheets/scaffold.css') - - # Controller spec, class, and helper. - m.template 'rspec_scaffold:routing_spec.rb', - File.join('spec/routing', controller_class_path, "#{controller_file_name}_routing_spec.rb") - - m.template 'rspec_scaffold:controller_spec.rb', - File.join('spec/controllers', controller_class_path, "#{controller_file_name}_controller_spec.rb") - - m.template "scaffold:controller.rb", - File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb") - - m.template 'rspec_scaffold:helper_spec.rb', - File.join('spec/helpers', class_path, "#{controller_file_name}_helper_spec.rb") - - m.template "scaffold:helper.rb", - File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb") - - for action in scaffold_views - m.template( - "scaffold:view_#{action}.#{@default_file_extension}", - File.join('app/views', controller_class_path, controller_file_name, "#{action}.#{default_file_extension}") - ) - end - - # Model class, unit test, and fixtures. - m.template 'model:model.rb', File.join('app/models', class_path, "#{file_name}.rb") - m.template 'model:fixtures.yml', File.join('spec/fixtures', class_path, "#{table_name}.yml") - m.template 'rspec_model:model_spec.rb', File.join('spec/models', class_path, "#{file_name}_spec.rb") - - # View specs - m.template "rspec_scaffold:edit_erb_spec.rb", - File.join('spec/views', controller_class_path, controller_file_name, "edit.#{default_file_extension}_spec.rb") - m.template "rspec_scaffold:index_erb_spec.rb", - File.join('spec/views', controller_class_path, controller_file_name, "index.#{default_file_extension}_spec.rb") - m.template "rspec_scaffold:new_erb_spec.rb", - File.join('spec/views', controller_class_path, controller_file_name, "new.#{default_file_extension}_spec.rb") - m.template "rspec_scaffold:show_erb_spec.rb", - File.join('spec/views', controller_class_path, controller_file_name, "show.#{default_file_extension}_spec.rb") - - # Integration - m.template 'integration_spec:integration_spec.rb', File.join('spec/integration', class_path, "#{table_name}_spec.rb") - - unless options[:skip_migration] - m.migration_template( - 'model:migration.rb', 'db/migrate', - :assigns => { - :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}", - :attributes => attributes - }, - :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}" - ) - end - - m.route_resources controller_file_name - - end - end - - protected - # Override with your own usage banner. - def banner - "Usage: #{$0} rspec_scaffold ModelName [field:type field:type]" - end - - def add_options!(opt) - opt.separator '' - opt.separator 'Options:' - opt.on("--skip-migration", - "Don't generate a migration file for this model") { |v| options[:skip_migration] = v } - end - - def scaffold_views - %w[ index show new edit ] - end - - def model_name - class_name.demodulize - end -end - -module Rails - module Generator - class GeneratedAttribute - def input_type - @input_type ||= case type - when :text then "textarea" - else - "input" - end - end - end - end -end diff --git a/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/controller_spec.rb b/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/controller_spec.rb deleted file mode 100755 index 5de71bb58..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/controller_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'spec_helper' - -describe <%= controller_class_name %>Controller do - - def mock_<%= file_name %>(stubs={}) - @mock_<%= file_name %> ||= mock_model(<%= class_name %>, stubs) - end - - describe "GET index" do - it "assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do - <%= class_name %>.stub!(:find).with(:all).and_return([mock_<%= file_name %>]) - get :index - assigns[:<%= table_name %>].should == [mock_<%= file_name %>] - end - end - - describe "GET show" do - it "assigns the requested <%= file_name %> as @<%= file_name %>" do - <%= class_name %>.stub!(:find).with("37").and_return(mock_<%= file_name %>) - get :show, :id => "37" - assigns[:<%= file_name %>].should equal(mock_<%= file_name %>) - end - end - - describe "GET new" do - it "assigns a new <%= file_name %> as @<%= file_name %>" do - <%= class_name %>.stub!(:new).and_return(mock_<%= file_name %>) - get :new - assigns[:<%= file_name %>].should equal(mock_<%= file_name %>) - end - end - - describe "GET edit" do - it "assigns the requested <%= file_name %> as @<%= file_name %>" do - <%= class_name %>.stub!(:find).with("37").and_return(mock_<%= file_name %>) - get :edit, :id => "37" - assigns[:<%= file_name %>].should equal(mock_<%= file_name %>) - end - end - - describe "POST create" do - - describe "with valid params" do - it "assigns a newly created <%= file_name %> as @<%= file_name %>" do - <%= class_name %>.stub!(:new).with({'these' => 'params'}).and_return(mock_<%= file_name %>(:save => true)) - post :create, :<%= file_name %> => {:these => 'params'} - assigns[:<%= file_name %>].should equal(mock_<%= file_name %>) - end - - it "redirects to the created <%= file_name %>" do - <%= class_name %>.stub!(:new).and_return(mock_<%= file_name %>(:save => true)) - post :create, :<%= file_name %> => {} - response.should redirect_to(<%= table_name.singularize %>_url(mock_<%= file_name %>)) - end - end - - describe "with invalid params" do - it "assigns a newly created but unsaved <%= file_name %> as @<%= file_name %>" do - <%= class_name %>.stub!(:new).with({'these' => 'params'}).and_return(mock_<%= file_name %>(:save => false)) - post :create, :<%= file_name %> => {:these => 'params'} - assigns[:<%= file_name %>].should equal(mock_<%= file_name %>) - end - - it "re-renders the 'new' template" do - <%= class_name %>.stub!(:new).and_return(mock_<%= file_name %>(:save => false)) - post :create, :<%= file_name %> => {} - response.should render_template('new') - end - end - - end - - describe "PUT update" do - - describe "with valid params" do - it "updates the requested <%= file_name %>" do - <%= class_name %>.should_receive(:find).with("37").and_return(mock_<%= file_name %>) - mock_<%= file_name %>.should_receive(:update_attributes).with({'these' => 'params'}) - put :update, :id => "37", :<%= file_name %> => {:these => 'params'} - end - - it "assigns the requested <%= file_name %> as @<%= file_name %>" do - <%= class_name %>.stub!(:find).and_return(mock_<%= file_name %>(:update_attributes => true)) - put :update, :id => "1" - assigns[:<%= file_name %>].should equal(mock_<%= file_name %>) - end - - it "redirects to the <%= file_name %>" do - <%= class_name %>.stub!(:find).and_return(mock_<%= file_name %>(:update_attributes => true)) - put :update, :id => "1" - response.should redirect_to(<%= table_name.singularize %>_url(mock_<%= file_name %>)) - end - end - - describe "with invalid params" do - it "updates the requested <%= file_name %>" do - <%= class_name %>.should_receive(:find).with("37").and_return(mock_<%= file_name %>) - mock_<%= file_name %>.should_receive(:update_attributes).with({'these' => 'params'}) - put :update, :id => "37", :<%= file_name %> => {:these => 'params'} - end - - it "assigns the <%= file_name %> as @<%= file_name %>" do - <%= class_name %>.stub!(:find).and_return(mock_<%= file_name %>(:update_attributes => false)) - put :update, :id => "1" - assigns[:<%= file_name %>].should equal(mock_<%= file_name %>) - end - - it "re-renders the 'edit' template" do - <%= class_name %>.stub!(:find).and_return(mock_<%= file_name %>(:update_attributes => false)) - put :update, :id => "1" - response.should render_template('edit') - end - end - - end - - describe "DELETE destroy" do - it "destroys the requested <%= file_name %>" do - <%= class_name %>.should_receive(:find).with("37").and_return(mock_<%= file_name %>) - mock_<%= file_name %>.should_receive(:destroy) - delete :destroy, :id => "37" - end - - it "redirects to the <%= table_name %> list" do - <%= class_name %>.stub!(:find).and_return(mock_<%= file_name %>(:destroy => true)) - delete :destroy, :id => "1" - response.should redirect_to(<%= table_name %>_url) - end - end - -end diff --git a/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/edit_erb_spec.rb b/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/edit_erb_spec.rb deleted file mode 100644 index 4f9a7911c..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/edit_erb_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%> -describe "/<%= table_name %>/edit.<%= default_file_extension %>" do - include <%= controller_class_name %>Helper - - before(:each) do - assigns[:<%= file_name %>] = @<%= file_name %> = stub_model(<%= class_name %>, - :new_record? => false<%= output_attributes.empty? ? '' : ',' %> -<% output_attributes.each_with_index do |attribute, attribute_index| -%> - :<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index == output_attributes.length - 1 ? '' : ','%> -<% end -%> - ) - end - - it "renders the edit <%= file_name %> form" do - render - - response.should have_tag("form[action=#{<%= file_name %>_path(@<%= file_name %>)}][method=post]") do -<% for attribute in output_attributes -%> - with_tag('<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>[name=?]', "<%= file_name %>[<%= attribute.name %>]") -<% end -%> - end - end -end diff --git a/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/helper_spec.rb b/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/helper_spec.rb deleted file mode 100644 index ad657cf05..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/helper_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'spec_helper' - -describe <%= controller_class_name %>Helper do - - #Delete this example and add some real ones or delete this file - it "is included in the helper object" do - included_modules = (class << helper; self; end).send :included_modules - included_modules.should include(<%= controller_class_name %>Helper) - end - -end diff --git a/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/index_erb_spec.rb b/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/index_erb_spec.rb deleted file mode 100644 index 5aa33d5b2..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/index_erb_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'spec_helper' - -<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%> -describe "/<%= table_name %>/index.<%= default_file_extension %>" do - include <%= controller_class_name %>Helper - - before(:each) do - assigns[:<%= table_name %>] = [ -<% [1,2].each_with_index do |id, model_index| -%> - stub_model(<%= class_name %><%= output_attributes.empty? ? (model_index == 1 ? ')' : '),') : ',' %> -<% output_attributes.each_with_index do |attribute, attribute_index| -%> - :<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index == output_attributes.length - 1 ? '' : ','%> -<% end -%> -<% if !output_attributes.empty? -%> - <%= model_index == 1 ? ')' : '),' %> -<% end -%> -<% end -%> - ] - end - - it "renders a list of <%= table_name %>" do - render -<% for attribute in output_attributes -%> - response.should have_tag("tr>td", <%= attribute.default_value %>.to_s, 2) -<% end -%> - end -end diff --git a/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/new_erb_spec.rb b/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/new_erb_spec.rb deleted file mode 100644 index 29f08e558..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/new_erb_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%> -describe "/<%= table_name %>/new.<%= default_file_extension %>" do - include <%= controller_class_name %>Helper - - before(:each) do - assigns[:<%= file_name %>] = stub_model(<%= class_name %>, - :new_record? => true<%= output_attributes.empty? ? '' : ',' %> -<% output_attributes.each_with_index do |attribute, attribute_index| -%> - :<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index == output_attributes.length - 1 ? '' : ','%> -<% end -%> - ) - end - - it "renders new <%= file_name %> form" do - render - - response.should have_tag("form[action=?][method=post]", <%= table_name %>_path) do -<% for attribute in output_attributes -%> - with_tag("<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>[name=?]", "<%= file_name %>[<%= attribute.name %>]") -<% end -%> - end - end -end diff --git a/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/routing_spec.rb b/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/routing_spec.rb deleted file mode 100644 index ad4731aee..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'spec_helper' - -describe <%= controller_class_name %>Controller do - describe "routing" do - it "recognizes and generates #index" do - { :get => "/<%= table_name %>" }.should route_to(:controller => "<%= table_name %>", :action => "index") - end - - it "recognizes and generates #new" do - { :get => "/<%= table_name %>/new" }.should route_to(:controller => "<%= table_name %>", :action => "new") - end - - it "recognizes and generates #show" do - { :get => "/<%= table_name %>/1" }.should route_to(:controller => "<%= table_name %>", :action => "show", :id => "1") - end - - it "recognizes and generates #edit" do - { :get => "/<%= table_name %>/1/edit" }.should route_to(:controller => "<%= table_name %>", :action => "edit", :id => "1") - end - - it "recognizes and generates #create" do - { :post => "/<%= table_name %>" }.should route_to(:controller => "<%= table_name %>", :action => "create") - end - - it "recognizes and generates #update" do - { :put => "/<%= table_name %>/1" }.should route_to(:controller => "<%= table_name %>", :action => "update", :id => "1") - end - - it "recognizes and generates #destroy" do - { :delete => "/<%= table_name %>/1" }.should route_to(:controller => "<%= table_name %>", :action => "destroy", :id => "1") - end - end -end diff --git a/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/show_erb_spec.rb b/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/show_erb_spec.rb deleted file mode 100644 index f2c11db89..000000000 --- a/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/show_erb_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%> -describe "/<%= table_name %>/show.<%= default_file_extension %>" do - include <%= controller_class_name %>Helper - before(:each) do - assigns[:<%= file_name %>] = @<%= file_name %> = stub_model(<%= class_name %><%= output_attributes.empty? ? ')' : ',' %> -<% output_attributes.each_with_index do |attribute, attribute_index| -%> - :<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index == output_attributes.length - 1 ? '' : ','%> -<% end -%> -<% if !output_attributes.empty? -%> - ) -<% end -%> - end - - it "renders attributes in <p>" do - render -<% for attribute in output_attributes -%> - response.should have_text(/<%= Regexp.escape(attribute.default_value).gsub(/^"|"$/, '')%>/) -<% end -%> - end -end |