rails3-generators 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/README.rdoc +2 -2
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/lib/generators/haml/scaffold/templates/index.haml.erb +6 -6
  5. data/rails3-generators.gemspec +3 -37
  6. metadata +3 -37
  7. data/lib/generators/rspec.rb +0 -25
  8. data/lib/generators/rspec/controller/controller_generator.rb +0 -26
  9. data/lib/generators/rspec/controller/templates/controller_spec.rb +0 -23
  10. data/lib/generators/rspec/controller/templates/view_spec.rb +0 -12
  11. data/lib/generators/rspec/helper/helper_generator.rb +0 -11
  12. data/lib/generators/rspec/helper/templates/helper_spec.rb +0 -11
  13. data/lib/generators/rspec/install/install_generator.rb +0 -28
  14. data/lib/generators/rspec/install/templates/lib/tasks/rspec.rake +0 -182
  15. data/lib/generators/rspec/install/templates/script/autospec.tt +0 -6
  16. data/lib/generators/rspec/install/templates/script/spec.tt +0 -10
  17. data/lib/generators/rspec/install/templates/script/spec_server.tt +0 -9
  18. data/lib/generators/rspec/install/templates/spec/rcov.opts +0 -2
  19. data/lib/generators/rspec/install/templates/spec/spec.opts +0 -4
  20. data/lib/generators/rspec/install/templates/spec/spec_helper.rb +0 -51
  21. data/lib/generators/rspec/integration/integration_generator.rb +0 -12
  22. data/lib/generators/rspec/integration/templates/integration_spec.rb +0 -4
  23. data/lib/generators/rspec/mailer/mailer_generator.rb +0 -21
  24. data/lib/generators/rspec/mailer/templates/fixture +0 -3
  25. data/lib/generators/rspec/mailer/templates/mailer_spec.rb +0 -14
  26. data/lib/generators/rspec/model/model_generator.rb +0 -22
  27. data/lib/generators/rspec/model/templates/fixtures.yml +0 -19
  28. data/lib/generators/rspec/model/templates/model_spec.rb +0 -14
  29. data/lib/generators/rspec/observer/observer_generator.rb +0 -12
  30. data/lib/generators/rspec/observer/templates/observer_spec.rb +0 -5
  31. data/lib/generators/rspec/plugin/plugin_generator.rb +0 -11
  32. data/lib/generators/rspec/plugin/templates/%file_name%_spec.rb.tt +0 -5
  33. data/lib/generators/rspec/plugin/templates/test_helper.rb +0 -5
  34. data/lib/generators/rspec/scaffold/scaffold_generator.rb +0 -112
  35. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +0 -127
  36. data/lib/generators/rspec/scaffold/templates/edit_spec.rb +0 -25
  37. data/lib/generators/rspec/scaffold/templates/index_spec.rb +0 -27
  38. data/lib/generators/rspec/scaffold/templates/new_spec.rb +0 -25
  39. data/lib/generators/rspec/scaffold/templates/routing_spec.rb +0 -67
  40. data/lib/generators/rspec/scaffold/templates/show_spec.rb +0 -22
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = rails3-generators
2
2
 
3
- Rails 3 compatible generators for RSpec, DataMapper, Haml, Factory-girl, Authlogic and Mongomapper
3
+ Rails 3 compatible generators for DataMapper, Haml, Factory-girl, Authlogic and Mongomapper
4
4
 
5
5
  == Note on Patches/Pull Requests
6
6
 
@@ -8,7 +8,7 @@ Fork the repo, add a generator, send a pull request. Pretty simple.
8
8
 
9
9
  == Contributors
10
10
 
11
- RSpec and DataMapper generators: Jose Valim
11
+ DataMapper generators: Jose Valim
12
12
 
13
13
  Haml: Paul Berry, Anuj Dutta, Louis T
14
14
 
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ begin
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "rails3-generators"
8
8
  gem.summary = %Q{Rails 3 compatible generators}
9
- gem.description = %Q{Rails 3 compatible generators for RSpec, DataMapper, Haml, Factory-girl, Authlogic, and Mongomapper}
9
+ gem.description = %Q{Rails 3 compatible generators for DataMapper, Haml, Factory-girl, Authlogic, and Mongomapper}
10
10
  gem.email = "andre@arko.net"
11
11
  gem.homepage = "http://github.com/indirect/rails3-generators"
12
12
  gem.authors = ["Jose Valim", "Anuj Dutta", "Paul Berry", "Jeff Tucker", "Louis T.", "Jai-Gouk Kim"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.4.0
@@ -9,14 +9,14 @@
9
9
  %th
10
10
  %th
11
11
 
12
- - @<%= plural_name %>.each do |<%= singular_name %>|
13
- %tr
12
+ - @<%= plural_name %>.each do |<%= singular_name %>|
13
+ %tr
14
14
  <% for attribute in attributes -%>
15
- %td= <%= singular_name %>.<%= attribute.name %>
15
+ %td= <%= singular_name %>.<%= attribute.name %>
16
16
  <% end -%>
17
- %td= link_to 'Show', <%= singular_name %>
18
- %td= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>)
19
- %td= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete
17
+ %td= link_to 'Show', <%= singular_name %>
18
+ %td= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>)
19
+ %td= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete
20
20
 
21
21
  %br
22
22
 
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails3-generators}
8
- s.version = "0.3.3"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jose Valim", "Anuj Dutta", "Paul Berry", "Jeff Tucker", "Louis T.", "Jai-Gouk Kim"]
12
- s.date = %q{2010-01-24}
13
- s.description = %q{Rails 3 compatible generators for RSpec, DataMapper, Haml, Factory-girl, Authlogic, and Mongomapper}
12
+ s.date = %q{2010-02-05}
13
+ s.description = %q{Rails 3 compatible generators for DataMapper, Haml, Factory-girl, Authlogic, and Mongomapper}
14
14
  s.email = %q{andre@arko.net}
15
15
  s.extra_rdoc_files = [
16
16
  "README.rdoc"
@@ -48,40 +48,6 @@ Gem::Specification.new do |s|
48
48
  "lib/generators/mongomapper/model/model_generator.rb",
49
49
  "lib/generators/mongomapper/model/templates/model.rb",
50
50
  "lib/generators/mongomapper/observer/observer_generator.rb",
51
- "lib/generators/rspec.rb",
52
- "lib/generators/rspec/controller/controller_generator.rb",
53
- "lib/generators/rspec/controller/templates/controller_spec.rb",
54
- "lib/generators/rspec/controller/templates/view_spec.rb",
55
- "lib/generators/rspec/helper/helper_generator.rb",
56
- "lib/generators/rspec/helper/templates/helper_spec.rb",
57
- "lib/generators/rspec/install/install_generator.rb",
58
- "lib/generators/rspec/install/templates/lib/tasks/rspec.rake",
59
- "lib/generators/rspec/install/templates/script/autospec.tt",
60
- "lib/generators/rspec/install/templates/script/spec.tt",
61
- "lib/generators/rspec/install/templates/script/spec_server.tt",
62
- "lib/generators/rspec/install/templates/spec/rcov.opts",
63
- "lib/generators/rspec/install/templates/spec/spec.opts",
64
- "lib/generators/rspec/install/templates/spec/spec_helper.rb",
65
- "lib/generators/rspec/integration/integration_generator.rb",
66
- "lib/generators/rspec/integration/templates/integration_spec.rb",
67
- "lib/generators/rspec/mailer/mailer_generator.rb",
68
- "lib/generators/rspec/mailer/templates/fixture",
69
- "lib/generators/rspec/mailer/templates/mailer_spec.rb",
70
- "lib/generators/rspec/model/model_generator.rb",
71
- "lib/generators/rspec/model/templates/fixtures.yml",
72
- "lib/generators/rspec/model/templates/model_spec.rb",
73
- "lib/generators/rspec/observer/observer_generator.rb",
74
- "lib/generators/rspec/observer/templates/observer_spec.rb",
75
- "lib/generators/rspec/plugin/plugin_generator.rb",
76
- "lib/generators/rspec/plugin/templates/%file_name%_spec.rb.tt",
77
- "lib/generators/rspec/plugin/templates/test_helper.rb",
78
- "lib/generators/rspec/scaffold/scaffold_generator.rb",
79
- "lib/generators/rspec/scaffold/templates/controller_spec.rb",
80
- "lib/generators/rspec/scaffold/templates/edit_spec.rb",
81
- "lib/generators/rspec/scaffold/templates/index_spec.rb",
82
- "lib/generators/rspec/scaffold/templates/new_spec.rb",
83
- "lib/generators/rspec/scaffold/templates/routing_spec.rb",
84
- "lib/generators/rspec/scaffold/templates/show_spec.rb",
85
51
  "lib/rails3-generators.rb",
86
52
  "rails3-generators.gemspec"
87
53
  ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails3-generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Valim
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-01-24 00:00:00 -05:00
17
+ date: 2010-02-05 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -27,7 +27,7 @@ dependencies:
27
27
  - !ruby/object:Gem::Version
28
28
  version: 1.2.9
29
29
  version:
30
- description: Rails 3 compatible generators for RSpec, DataMapper, Haml, Factory-girl, Authlogic, and Mongomapper
30
+ description: Rails 3 compatible generators for DataMapper, Haml, Factory-girl, Authlogic, and Mongomapper
31
31
  email: andre@arko.net
32
32
  executables: []
33
33
 
@@ -68,40 +68,6 @@ files:
68
68
  - lib/generators/mongomapper/model/model_generator.rb
69
69
  - lib/generators/mongomapper/model/templates/model.rb
70
70
  - lib/generators/mongomapper/observer/observer_generator.rb
71
- - lib/generators/rspec.rb
72
- - lib/generators/rspec/controller/controller_generator.rb
73
- - lib/generators/rspec/controller/templates/controller_spec.rb
74
- - lib/generators/rspec/controller/templates/view_spec.rb
75
- - lib/generators/rspec/helper/helper_generator.rb
76
- - lib/generators/rspec/helper/templates/helper_spec.rb
77
- - lib/generators/rspec/install/install_generator.rb
78
- - lib/generators/rspec/install/templates/lib/tasks/rspec.rake
79
- - lib/generators/rspec/install/templates/script/autospec.tt
80
- - lib/generators/rspec/install/templates/script/spec.tt
81
- - lib/generators/rspec/install/templates/script/spec_server.tt
82
- - lib/generators/rspec/install/templates/spec/rcov.opts
83
- - lib/generators/rspec/install/templates/spec/spec.opts
84
- - lib/generators/rspec/install/templates/spec/spec_helper.rb
85
- - lib/generators/rspec/integration/integration_generator.rb
86
- - lib/generators/rspec/integration/templates/integration_spec.rb
87
- - lib/generators/rspec/mailer/mailer_generator.rb
88
- - lib/generators/rspec/mailer/templates/fixture
89
- - lib/generators/rspec/mailer/templates/mailer_spec.rb
90
- - lib/generators/rspec/model/model_generator.rb
91
- - lib/generators/rspec/model/templates/fixtures.yml
92
- - lib/generators/rspec/model/templates/model_spec.rb
93
- - lib/generators/rspec/observer/observer_generator.rb
94
- - lib/generators/rspec/observer/templates/observer_spec.rb
95
- - lib/generators/rspec/plugin/plugin_generator.rb
96
- - lib/generators/rspec/plugin/templates/%file_name%_spec.rb.tt
97
- - lib/generators/rspec/plugin/templates/test_helper.rb
98
- - lib/generators/rspec/scaffold/scaffold_generator.rb
99
- - lib/generators/rspec/scaffold/templates/controller_spec.rb
100
- - lib/generators/rspec/scaffold/templates/edit_spec.rb
101
- - lib/generators/rspec/scaffold/templates/index_spec.rb
102
- - lib/generators/rspec/scaffold/templates/new_spec.rb
103
- - lib/generators/rspec/scaffold/templates/routing_spec.rb
104
- - lib/generators/rspec/scaffold/templates/show_spec.rb
105
71
  - lib/rails3-generators.rb
106
72
  - rails3-generators.gemspec
107
73
  has_rdoc: true
@@ -1,25 +0,0 @@
1
- require 'rails/generators/named_base'
2
-
3
- module Rspec
4
- module Generators
5
- class Base < Rails::Generators::NamedBase #:nodoc:
6
- def self.source_root
7
- @_rspec_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'rspec', generator_name, 'templates'))
8
- end
9
- end
10
- end
11
- end
12
-
13
- module Rails
14
- module Generators
15
- class GeneratedAttribute #:nodoc:
16
- def input_type
17
- @input_type ||= if type == :text
18
- "textarea"
19
- else
20
- "input"
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,26 +0,0 @@
1
- require 'generators/rspec'
2
-
3
- module Rspec
4
- module Generators
5
- class ControllerGenerator < Base
6
- argument :actions, :type => :array, :default => [], :banner => "action action"
7
-
8
- class_option :template_engine, :desc => "Template engine to generate view files"
9
-
10
- def create_controller_files
11
- template 'controller_spec.rb',
12
- File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")
13
- end
14
-
15
- def create_view_files
16
- empty_directory File.join("spec", "views", file_path)
17
-
18
- actions.each do |action|
19
- @action = action
20
- template 'view_spec.rb',
21
- File.join("spec", "views", file_path, "#{@action}.html.#{options[:template_engine]}_spec.rb")
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,23 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
2
-
3
- describe <%= class_name %>Controller do
4
-
5
- <% if actions.empty? -%>
6
- #Delete this example and add some real ones
7
- <% else -%>
8
- #Delete these examples and add some real ones
9
- <% end -%>
10
- it "should use <%= class_name %>Controller" do
11
- controller.should be_an_instance_of(<%= class_name %>Controller)
12
- end
13
-
14
- <% for action in actions -%>
15
-
16
- describe "GET '<%= action %>'" do
17
- it "should be successful" do
18
- get '<%= action %>'
19
- response.should be_success
20
- end
21
- end
22
- <% end -%>
23
- end
@@ -1,12 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
2
-
3
- describe "/<%= file_name %>/<%= @action %>.html.<%= options[:template_engine] %>" do
4
- before(:each) do
5
- render '<%= file_name %>/<%= @action %>'
6
- end
7
-
8
- #Delete this example and add some real ones or delete this file
9
- it "should tell you where to find the file" do
10
- response.should have_tag('p', %r[Find me in app/views/<%= file_path %>/<%= @action %>])
11
- end
12
- end
@@ -1,11 +0,0 @@
1
- require 'generators/rspec'
2
-
3
- module Rspec
4
- module Generators
5
- class HelperGenerator < Base
6
- def create_helper_files
7
- template 'helper_spec.rb', File.join('spec/helpers', class_path, "#{file_name}_helper_spec.rb")
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
2
-
3
- describe <%= class_name %>Helper do
4
-
5
- #Delete this example and add some real ones or delete this file
6
- it "is included in the helper object" do
7
- included_modules = (class << helper; self; end).send :included_modules
8
- included_modules.should include(<%= class_name %>Helper)
9
- end
10
-
11
- end
@@ -1,28 +0,0 @@
1
- module Rspec
2
- module Generators
3
- class InstallGenerator < Rails::Generators::Base
4
- add_shebang_option!
5
-
6
- desc <<DESC
7
- Description:
8
- Copy rspec files to your application.
9
- DESC
10
-
11
- def self.source_root
12
- @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
13
- end
14
-
15
- def copy_lib_files
16
- directory 'lib'
17
- end
18
-
19
- def copy_script_files
20
- directory 'script'
21
- end
22
-
23
- def copy_spec_files
24
- directory 'spec'
25
- end
26
- end
27
- end
28
- end
@@ -1,182 +0,0 @@
1
- gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
2
- rspec_gem_dir = nil
3
- Dir["#{Rails.root}/vendor/gems/*"].each do |subdir|
4
- rspec_gem_dir = subdir if subdir.gsub("#{Rails.root}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb")
5
- end
6
- rspec_plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec')
7
-
8
- if rspec_gem_dir && (test ?d, rspec_plugin_dir)
9
- 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"
10
- end
11
-
12
- if rspec_gem_dir
13
- $LOAD_PATH.unshift("#{rspec_gem_dir}/lib")
14
- elsif File.exist?(rspec_plugin_dir)
15
- $LOAD_PATH.unshift("#{rspec_plugin_dir}/lib")
16
- end
17
-
18
- # Don't load rspec if running "rake gems:*"
19
- unless ARGV.any? {|a| a =~ /^gems/}
20
-
21
- begin
22
- require 'spec/rake/spectask'
23
- rescue MissingSourceFile
24
- module Spec
25
- module Rake
26
- class SpecTask
27
- def initialize(name)
28
- task name do
29
- # if rspec-rails is a configured gem, this will output helpful material and exit ...
30
- require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
31
-
32
- # ... otherwise, do this:
33
- raise <<-MSG
34
-
35
- #{"*" * 80}
36
- * You are trying to run an rspec rake task defined in
37
- * #{__FILE__},
38
- * but rspec can not be found in vendor/gems, vendor/plugins or system gems.
39
- #{"*" * 80}
40
- MSG
41
- end
42
- end
43
- end
44
- end
45
- end
46
- end
47
-
48
- Rake.application.instance_variable_get('@tasks').delete('default')
49
-
50
- spec_prereq = File.exist?(File.join(Rails.root, 'config', 'database.yml')) ? "db:test:prepare" : :noop
51
- task :noop do
52
- end
53
-
54
- task :default => :spec
55
- task :stats => "spec:statsetup"
56
-
57
- desc "Run all specs in spec directory (excluding plugin specs)"
58
- Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
59
- t.spec_opts = ['--options', "\"#{Rails.root}/spec/spec.opts\""]
60
- t.spec_files = FileList['spec/**/*_spec.rb']
61
- end
62
-
63
- namespace :spec do
64
- desc "Run all specs in spec directory with RCov (excluding plugin specs)"
65
- Spec::Rake::SpecTask.new(:rcov) do |t|
66
- t.spec_opts = ['--options', "\"#{Rails.root}/spec/spec.opts\""]
67
- t.spec_files = FileList['spec/**/*_spec.rb']
68
- t.rcov = true
69
- t.rcov_opts = lambda do
70
- IO.readlines("#{Rails.root}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
71
- end
72
- end
73
-
74
- desc "Print Specdoc for all specs (excluding plugin specs)"
75
- Spec::Rake::SpecTask.new(:doc) do |t|
76
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
77
- t.spec_files = FileList['spec/**/*_spec.rb']
78
- end
79
-
80
- desc "Print Specdoc for all plugin examples"
81
- Spec::Rake::SpecTask.new(:plugin_doc) do |t|
82
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
83
- t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*')
84
- end
85
-
86
- [:models, :controllers, :views, :helpers, :lib, :integration].each do |sub|
87
- desc "Run the code examples in spec/#{sub}"
88
- Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
89
- t.spec_opts = ['--options', "\"#{Rails.root}/spec/spec.opts\""]
90
- t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
91
- end
92
- end
93
-
94
- desc "Run the code examples in vendor/plugins (except RSpec's own)"
95
- Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
96
- t.spec_opts = ['--options', "\"#{Rails.root}/spec/spec.opts\""]
97
- t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
98
- end
99
-
100
- namespace :plugins do
101
- desc "Runs the examples for rspec_on_rails"
102
- Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
103
- t.spec_opts = ['--options', "\"#{Rails.root}/spec/spec.opts\""]
104
- t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb']
105
- end
106
- end
107
-
108
- # Setup specs for stats
109
- task :statsetup do
110
- require 'code_statistics'
111
- ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
112
- ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
113
- ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
114
- ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
115
- ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
116
- ::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing')
117
- ::STATS_DIRECTORIES << %w(Integration\ specs spec/integration) if File.exist?('spec/integration')
118
- ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
119
- ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
120
- ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
121
- ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
122
- ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
123
- ::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
124
- ::CodeStatistics::TEST_TYPES << "Integration specs" if File.exist?('spec/integration')
125
- end
126
-
127
- namespace :db do
128
- namespace :fixtures do
129
- 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."
130
- task :load => :environment do
131
- ActiveRecord::Base.establish_connection(Rails.env)
132
- base_dir = File.join(Rails.root, 'spec', 'fixtures')
133
- fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
134
-
135
- require 'active_record/fixtures'
136
- (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
137
- Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
138
- end
139
- end
140
- end
141
- end
142
-
143
- namespace :server do
144
- daemonized_server_pid = File.expand_path("#{Rails.root}/tmp/pids/spec_server.pid")
145
-
146
- desc "start spec_server."
147
- task :start do
148
- if File.exist?(daemonized_server_pid)
149
- $stderr.puts "spec_server is already running."
150
- else
151
- $stderr.puts %Q{Starting up spec_server ...}
152
- FileUtils.mkdir_p('tmp/pids') unless test ?d, 'tmp/pids'
153
- system("ruby", "script/spec_server", "--daemon", "--pid", daemonized_server_pid)
154
- end
155
- end
156
-
157
- desc "stop spec_server."
158
- task :stop do
159
- unless File.exist?(daemonized_server_pid)
160
- $stderr.puts "No server running."
161
- else
162
- $stderr.puts "Shutting down spec_server ..."
163
- system("kill", "-s", "TERM", File.read(daemonized_server_pid).strip) &&
164
- File.delete(daemonized_server_pid)
165
- end
166
- end
167
-
168
- desc "restart spec_server."
169
- task :restart => [:stop, :start]
170
-
171
- desc "check if spec server is running"
172
- task :status do
173
- if File.exist?(daemonized_server_pid)
174
- $stderr.puts %Q{spec_server is running (PID: #{File.read(daemonized_server_pid).gsub("\n","")})}
175
- else
176
- $stderr.puts "No server running."
177
- end
178
- end
179
- end
180
- end
181
-
182
- end
@@ -1,6 +0,0 @@
1
- <%= shebang %>
2
- gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
3
- ENV['RSPEC'] = 'true' # allows autotest to discover rspec
4
- ENV['AUTOTEST'] = 'true' # allows autotest to run w/ color on linux
5
- system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) ||
6
- $stderr.puts("Unable to find autotest. Please install ZenTest or fix your PATH")
@@ -1,10 +0,0 @@
1
- <%= shebang %>
2
- if ARGV.any? {|arg| %w[--drb -X --generate-options -G --help -h --version -v].include?(arg)}
3
- require 'rubygems' unless ENV['NO_RUBYGEMS']
4
- else
5
- gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
6
- ENV["RAILS_ENV"] ||= 'test'
7
- require File.expand_path(File.dirname(__FILE__) + "/../config/environment") unless defined?(Rails.root)
8
- end
9
- require 'spec/autorun'
10
- exit ::Spec::Runner::CommandLine.run
@@ -1,9 +0,0 @@
1
- <%= shebang %>
2
- gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
3
-
4
- puts "Loading Rails environment"
5
- ENV["RAILS_ENV"] ||= 'test'
6
- require File.expand_path(File.dirname(__FILE__) + "/../config/environment") unless defined?(Rails.root)
7
-
8
- require 'optparse'
9
- require 'spec/rails/spec_server'
@@ -1,2 +0,0 @@
1
- --exclude "spec/*,gems/*"
2
- --rails
@@ -1,4 +0,0 @@
1
- --colour
2
- --format progress
3
- --loadby mtime
4
- --reverse
@@ -1,51 +0,0 @@
1
- # This file is copied to ~/spec when you run 'ruby script/generate rspec'
2
- # from the project root directory.
3
- ENV["RAILS_ENV"] ||= 'test'
4
- require File.dirname(__FILE__) + "/../config/environment" unless defined?(Rails.root)
5
- require 'spec/autorun'
6
- require 'spec/rails'
7
-
8
- # Requires supporting files with custom matchers and macros, etc,
9
- # in ./support/ and its subdirectories.
10
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
-
12
- Spec::Runner.configure do |config|
13
- # If you're not using ActiveRecord you should remove these
14
- # lines, delete config/database.yml and disable :active_record
15
- # in your config/boot.rb
16
- config.use_transactional_fixtures = true
17
- config.use_instantiated_fixtures = false
18
- config.fixture_path = Rails.root + '/spec/fixtures/'
19
-
20
- # == Fixtures
21
- #
22
- # You can declare fixtures for each example_group like this:
23
- # describe "...." do
24
- # fixtures :table_a, :table_b
25
- #
26
- # Alternatively, if you prefer to declare them only once, you can
27
- # do so right here. Just uncomment the next line and replace the fixture
28
- # names with your fixtures.
29
- #
30
- # config.global_fixtures = :table_a, :table_b
31
- #
32
- # If you declare global fixtures, be aware that they will be declared
33
- # for all of your examples, even those that don't use them.
34
- #
35
- # You can also declare which fixtures to use (for example fixtures for test/fixtures):
36
- #
37
- # config.fixture_path = Rails.root + '/spec/fixtures/'
38
- #
39
- # == Mock Framework
40
- #
41
- # RSpec uses it's own mocking framework by default. If you prefer to
42
- # use mocha, flexmock or RR, uncomment the appropriate line:
43
- #
44
- # config.mock_with :mocha
45
- # config.mock_with :flexmock
46
- # config.mock_with :rr
47
- #
48
- # == Notes
49
- #
50
- # For more information take a look at Spec::Runner::Configuration and Spec::Runner
51
- end
@@ -1,12 +0,0 @@
1
- require 'generators/rspec'
2
-
3
- module Rspec
4
- module Generators
5
- class IntegrationGenerator < Base
6
- def create_integration_file
7
- template 'integration_spec.rb',
8
- File.join('spec/integration', class_path, "#{table_name}_spec.rb")
9
- end
10
- end
11
- end
12
- end
@@ -1,4 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
2
-
3
- describe "<%= class_name.pluralize %>" do
4
- end
@@ -1,21 +0,0 @@
1
- require 'generators/rspec'
2
-
3
- module Rspec
4
- module Generators
5
- class MailerGenerator < Base
6
- argument :actions, :type => :array, :default => [], :banner => "method method"
7
-
8
- def create_mailer_files
9
- template "mailer_spec.rb",
10
- File.join('spec', 'models', class_path, "#{file_name}_spec.rb")
11
- end
12
-
13
- def create_fixtures_files
14
- actions.each do |action|
15
- @action, @path = action, File.join(file_path, action)
16
- template "fixture", File.join("spec/fixtures", @path)
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,3 +0,0 @@
1
- <%= class_name %>#<%= @action %>
2
-
3
- Find me in app/views/<%= @path %>
@@ -1,14 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
2
-
3
- describe <%= class_name %> do
4
- <% for action in actions -%>
5
- it "should deliver <%= action.gsub("_", " ") %> message" do
6
- @expected.subject = '<%= class_name %>#<%= action %>'
7
- @expected.body = read_fixture('<%= action %>')
8
- @expected.date = Time.now
9
-
10
- @expected.encoded.should == <%= class_name %>.create_<%= action %>(@expected.date).encoded
11
- end
12
-
13
- <% end -%>
14
- end
@@ -1,22 +0,0 @@
1
- require 'generators/rspec'
2
-
3
- module Rspec
4
- module Generators
5
- class ModelGenerator < Base
6
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7
- class_option :fixture, :type => :boolean
8
-
9
- def create_test_file
10
- template 'model_spec.rb', File.join('spec/models', class_path, "#{file_name}_spec.rb")
11
- end
12
-
13
- hook_for :fixture_replacement
14
-
15
- def create_fixture_file
16
- if options[:fixture] && options[:fixture_replacement].nil?
17
- template 'fixtures.yml', File.join('spec/fixtures', "#{table_name}.yml")
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,19 +0,0 @@
1
- # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
-
3
- <% unless attributes.empty? -%>
4
- one:
5
- <% for attribute in attributes -%>
6
- <%= attribute.name %>: <%= attribute.default %>
7
- <% end -%>
8
-
9
- two:
10
- <% for attribute in attributes -%>
11
- <%= attribute.name %>: <%= attribute.default %>
12
- <% end -%>
13
- <% else -%>
14
- # one:
15
- # column: value
16
- #
17
- # two:
18
- # column: value
19
- <% end -%>
@@ -1,14 +0,0 @@
1
- vrequire File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
2
-
3
- describe <%= class_name %> do
4
- before(:each) do
5
- @valid_attributes = {
6
- <%= attributes.map{ |a| ":#{a.name} => #{a.default.inspect}" }.join(",\n ") %>
7
- }
8
- end
9
-
10
- it "should create a new instance given valid attributes" do
11
- <%= class_name %>.create!(@valid_attributes)
12
- end
13
- end
14
-
@@ -1,12 +0,0 @@
1
- require 'generators/rspec'
2
-
3
- module Rspec
4
- module Generators
5
- class ObserverGenerator < Base
6
- def create_observer_files
7
- template 'observer_spec.rb',
8
- File.join('spec', 'models', class_path, "#{file_name}_observer_spec.rb")
9
- end
10
- end
11
- end
12
- end
@@ -1,5 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
2
-
3
- describe <%= class_name %> do
4
-
5
- end
@@ -1,11 +0,0 @@
1
- require 'generators/rspec'
2
-
3
- module Rspec
4
- module Generators
5
- class PluginGenerator < Base
6
- def create_spec_files
7
- directory '.', 'spec'
8
- end
9
- end
10
- end
11
- end
@@ -1,5 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper.rb'))
2
-
3
- describe <%= class_name %> do
4
-
5
- end
@@ -1,5 +0,0 @@
1
- $TESTING=true
2
- $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
3
-
4
- Spec::Runner.configure do |config|
5
- end
@@ -1,112 +0,0 @@
1
- require 'generators/rspec'
2
- require 'rails/generators/resource_helpers'
3
-
4
- module Rspec
5
- module Generators
6
- class ScaffoldGenerator < Base
7
- include Rails::Generators::ResourceHelpers
8
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
9
-
10
- class_option :orm, :desc => "ORM used to generate the controller"
11
- class_option :template_engine, :desc => "Template engine to generate view files"
12
- class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller"
13
-
14
- class_option :views, :type => :boolean, :default => true
15
- class_option :routes, :type => :boolean, :default => true
16
-
17
- def copy_controller_files
18
- template 'controller_spec.rb',
19
- File.join('spec/controllers', controller_class_path, "#{controller_file_name}_controller_spec.rb")
20
- end
21
-
22
- def copy_view_files
23
- return unless options[:views]
24
-
25
- copy_view :edit
26
- copy_view :index unless options[:singleton]
27
- copy_view :new
28
- copy_view :show
29
- end
30
-
31
- def copy_routing_files
32
- return unless options[:routes]
33
-
34
- template 'routing_spec.rb',
35
- File.join('spec/routing', controller_class_path, "#{controller_file_name}_routing_spec.rb")
36
- end
37
-
38
- hook_for :integration_tool, :as => :integration
39
-
40
- protected
41
-
42
- def copy_view(view)
43
- template "#{view}_spec.rb",
44
- File.join("spec/views", controller_file_path, "#{view}.html.#{options[:template_engine]}_spec.rb")
45
- end
46
-
47
- def params
48
- "{'these' => 'params'}"
49
- end
50
-
51
- # Returns the name of the mock. For example, if the file name is user,
52
- # it returns mock_user.
53
- #
54
- # If a hash is given, it uses the hash key as the ORM method and the
55
- # value as response. So, for ActiveRecord and file name "User":
56
- #
57
- # mock_file_name(:save => true)
58
- # #=> mock_user(:save => true)
59
- #
60
- # If another ORM is being used and another method instead of save is
61
- # called, it will be the one used.
62
- #
63
- def mock_file_name(hash=nil)
64
- if hash
65
- method, and_return = hash.to_a.first
66
- method = orm_instance.send(method).split('.').last.gsub(/\(.*?\)/, '')
67
- "mock_#{file_name}(:#{method} => #{and_return})"
68
- else
69
- "mock_#{file_name}"
70
- end
71
- end
72
-
73
- # Receives the ORM chain and convert to expects. For ActiveRecord:
74
- #
75
- # should! orm_class.find(User, "37")
76
- # #=> User.should_receive(:find).with(37)
77
- #
78
- # For Datamapper:
79
- #
80
- # should! orm_class.find(User, "37")
81
- # #=> User.should_receive(:get).with(37)
82
- #
83
- def should!(chain)
84
- stub_or_should_chain(:should_receive, chain)
85
- end
86
-
87
- # Receives the ORM chain and convert to stub. For ActiveRecord:
88
- #
89
- # stub! orm_class.find(User, "37")
90
- # #=> User.stub!(:find).with(37)
91
- #
92
- # For Datamapper:
93
- #
94
- # stub! orm_class.find(User, "37")
95
- # #=> User.stub!(:get).with(37)
96
- #
97
- def stub!(chain)
98
- stub_or_should_chain(:stub!, chain)
99
- end
100
-
101
- def stub_or_should_chain(mode, chain)
102
- receiver, method = chain.split(".")
103
- method.gsub!(/\((.*?)\)/, '')
104
-
105
- response = "#{receiver}.#{mode}(:#{method})"
106
- response << ".with(#{$1})" unless $1.blank?
107
- response
108
- end
109
-
110
- end
111
- end
112
- end
@@ -1,127 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
2
-
3
- describe <%= controller_class_name %>Controller do
4
-
5
- def <%= mock_file_name %>(stubs={})
6
- @<%= mock_file_name %> ||= mock_model(<%= class_name %>, stubs)
7
- end
8
-
9
- <% unless options[:singleton] -%>
10
- describe "GET index" do
11
- it "assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do
12
- <%= stub! orm_class.all(class_name) %>.and_return([<%= mock_file_name %>])
13
- get :index
14
- assigns[:<%= table_name %>].should == [<%= mock_file_name %>]
15
- end
16
- end
17
- <% end -%>
18
-
19
- describe "GET show" do
20
- it "assigns the requested <%= file_name %> as @<%= file_name %>" do
21
- <%= stub! orm_class.find(class_name, "37".inspect) %>.and_return(<%= mock_file_name %>)
22
- get :show, :id => "37"
23
- assigns[:<%= file_name %>].should equal(<%= mock_file_name %>)
24
- end
25
- end
26
-
27
- describe "GET new" do
28
- it "assigns a new <%= file_name %> as @<%= file_name %>" do
29
- <%= stub! orm_class.build(class_name) %>.and_return(<%= mock_file_name %>)
30
- get :new
31
- assigns[:<%= file_name %>].should equal(<%= mock_file_name %>)
32
- end
33
- end
34
-
35
- describe "GET edit" do
36
- it "assigns the requested <%= file_name %> as @<%= file_name %>" do
37
- <%= stub! orm_class.find(class_name, "37".inspect) %>.and_return(<%= mock_file_name %>)
38
- get :edit, :id => "37"
39
- assigns[:<%= file_name %>].should equal(<%= mock_file_name %>)
40
- end
41
- end
42
-
43
- describe "POST create" do
44
-
45
- describe "with valid params" do
46
- it "assigns a newly created <%= file_name %> as @<%= file_name %>" do
47
- <%= stub! orm_class.build(class_name, params) %>.and_return(<%= mock_file_name(:save => true) %>)
48
- post :create, :<%= file_name %> => <%= params %>
49
- assigns[:<%= file_name %>].should equal(<%= mock_file_name %>)
50
- end
51
-
52
- it "redirects to the created <%= file_name %>" do
53
- <%= stub! orm_class.build(class_name) %>.and_return(<%= mock_file_name(:save => true) %>)
54
- post :create, :<%= file_name %> => {}
55
- response.should redirect_to(<%= table_name.singularize %>_url(<%= mock_file_name %>))
56
- end
57
- end
58
-
59
- describe "with invalid params" do
60
- it "assigns a newly created but unsaved <%= file_name %> as @<%= file_name %>" do
61
- <%= stub! orm_class.build(class_name, params) %>.and_return(<%= mock_file_name(:save => false) %>)
62
- post :create, :<%= file_name %> => <%= params %>
63
- assigns[:<%= file_name %>].should equal(<%= mock_file_name %>)
64
- end
65
-
66
- it "re-renders the 'new' template" do
67
- <%= stub! orm_class.build(class_name) %>.and_return(<%= mock_file_name(:save => false) %>)
68
- post :create, :<%= file_name %> => {}
69
- response.should render_template('new')
70
- end
71
- end
72
-
73
- end
74
-
75
- describe "PUT update" do
76
-
77
- describe "with valid params" do
78
- it "updates the requested <%= file_name %>" do
79
- <%= should! orm_class.find(class_name, "37".inspect) %>.and_return(<%= mock_file_name %>)
80
- mock_<%= should! orm_instance.update_attributes(params) %>
81
- put :update, :id => "37", :<%= file_name %> => <%= params %>
82
- end
83
-
84
- it "assigns the requested <%= file_name %> as @<%= file_name %>" do
85
- <%= stub! orm_class.find(class_name) %>.and_return(<%= mock_file_name(:update_attributes => true) %>)
86
- put :update, :id => "1"
87
- assigns[:<%= file_name %>].should equal(<%= mock_file_name %>)
88
- end
89
-
90
- it "redirects to the <%= file_name %>" do
91
- <%= stub! orm_class.find(class_name) %>.and_return(<%= mock_file_name(:update_attributes => true) %>)
92
- put :update, :id => "1"
93
- response.should redirect_to(<%= table_name.singularize %>_url(<%= mock_file_name %>))
94
- end
95
- end
96
-
97
- describe "with invalid params" do
98
- it "assigns the <%= file_name %> as @<%= file_name %>" do
99
- <%= stub! orm_class.find(class_name) %>.and_return(<%= mock_file_name(:update_attributes => false) %>)
100
- put :update, :id => "1"
101
- assigns[:<%= file_name %>].should equal(<%= mock_file_name %>)
102
- end
103
-
104
- it "re-renders the 'edit' template" do
105
- <%= stub! orm_class.find(class_name) %>.and_return(<%= mock_file_name(:update_attributes => false) %>)
106
- put :update, :id => "1"
107
- response.should render_template('edit')
108
- end
109
- end
110
-
111
- end
112
-
113
- describe "DELETE destroy" do
114
- it "destroys the requested <%= file_name %>" do
115
- <%= should! orm_class.find(class_name, "37".inspect) %>.and_return(<%= mock_file_name %>)
116
- mock_<%= should! orm_instance.destroy %>
117
- delete :destroy, :id => "37"
118
- end
119
-
120
- it "redirects to the <%= table_name %> list" do
121
- <%= stub! orm_class.find(class_name) %>.and_return(<%= mock_file_name(:destroy => true) %>)
122
- delete :destroy, :id => "1"
123
- response.should redirect_to(<%= table_name %>_url)
124
- end
125
- end
126
-
127
- end
@@ -1,25 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
2
-
3
- <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- describe "/<%= table_name %>/edit.html.<%= options[:template_engine] %>" do
5
- include <%= controller_class_name %>Helper
6
-
7
- before(:each) do
8
- assigns[:<%= file_name %>] = @<%= file_name %> = stub_model(<%= class_name %>,
9
- :new_record? => false<%= output_attributes.empty? ? '' : ',' %>
10
- <% output_attributes.each_with_index do |attribute, attribute_index| -%>
11
- :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
12
- <% end -%>
13
- )
14
- end
15
-
16
- it "renders the edit <%= file_name %> form" do
17
- render
18
-
19
- response.should have_tag("form[action=#{<%= file_name %>_path(@<%= file_name %>)}][method=post]") do
20
- <% for attribute in output_attributes -%>
21
- with_tag('<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>[name=?]', "<%= file_name %>[<%= attribute.name %>]")
22
- <% end -%>
23
- end
24
- end
25
- end
@@ -1,27 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
2
-
3
- <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- describe "/<%= table_name %>/index.html.<%= options[:template_engine] %>" do
5
- include <%= controller_class_name %>Helper
6
-
7
- before(:each) do
8
- assigns[:<%= table_name %>] = [
9
- <% [1,2].each_with_index do |id, model_index| -%>
10
- stub_model(<%= class_name %><%= output_attributes.empty? ? (model_index == 1 ? ')' : '),') : ',' %>
11
- <% output_attributes.each_with_index do |attribute, attribute_index| -%>
12
- :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
13
- <% end -%>
14
- <% if !output_attributes.empty? -%>
15
- <%= model_index == 1 ? ')' : '),' %>
16
- <% end -%>
17
- <% end -%>
18
- ]
19
- end
20
-
21
- it "renders a list of <%= table_name %>" do
22
- render
23
- <% for attribute in output_attributes -%>
24
- response.should have_tag("tr>td", <%= attribute.default.inspect %>.to_s, 2)
25
- <% end -%>
26
- end
27
- end
@@ -1,25 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
2
-
3
- <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- describe "/<%= table_name %>/new.html.<%= options[:template_engine] %>" do
5
- include <%= controller_class_name %>Helper
6
-
7
- before(:each) do
8
- assigns[:<%= file_name %>] = stub_model(<%= class_name %>,
9
- :new_record? => true<%= output_attributes.empty? ? '' : ',' %>
10
- <% output_attributes.each_with_index do |attribute, attribute_index| -%>
11
- :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
12
- <% end -%>
13
- )
14
- end
15
-
16
- it "renders new <%= file_name %> form" do
17
- render
18
-
19
- response.should have_tag("form[action=?][method=post]", <%= table_name %>_path) do
20
- <% for attribute in output_attributes -%>
21
- with_tag("<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>[name=?]", "<%= file_name %>[<%= attribute.name %>]")
22
- <% end -%>
23
- end
24
- end
25
- end
@@ -1,67 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
2
-
3
- describe <%= controller_class_name %>Controller do
4
- describe "route generation" do
5
- <% unless options[:singleton] -%>
6
- it "maps #index" do
7
- route_for(:controller => "<%= table_name %>", :action => "index").should == "/<%= table_name %>"
8
- end
9
- <% end -%>
10
-
11
- it "maps #new" do
12
- route_for(:controller => "<%= table_name %>", :action => "new").should == "/<%= table_name %>/new"
13
- end
14
-
15
- it "maps #show" do
16
- route_for(:controller => "<%= table_name %>", :action => "show", :id => "1").should == "/<%= table_name %>/1"
17
- end
18
-
19
- it "maps #edit" do
20
- route_for(:controller => "<%= table_name %>", :action => "edit", :id => "1").should == "/<%= table_name %>/1/edit"
21
- end
22
-
23
- it "maps #create" do
24
- route_for(:controller => "<%= table_name %>", :action => "create").should == {:path => "/<%= table_name %>", :method => :post}
25
- end
26
-
27
- it "maps #update" do
28
- route_for(:controller => "<%= table_name %>", :action => "update", :id => "1").should == {:path =>"/<%= table_name %>/1", :method => :put}
29
- end
30
-
31
- it "maps #destroy" do
32
- route_for(:controller => "<%= table_name %>", :action => "destroy", :id => "1").should == {:path =>"/<%= table_name %>/1", :method => :delete}
33
- end
34
- end
35
-
36
- describe "route recognition" do
37
- <% unless options[:singleton] -%>
38
- it "generates params for #index" do
39
- params_from(:get, "/<%= table_name %>").should == {:controller => "<%= table_name %>", :action => "index"}
40
- end
41
- <% end -%>
42
-
43
- it "generates params for #new" do
44
- params_from(:get, "/<%= table_name %>/new").should == {:controller => "<%= table_name %>", :action => "new"}
45
- end
46
-
47
- it "generates params for #create" do
48
- params_from(:post, "/<%= table_name %>").should == {:controller => "<%= table_name %>", :action => "create"}
49
- end
50
-
51
- it "generates params for #show" do
52
- params_from(:get, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "show", :id => "1"}
53
- end
54
-
55
- it "generates params for #edit" do
56
- params_from(:get, "/<%= table_name %>/1/edit").should == {:controller => "<%= table_name %>", :action => "edit", :id => "1"}
57
- end
58
-
59
- it "generates params for #update" do
60
- params_from(:put, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "update", :id => "1"}
61
- end
62
-
63
- it "generates params for #destroy" do
64
- params_from(:delete, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "destroy", :id => "1"}
65
- end
66
- end
67
- end
@@ -1,22 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
2
-
3
- <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- describe "/<%= table_name %>/show.html.<%= options[:template_engine] %>" do
5
- include <%= controller_class_name %>Helper
6
- before(:each) do
7
- assigns[:<%= file_name %>] = @<%= file_name %> = stub_model(<%= class_name %><%= output_attributes.empty? ? ')' : ',' %>
8
- <% output_attributes.each_with_index do |attribute, attribute_index| -%>
9
- :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
10
- <% end -%>
11
- <% if !output_attributes.empty? -%>
12
- )
13
- <% end -%>
14
- end
15
-
16
- it "renders attributes in <p>" do
17
- render
18
- <% for attribute in output_attributes -%>
19
- response.should have_text(/<%= Regexp.escape(attribute.default.inspect).gsub(/^"|"$/, '')%>/)
20
- <% end -%>
21
- end
22
- end