rails3-generators 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +6 -0
- data/LICENSE +20 -0
- data/README.rdoc +11 -0
- data/Rakefile +57 -0
- data/VERSION +1 -0
- data/features/support/env.rb +4 -0
- data/lib/generators/authlogic.rb +11 -0
- data/lib/generators/authlogic/session/session_generator.rb +18 -0
- data/lib/generators/authlogic/session/templates/session.rb +2 -0
- data/lib/generators/datamapper.rb +80 -0
- data/lib/generators/datamapper/migration/migration_generator.rb +26 -0
- data/lib/generators/datamapper/migration/templates/migration.rb +21 -0
- data/lib/generators/datamapper/model/model_generator.rb +29 -0
- data/lib/generators/datamapper/model/templates/migration.rb +17 -0
- data/lib/generators/datamapper/model/templates/model.rb +10 -0
- data/lib/generators/datamapper/observer/observer_generator.rb +15 -0
- data/lib/generators/datamapper/observer/templates/observer.rb +5 -0
- data/lib/generators/factory_girl.rb +11 -0
- data/lib/generators/factory_girl/model/model_generator.rb +14 -0
- data/lib/generators/factory_girl/model/templates/fixtures.rb +7 -0
- data/lib/generators/haml.rb +9 -0
- data/lib/generators/haml/controller/controller_generator.rb +24 -0
- data/lib/generators/haml/controller/templates/view.html.haml +0 -0
- data/lib/generators/haml/scaffold/scaffold_generator.rb +23 -0
- data/lib/generators/haml/scaffold/templates/_form.haml.erb +10 -0
- data/lib/generators/haml/scaffold/templates/edit.haml.erb +7 -0
- data/lib/generators/haml/scaffold/templates/index.haml.erb +23 -0
- data/lib/generators/haml/scaffold/templates/layout.haml.erb +8 -0
- data/lib/generators/haml/scaffold/templates/new.haml.erb +5 -0
- data/lib/generators/haml/scaffold/templates/show.haml.erb +9 -0
- data/lib/generators/rspec.rb +25 -0
- data/lib/generators/rspec/controller/controller_generator.rb +26 -0
- data/lib/generators/rspec/controller/templates/controller_spec.rb +23 -0
- data/lib/generators/rspec/controller/templates/view_spec.rb +12 -0
- data/lib/generators/rspec/helper/helper_generator.rb +11 -0
- data/lib/generators/rspec/helper/templates/helper_spec.rb +11 -0
- data/lib/generators/rspec/install/install_generator.rb +28 -0
- data/lib/generators/rspec/install/templates/lib/tasks/rspec.rake +182 -0
- data/lib/generators/rspec/install/templates/script/autospec.tt +6 -0
- data/lib/generators/rspec/install/templates/script/spec.tt +10 -0
- data/lib/generators/rspec/install/templates/script/spec_server.tt +9 -0
- data/lib/generators/rspec/install/templates/spec/rcov.opts +2 -0
- data/lib/generators/rspec/install/templates/spec/spec.opts +4 -0
- data/lib/generators/rspec/install/templates/spec/spec_helper.rb +51 -0
- data/lib/generators/rspec/integration/integration_generator.rb +12 -0
- data/lib/generators/rspec/integration/templates/integration_spec.rb +4 -0
- data/lib/generators/rspec/mailer/mailer_generator.rb +21 -0
- data/lib/generators/rspec/mailer/templates/fixture +3 -0
- data/lib/generators/rspec/mailer/templates/mailer_spec.rb +14 -0
- data/lib/generators/rspec/model/model_generator.rb +22 -0
- data/lib/generators/rspec/model/templates/fixtures.yml +19 -0
- data/lib/generators/rspec/model/templates/model_spec.rb +13 -0
- data/lib/generators/rspec/observer/observer_generator.rb +12 -0
- data/lib/generators/rspec/observer/templates/observer_spec.rb +5 -0
- data/lib/generators/rspec/plugin/plugin_generator.rb +11 -0
- data/lib/generators/rspec/plugin/templates/%file_name%_spec.rb.tt +5 -0
- data/lib/generators/rspec/plugin/templates/test_helper.rb +5 -0
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +112 -0
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +127 -0
- data/lib/generators/rspec/scaffold/templates/edit_spec.rb +25 -0
- data/lib/generators/rspec/scaffold/templates/index_spec.rb +27 -0
- data/lib/generators/rspec/scaffold/templates/new_spec.rb +25 -0
- data/lib/generators/rspec/scaffold/templates/routing_spec.rb +67 -0
- data/lib/generators/rspec/scaffold/templates/show_spec.rb +22 -0
- data/lib/rails3-generators.rb +2 -0
- data/rails3-generators.gemspec +116 -0
- data/spec/rails3-generators_spec.rb +4 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +8 -0
- metadata +144 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
%h1 Listing <%= plural_name %>
|
2
|
+
|
3
|
+
%table
|
4
|
+
%tr
|
5
|
+
<% for attribute in attributes -%>
|
6
|
+
%th <%= attribute.human_name %>
|
7
|
+
<% end -%>
|
8
|
+
%th
|
9
|
+
%th
|
10
|
+
%th
|
11
|
+
|
12
|
+
- @<%= plural_name %>.each do |<%= singular_name %>|
|
13
|
+
%tr
|
14
|
+
<% for attribute in attributes -%>
|
15
|
+
%td= <%= singular_name %>.<%= attribute.name %>
|
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
|
20
|
+
|
21
|
+
%br
|
22
|
+
|
23
|
+
= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path
|
@@ -0,0 +1,25 @@
|
|
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
|
@@ -0,0 +1,26 @@
|
|
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
|
@@ -0,0 +1,23 @@
|
|
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
|
@@ -0,0 +1,12 @@
|
|
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
|
@@ -0,0 +1,11 @@
|
|
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
|
@@ -0,0 +1,28 @@
|
|
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
|
@@ -0,0 +1,182 @@
|
|
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
|
@@ -0,0 +1,6 @@
|
|
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")
|
@@ -0,0 +1,10 @@
|
|
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
|
@@ -0,0 +1,9 @@
|
|
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'
|
@@ -0,0 +1,51 @@
|
|
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
|