rspec_rails3_gen 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README +14 -0
- data/README.rdoc +13 -0
- data/bin/rspec_controller +19 -0
- data/bin/rspec_integration_spec +21 -0
- data/bin/rspec_model +19 -0
- data/bin/rspec_scaffold +21 -0
- data/bin/rspec_skeleton +19 -0
- data/lib/generators/rspec/controller/USAGE +33 -0
- data/lib/generators/rspec/controller/controller_generator.rb +125 -0
- data/lib/generators/rspec/controller/templates/actions/create.rb +4 -0
- data/lib/generators/rspec/controller/templates/actions/destroy.rb +4 -0
- data/lib/generators/rspec/controller/templates/actions/edit.rb +3 -0
- data/lib/generators/rspec/controller/templates/actions/index.rb +3 -0
- data/lib/generators/rspec/controller/templates/actions/new.rb +3 -0
- data/lib/generators/rspec/controller/templates/actions/show.rb +3 -0
- data/lib/generators/rspec/controller/templates/actions/update.rb +5 -0
- data/lib/generators/rspec/controller/templates/controller.rb +4 -0
- data/lib/generators/rspec/controller/templates/controller_spec.rb +25 -0
- data/lib/generators/rspec/controller/templates/helper.rb +2 -0
- data/lib/generators/rspec/controller/templates/helper_spec.erb +11 -0
- data/lib/generators/rspec/controller/templates/view_spec.rb +12 -0
- data/lib/generators/rspec/controller/templates/views/erb/_form.html.erb +4 -0
- data/lib/generators/rspec/controller/templates/views/erb/edit.html.erb +14 -0
- data/lib/generators/rspec/controller/templates/views/erb/index.html.erb +10 -0
- data/lib/generators/rspec/controller/templates/views/erb/new.html.erb +7 -0
- data/lib/generators/rspec/controller/templates/views/erb/show.html.erb +13 -0
- data/lib/generators/rspec/controller/templates/views/haml/_form.html.haml +4 -0
- data/lib/generators/rspec/controller/templates/views/haml/edit.html.haml +14 -0
- data/lib/generators/rspec/controller/templates/views/haml/index.html.haml +8 -0
- data/lib/generators/rspec/controller/templates/views/haml/new.html.haml +7 -0
- data/lib/generators/rspec/controller/templates/views/haml/show.html.haml +14 -0
- data/lib/generators/rspec/default_values.rb +28 -0
- data/lib/generators/rspec/integration_spec/USAGE +19 -0
- data/lib/generators/rspec/integration_spec/integration_spec_generator.rb +13 -0
- data/lib/generators/rspec/integration_spec/templates/integration_spec.rb +4 -0
- data/lib/generators/rspec/model/USAGE +18 -0
- data/lib/generators/rspec/model/model_generator.rb +53 -0
- data/lib/generators/rspec/model/templates/model.rb +1 -0
- data/lib/generators/rspec/model/templates/model_spec.rb +13 -0
- data/lib/generators/rspec/scaffold/USAGE +1 -0
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +198 -0
- data/lib/generators/rspec/scaffold/templates/actions/create.rb +4 -0
- data/lib/generators/rspec/scaffold/templates/actions/destroy.rb +4 -0
- data/lib/generators/rspec/scaffold/templates/actions/edit.rb +3 -0
- data/lib/generators/rspec/scaffold/templates/actions/index.rb +3 -0
- data/lib/generators/rspec/scaffold/templates/actions/new.rb +3 -0
- data/lib/generators/rspec/scaffold/templates/actions/show.rb +3 -0
- data/lib/generators/rspec/scaffold/templates/actions/update.rb +5 -0
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +131 -0
- data/lib/generators/rspec/scaffold/templates/edit_erb_spec.rb +25 -0
- data/lib/generators/rspec/scaffold/templates/helper_spec.erb +11 -0
- data/lib/generators/rspec/scaffold/templates/index_erb_spec.rb +27 -0
- data/lib/generators/rspec/scaffold/templates/new_erb_spec.rb +25 -0
- data/lib/generators/rspec/scaffold/templates/routing_spec.rb +33 -0
- data/lib/generators/rspec/scaffold/templates/show_erb_spec.rb +22 -0
- data/lib/generators/rspec/scaffold/templates/views/erb/_form.html.erb +10 -0
- data/lib/generators/rspec/scaffold/templates/views/erb/edit.html.erb +14 -0
- data/lib/generators/rspec/scaffold/templates/views/erb/index.html.erb +29 -0
- data/lib/generators/rspec/scaffold/templates/views/erb/new.html.erb +7 -0
- data/lib/generators/rspec/scaffold/templates/views/erb/show.html.erb +20 -0
- data/lib/generators/rspec/scaffold/templates/views/haml/_form.html.haml +10 -0
- data/lib/generators/rspec/scaffold/templates/views/haml/edit.html.haml +14 -0
- data/lib/generators/rspec/scaffold/templates/views/haml/index.html.haml +25 -0
- data/lib/generators/rspec/scaffold/templates/views/haml/new.html.haml +7 -0
- data/lib/generators/rspec/scaffold/templates/views/haml/show.html.haml +20 -0
- data/lib/generators/rspec/skeleton/USAGE +19 -0
- data/lib/generators/rspec/skeleton/skeleton_generator.rb +29 -0
- data/lib/generators/rspec/skeleton/templates/previous_failures.txt +0 -0
- data/lib/generators/rspec/skeleton/templates/rcov.opts +2 -0
- data/lib/generators/rspec/skeleton/templates/rspec.rake +144 -0
- data/lib/generators/rspec/skeleton/templates/script/autospec +6 -0
- data/lib/generators/rspec/skeleton/templates/script/spec +10 -0
- data/lib/generators/rspec/skeleton/templates/spec.opts +4 -0
- data/lib/generators/rspec/skeleton/templates/spec_helper.rb +54 -0
- data/lib/generators/rspec_rails3_gen_base.rb +27 -0
- data/spec/rspec_rails3_spec.rb +7 -0
- data/spec/spec_helper.rb +9 -0
- metadata +146 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
<%% title "<%= singular_name.titleize %>" %>
|
2
|
+
|
3
|
+
<%- for attribute in model_attributes -%>
|
4
|
+
<p>
|
5
|
+
<strong><%= attribute.human_name.titleize %>:</strong>
|
6
|
+
<%%=h @<%= singular_name %>.<%= attribute.name %> %>
|
7
|
+
</p>
|
8
|
+
<%- end -%>
|
9
|
+
|
10
|
+
<p>
|
11
|
+
<%- if action? :edit -%>
|
12
|
+
<%%= link_to "Edit", edit_<%= singular_name %>_path(@<%= singular_name %>) %> |
|
13
|
+
<%- end -%>
|
14
|
+
<%- if action? :destroy -%>
|
15
|
+
<%%= link_to "Destroy", @<%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %> |
|
16
|
+
<%- end -%>
|
17
|
+
<%- if action? :index -%>
|
18
|
+
<%%= link_to "View All", <%= plural_name %>_path %>
|
19
|
+
<%- end -%>
|
20
|
+
</p>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
- title "Edit <%= singular_name.titleize %>"
|
2
|
+
|
3
|
+
<%= render_form %>
|
4
|
+
|
5
|
+
<%- if actions? :show, :index -%>
|
6
|
+
%p
|
7
|
+
<%- if action? :show -%>
|
8
|
+
= link_to "Show", <%= singular_name %>_path(@<%= singular_name %>)
|
9
|
+
|
|
10
|
+
<%- end -%>
|
11
|
+
<%- if action? :index -%>
|
12
|
+
= link_to "View All", <%= plural_name %>_path
|
13
|
+
<%- end -%>
|
14
|
+
<%- end -%>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
- title "<%= plural_name.titleize %>"
|
2
|
+
|
3
|
+
%table
|
4
|
+
%tr
|
5
|
+
<%- for attribute in model_attributes -%>
|
6
|
+
%th <%= attribute.human_name %>
|
7
|
+
<%- end -%>
|
8
|
+
- for <%= singular_name %> in @<%= plural_name %>
|
9
|
+
%tr
|
10
|
+
<%- for attribute in model_attributes -%>
|
11
|
+
%td= h <%= singular_name %>.<%= attribute.name %>
|
12
|
+
<%- end -%>
|
13
|
+
<%- if action? :show -%>
|
14
|
+
%td= link_to 'Show', <%= singular_name %>
|
15
|
+
<%- end -%>
|
16
|
+
<%- if action? :edit -%>
|
17
|
+
%td= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>)
|
18
|
+
<%- end -%>
|
19
|
+
<%- if action? :destroy -%>
|
20
|
+
%td= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete
|
21
|
+
<%- end -%>
|
22
|
+
|
23
|
+
<%- if actions? :new -%>
|
24
|
+
%p= link_to "New <%= singular_name.titleize %>", new_<%= singular_name %>_path
|
25
|
+
<%- end -%>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
- title "<%= singular_name.titleize %>"
|
2
|
+
|
3
|
+
<%- for attribute in model_attributes -%>
|
4
|
+
%p
|
5
|
+
%strong <%= attribute.human_name.titleize %>:
|
6
|
+
=h @<%= singular_name %>.<%= attribute.name %>
|
7
|
+
<%- end -%>
|
8
|
+
|
9
|
+
%p
|
10
|
+
<%- if action? :edit -%>
|
11
|
+
= link_to "Edit", edit_<%= singular_name %>_path(@<%= singular_name %>)
|
12
|
+
|
|
13
|
+
<%- end -%>
|
14
|
+
<%- if action? :destroy -%>
|
15
|
+
= link_to "Destroy", @<%= singular_name %>, :confirm => 'Are you sure?', :method => :delete
|
16
|
+
|
|
17
|
+
<%- end -%>
|
18
|
+
<%- if action? :index -%>
|
19
|
+
= link_to "View All", <%= plural_name %>_path
|
20
|
+
<%- end -%>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Description:
|
2
|
+
The rspec:skeleton generator creates a standard skeleton directory/file structure for using Rspec in a Rails 3 app.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
./script/generate rspec:skeleton
|
6
|
+
|
7
|
+
This will create the following directory structure inside the root of the Rails 3 app:
|
8
|
+
/lib/tasks
|
9
|
+
rspec.rake
|
10
|
+
|
11
|
+
/scripts
|
12
|
+
autospec
|
13
|
+
spec
|
14
|
+
|
15
|
+
/spec
|
16
|
+
rcov.opts
|
17
|
+
spec.opts
|
18
|
+
spec_helper.rb
|
19
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Author: Kristian Mandrup
|
2
|
+
# email: kmandrup@gmail.com
|
3
|
+
|
4
|
+
require 'generators/rspec_rails3_gen_base'
|
5
|
+
|
6
|
+
module RSpec
|
7
|
+
module Generators
|
8
|
+
class SkeletonGenerator < Base
|
9
|
+
|
10
|
+
def create_files
|
11
|
+
empty_directory "lib/tasks"
|
12
|
+
# add rspec rake task
|
13
|
+
copy_file 'rspec.rake', 'lib/tasks/rspec.rake'
|
14
|
+
|
15
|
+
# add scripts
|
16
|
+
copy_file 'script/autospec', 'script/autospec'
|
17
|
+
chmod 'script/autospec', 0755, :verbose => false
|
18
|
+
|
19
|
+
copy_file 'script/spec', 'script/spec'
|
20
|
+
chmod 'script/spec', 0755, :verbose => false
|
21
|
+
|
22
|
+
empty_directory 'spec'
|
23
|
+
copy_file 'rcov.opts', 'spec/rcov.opts'
|
24
|
+
copy_file 'spec.opts', 'spec/spec.opts'
|
25
|
+
template 'spec_helper.rb', 'spec_helper.rb'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
File without changes
|
@@ -0,0 +1,144 @@
|
|
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.join(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
|
+
end
|
143
|
+
|
144
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
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")
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
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
|
@@ -0,0 +1,54 @@
|
|
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.expand_path(File.join(File.dirname(__FILE__),'..','config','environment'))
|
5
|
+
require 'spec/autorun'
|
6
|
+
require 'spec/rails'
|
7
|
+
|
8
|
+
# Uncomment the next line to use webrat's matchers
|
9
|
+
#require 'webrat/integrations/rspec-rails'
|
10
|
+
|
11
|
+
# Requires supporting files with custom matchers and macros, etc,
|
12
|
+
# in ./support/ and its subdirectories.
|
13
|
+
Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
|
14
|
+
|
15
|
+
Spec::Runner.configure do |config|
|
16
|
+
# If you're not using ActiveRecord you should remove these
|
17
|
+
# lines, delete config/database.yml and disable :active_record
|
18
|
+
# in your config/boot.rb
|
19
|
+
config.use_transactional_fixtures = true
|
20
|
+
config.use_instantiated_fixtures = false
|
21
|
+
config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
22
|
+
|
23
|
+
# == Fixtures
|
24
|
+
#
|
25
|
+
# You can declare fixtures for each example_group like this:
|
26
|
+
# describe "...." do
|
27
|
+
# fixtures :table_a, :table_b
|
28
|
+
#
|
29
|
+
# Alternatively, if you prefer to declare them only once, you can
|
30
|
+
# do so right here. Just uncomment the next line and replace the fixture
|
31
|
+
# names with your fixtures.
|
32
|
+
#
|
33
|
+
# config.global_fixtures = :table_a, :table_b
|
34
|
+
#
|
35
|
+
# If you declare global fixtures, be aware that they will be declared
|
36
|
+
# for all of your examples, even those that don't use them.
|
37
|
+
#
|
38
|
+
# You can also declare which fixtures to use (for example fixtures for test/fixtures):
|
39
|
+
#
|
40
|
+
# config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
41
|
+
#
|
42
|
+
# == Mock Framework
|
43
|
+
#
|
44
|
+
# RSpec uses its own mocking framework by default. If you prefer to
|
45
|
+
# use mocha, flexmock or RR, uncomment the appropriate line:
|
46
|
+
#
|
47
|
+
# config.mock_with :mocha
|
48
|
+
# config.mock_with :flexmock
|
49
|
+
# config.mock_with :rr
|
50
|
+
#
|
51
|
+
# == Notes
|
52
|
+
#
|
53
|
+
# For more information take a look at Spec::Runner::Configuration and Spec::Runner
|
54
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
require 'rails/generators/named_base'
|
3
|
+
|
4
|
+
module RSpec
|
5
|
+
module Generators
|
6
|
+
class Base < Rails::Generators::Base #:nodoc:
|
7
|
+
def self.source_root
|
8
|
+
@_rspec_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'rspec', generator_name, 'templates'))
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.banner
|
12
|
+
"#{$0} rspec:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class NamedBase < Rails::Generators::NamedBase #:nodoc:
|
17
|
+
def self.source_root
|
18
|
+
@_rspec_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'rspec', generator_name, 'templates'))
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.banner
|
22
|
+
"#{$0} rspec:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec_rails3_gen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kristian Mandrup
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-05 00:00:00 +01:00
|
13
|
+
default_executable: rspec_skeleton
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.9
|
24
|
+
version:
|
25
|
+
description: Rspec Rails 3 generators ported from similar Rails 2 generators
|
26
|
+
email: kmandrup@gmail.com
|
27
|
+
executables:
|
28
|
+
- rspec_integration_spec
|
29
|
+
- rspec_skeleton
|
30
|
+
- rspec_controller
|
31
|
+
- rspec_model
|
32
|
+
- rspec_scaffold
|
33
|
+
extensions: []
|
34
|
+
|
35
|
+
extra_rdoc_files:
|
36
|
+
- LICENSE
|
37
|
+
- README
|
38
|
+
- README.rdoc
|
39
|
+
files:
|
40
|
+
- bin/rspec_controller
|
41
|
+
- bin/rspec_integration_spec
|
42
|
+
- bin/rspec_model
|
43
|
+
- bin/rspec_scaffold
|
44
|
+
- bin/rspec_skeleton
|
45
|
+
- lib/generators/rspec/controller/USAGE
|
46
|
+
- lib/generators/rspec/controller/controller_generator.rb
|
47
|
+
- lib/generators/rspec/controller/templates/actions/create.rb
|
48
|
+
- lib/generators/rspec/controller/templates/actions/destroy.rb
|
49
|
+
- lib/generators/rspec/controller/templates/actions/edit.rb
|
50
|
+
- lib/generators/rspec/controller/templates/actions/index.rb
|
51
|
+
- lib/generators/rspec/controller/templates/actions/new.rb
|
52
|
+
- lib/generators/rspec/controller/templates/actions/show.rb
|
53
|
+
- lib/generators/rspec/controller/templates/actions/update.rb
|
54
|
+
- lib/generators/rspec/controller/templates/controller.rb
|
55
|
+
- lib/generators/rspec/controller/templates/controller_spec.rb
|
56
|
+
- lib/generators/rspec/controller/templates/helper.rb
|
57
|
+
- lib/generators/rspec/controller/templates/helper_spec.erb
|
58
|
+
- lib/generators/rspec/controller/templates/view_spec.rb
|
59
|
+
- lib/generators/rspec/controller/templates/views/erb/_form.html.erb
|
60
|
+
- lib/generators/rspec/controller/templates/views/erb/edit.html.erb
|
61
|
+
- lib/generators/rspec/controller/templates/views/erb/index.html.erb
|
62
|
+
- lib/generators/rspec/controller/templates/views/erb/new.html.erb
|
63
|
+
- lib/generators/rspec/controller/templates/views/erb/show.html.erb
|
64
|
+
- lib/generators/rspec/controller/templates/views/haml/_form.html.haml
|
65
|
+
- lib/generators/rspec/controller/templates/views/haml/edit.html.haml
|
66
|
+
- lib/generators/rspec/controller/templates/views/haml/index.html.haml
|
67
|
+
- lib/generators/rspec/controller/templates/views/haml/new.html.haml
|
68
|
+
- lib/generators/rspec/controller/templates/views/haml/show.html.haml
|
69
|
+
- lib/generators/rspec/default_values.rb
|
70
|
+
- lib/generators/rspec/integration_spec/USAGE
|
71
|
+
- lib/generators/rspec/integration_spec/integration_spec_generator.rb
|
72
|
+
- lib/generators/rspec/integration_spec/templates/integration_spec.rb
|
73
|
+
- lib/generators/rspec/model/USAGE
|
74
|
+
- lib/generators/rspec/model/model_generator.rb
|
75
|
+
- lib/generators/rspec/model/templates/model.rb
|
76
|
+
- lib/generators/rspec/model/templates/model_spec.rb
|
77
|
+
- lib/generators/rspec/scaffold/USAGE
|
78
|
+
- lib/generators/rspec/scaffold/scaffold_generator.rb
|
79
|
+
- lib/generators/rspec/scaffold/templates/actions/create.rb
|
80
|
+
- lib/generators/rspec/scaffold/templates/actions/destroy.rb
|
81
|
+
- lib/generators/rspec/scaffold/templates/actions/edit.rb
|
82
|
+
- lib/generators/rspec/scaffold/templates/actions/index.rb
|
83
|
+
- lib/generators/rspec/scaffold/templates/actions/new.rb
|
84
|
+
- lib/generators/rspec/scaffold/templates/actions/show.rb
|
85
|
+
- lib/generators/rspec/scaffold/templates/actions/update.rb
|
86
|
+
- lib/generators/rspec/scaffold/templates/controller_spec.rb
|
87
|
+
- lib/generators/rspec/scaffold/templates/edit_erb_spec.rb
|
88
|
+
- lib/generators/rspec/scaffold/templates/helper_spec.erb
|
89
|
+
- lib/generators/rspec/scaffold/templates/index_erb_spec.rb
|
90
|
+
- lib/generators/rspec/scaffold/templates/new_erb_spec.rb
|
91
|
+
- lib/generators/rspec/scaffold/templates/routing_spec.rb
|
92
|
+
- lib/generators/rspec/scaffold/templates/show_erb_spec.rb
|
93
|
+
- lib/generators/rspec/scaffold/templates/views/erb/_form.html.erb
|
94
|
+
- lib/generators/rspec/scaffold/templates/views/erb/edit.html.erb
|
95
|
+
- lib/generators/rspec/scaffold/templates/views/erb/index.html.erb
|
96
|
+
- lib/generators/rspec/scaffold/templates/views/erb/new.html.erb
|
97
|
+
- lib/generators/rspec/scaffold/templates/views/erb/show.html.erb
|
98
|
+
- lib/generators/rspec/scaffold/templates/views/haml/_form.html.haml
|
99
|
+
- lib/generators/rspec/scaffold/templates/views/haml/edit.html.haml
|
100
|
+
- lib/generators/rspec/scaffold/templates/views/haml/index.html.haml
|
101
|
+
- lib/generators/rspec/scaffold/templates/views/haml/new.html.haml
|
102
|
+
- lib/generators/rspec/scaffold/templates/views/haml/show.html.haml
|
103
|
+
- lib/generators/rspec/skeleton/USAGE
|
104
|
+
- lib/generators/rspec/skeleton/skeleton_generator.rb
|
105
|
+
- lib/generators/rspec/skeleton/templates/previous_failures.txt
|
106
|
+
- lib/generators/rspec/skeleton/templates/rcov.opts
|
107
|
+
- lib/generators/rspec/skeleton/templates/rspec.rake
|
108
|
+
- lib/generators/rspec/skeleton/templates/script/autospec
|
109
|
+
- lib/generators/rspec/skeleton/templates/script/spec
|
110
|
+
- lib/generators/rspec/skeleton/templates/spec.opts
|
111
|
+
- lib/generators/rspec/skeleton/templates/spec_helper.rb
|
112
|
+
- lib/generators/rspec_rails3_gen_base.rb
|
113
|
+
- LICENSE
|
114
|
+
- README
|
115
|
+
- README.rdoc
|
116
|
+
has_rdoc: true
|
117
|
+
homepage: http://github.com/kristianmandrup/rspec_rails3_gen
|
118
|
+
licenses: []
|
119
|
+
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options:
|
122
|
+
- --charset=UTF-8
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: "0"
|
130
|
+
version:
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: "0"
|
136
|
+
version:
|
137
|
+
requirements: []
|
138
|
+
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 1.3.5
|
141
|
+
signing_key:
|
142
|
+
specification_version: 3
|
143
|
+
summary: RSpec Rails 3 generators
|
144
|
+
test_files:
|
145
|
+
- spec/rspec_rails3_spec.rb
|
146
|
+
- spec/spec_helper.rb
|