Objective3-objective_spec 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/LICENSE +20 -0
- data/README.rdoc +13 -0
- data/Rakefile +48 -0
- data/TODO +6 -0
- data/VERSION +1 -0
- data/generators/objective_controller/USAGE +33 -0
- data/generators/objective_controller/objective_controller_generator.rb +45 -0
- data/generators/objective_controller/templates/controller_spec.rb +25 -0
- data/generators/objective_controller/templates/helper_spec.rb +11 -0
- data/generators/objective_controller/templates/view_spec.rb +10 -0
- data/generators/objective_resource/.DS_Store +0 -0
- data/generators/objective_resource/objective_resource_generator.rb +172 -0
- data/generators/objective_resource/templates/.DS_Store +0 -0
- data/generators/objective_resource/templates/controller.rb +2 -0
- data/generators/objective_resource/templates/helper.rb +2 -0
- data/generators/objective_resource/templates/migration.rb +15 -0
- data/generators/objective_resource/templates/model.rb +2 -0
- data/generators/objective_resource/templates/rspec/functional_spec.rb +247 -0
- data/generators/objective_resource/templates/rspec/helper_spec.rb +11 -0
- data/generators/objective_resource/templates/rspec/routing_spec.rb +61 -0
- data/generators/objective_resource/templates/rspec/unit_spec.rb +10 -0
- data/generators/objective_resource/templates/rspec/views/edit_spec.rb +23 -0
- data/generators/objective_resource/templates/rspec/views/index_spec.rb +21 -0
- data/generators/objective_resource/templates/rspec/views/new_spec.rb +23 -0
- data/generators/objective_resource/templates/rspec/views/show_spec.rb +19 -0
- data/generators/objective_resource/templates/view__form.haml +5 -0
- data/generators/objective_resource/templates/view_edit.haml +11 -0
- data/generators/objective_resource/templates/view_index.haml +19 -0
- data/generators/objective_resource/templates/view_new.haml +9 -0
- data/generators/objective_resource/templates/view_show.haml +9 -0
- data/generators/objective_spec/objective_spec_generator.rb +32 -0
- data/generators/objective_spec/templates/spec_helpers/common.rb +3 -0
- data/generators/objective_spec/templates/spec_helpers/controller.rb +3 -0
- data/generators/objective_spec/templates/spec_helpers/model.rb +3 -0
- data/generators/objective_spec/templates/spec_helpers/view.rb +3 -0
- data/init.rb +2 -0
- data/lib/objective_spec.rb +6 -0
- data/lib/objective_spec/assets.rb +2 -0
- data/lib/objective_spec/mailer_example_group.rb +14 -0
- data/lib/objective_spec/matchers.rb +8 -0
- data/lib/objective_spec/spec_helpers.rb +4 -0
- data/spec/objective_spec_spec.rb +7 -0
- data/spec/spec_helper.rb +9 -0
- metadata +98 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Blake Watters
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
= Objective Spec
|
2
|
+
Author: Blake Watters <blake@objective3.com>
|
3
|
+
|
4
|
+
Additional RSpec testing goodness for Rails from Objective 3.
|
5
|
+
|
6
|
+
Includes:
|
7
|
+
* An example group for testing Mailers
|
8
|
+
* Infrastructure for matchers and spec_helpers
|
9
|
+
* Disable asset timestamping during spec runs
|
10
|
+
|
11
|
+
== Copyright
|
12
|
+
|
13
|
+
Copyright (c) 2009 Objective 3. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "objective_spec"
|
8
|
+
gem.summary = %Q{TODO}
|
9
|
+
gem.email = "blake@objective3.com"
|
10
|
+
gem.homepage = "http://github.com/Objective3/objective_spec"
|
11
|
+
gem.authors = ["Blake Watters"]
|
12
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
13
|
+
end
|
14
|
+
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'spec/rake/spectask'
|
20
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
21
|
+
spec.libs << 'lib' << 'spec'
|
22
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
23
|
+
end
|
24
|
+
|
25
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
26
|
+
spec.libs << 'lib' << 'spec'
|
27
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
28
|
+
spec.rcov = true
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
task :default => :spec
|
33
|
+
|
34
|
+
require 'rake/rdoctask'
|
35
|
+
Rake::RDocTask.new do |rdoc|
|
36
|
+
if File.exist?('VERSION.yml')
|
37
|
+
config = YAML.load(File.read('VERSION.yml'))
|
38
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
39
|
+
else
|
40
|
+
version = ""
|
41
|
+
end
|
42
|
+
|
43
|
+
rdoc.rdoc_dir = 'rdoc'
|
44
|
+
rdoc.title = "objective_spec #{version}"
|
45
|
+
rdoc.rdoc_files.include('README*')
|
46
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
47
|
+
end
|
48
|
+
|
data/TODO
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Description:
|
2
|
+
The objective_controller generator creates stub specs and files for a new
|
3
|
+
controller and its views.
|
4
|
+
|
5
|
+
The generator takes a controller name and a list of views as arguments.
|
6
|
+
The controller name may be given in CamelCase or under_score and should
|
7
|
+
not be suffixed with 'Controller'. To create a controller within a
|
8
|
+
module, specify the controller name as 'module/controller'.
|
9
|
+
|
10
|
+
The generator creates stubs for a controller (and spec), a view (and spec)
|
11
|
+
for each view in the argument list, plus a helper.
|
12
|
+
|
13
|
+
Example:
|
14
|
+
./script/generate objective_controller dog bark fetch
|
15
|
+
...
|
16
|
+
create spec/controllers/dog_controller_spec.rb
|
17
|
+
create app/controllers/dog_controller.rb
|
18
|
+
create app/helpers/dog_helper.rb
|
19
|
+
create spec/views/dog/bark_view_spec.rb
|
20
|
+
create app/views/dog/bark.html.haml
|
21
|
+
create spec/views/dog/fetch_view_spec.rb
|
22
|
+
create app/views/dog/fetch.html.haml
|
23
|
+
|
24
|
+
Modules Example:
|
25
|
+
./script/generate objective_controller 'pets/dog' bark fetch
|
26
|
+
...
|
27
|
+
create spec/controllers/pets/dog_controller_spec.rb
|
28
|
+
create app/controllers/pets/dog_controller.rb
|
29
|
+
create app/helpers/pets/dog_helper.rb
|
30
|
+
create spec/views/pets/dog/bark_view_spec.rb
|
31
|
+
create app/views/pets/dog/bark.html.haml
|
32
|
+
create spec/views/pets/dog/fetch_view_spec.rb
|
33
|
+
create app/views/pets/dog/fetch.html.haml
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rails_generator/generators/components/controller/controller_generator'
|
2
|
+
|
3
|
+
class ObjectiveControllerGenerator < ControllerGenerator
|
4
|
+
|
5
|
+
def manifest
|
6
|
+
record do |m|
|
7
|
+
# Check for class naming collisions.
|
8
|
+
m.class_collisions class_path, "#{class_name}Controller", "#{class_name}Helper"
|
9
|
+
|
10
|
+
# Controller, helper, views, and spec directories.
|
11
|
+
m.directory File.join('app/controllers', class_path)
|
12
|
+
m.directory File.join('app/helpers', class_path)
|
13
|
+
m.directory File.join('app/views', class_path, file_name)
|
14
|
+
m.directory File.join('spec/controllers', class_path)
|
15
|
+
m.directory File.join('spec/helpers', class_path)
|
16
|
+
m.directory File.join('spec/views', class_path, file_name)
|
17
|
+
|
18
|
+
@default_file_extension = "html.haml"
|
19
|
+
|
20
|
+
# Controller spec, class, and helper.
|
21
|
+
m.template 'controller_spec.rb',
|
22
|
+
File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")
|
23
|
+
|
24
|
+
m.template 'helper_spec.rb',
|
25
|
+
File.join('spec/helpers', class_path, "#{file_name}_helper_spec.rb")
|
26
|
+
|
27
|
+
m.template 'controller:controller.rb',
|
28
|
+
File.join('app/controllers', class_path, "#{file_name}_controller.rb")
|
29
|
+
|
30
|
+
m.template 'controller:helper.rb',
|
31
|
+
File.join('app/helpers', class_path, "#{file_name}_helper.rb")
|
32
|
+
|
33
|
+
# Spec and view template for each action.
|
34
|
+
actions.each do |action|
|
35
|
+
m.template 'view_spec.rb',
|
36
|
+
File.join('spec/views', class_path, file_name, "#{action}.#{@default_file_extension}_spec.rb"),
|
37
|
+
:assigns => { :action => action, :model => file_name }
|
38
|
+
path = File.join('app/views', class_path, file_name, "#{action}.#{@default_file_extension}")
|
39
|
+
m.template "controller:view.#{@default_file_extension}",
|
40
|
+
path,
|
41
|
+
:assigns => { :action => action, :path => path }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,25 @@
|
|
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
|
+
<% unless actions.empty? -%>
|
15
|
+
<% for action in actions -%>
|
16
|
+
|
17
|
+
describe "GET '<%= action %>'" do
|
18
|
+
it "should be successful" do
|
19
|
+
get '<%= action %>'
|
20
|
+
response.should be_success
|
21
|
+
end
|
22
|
+
end
|
23
|
+
<% end -%>
|
24
|
+
<% end -%>
|
25
|
+
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 "should be included in the object returned by #helper" 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,10 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
|
2
|
+
|
3
|
+
describe "/<%= class_name.underscore %>/<%= action %>" do
|
4
|
+
|
5
|
+
# Delete this example and add some real ones or delete this file
|
6
|
+
it "should tell you where to find the file" do
|
7
|
+
render '<%= class_name.underscore %>/<%= action %>'
|
8
|
+
response.should have_tag('p', %r[Find me in app/views/<%= class_name.underscore %>/<%= action %>])
|
9
|
+
end
|
10
|
+
end
|
Binary file
|
@@ -0,0 +1,172 @@
|
|
1
|
+
class ObjectiveResourceGenerator < Rails::Generator::NamedBase
|
2
|
+
attr_reader :controller_name,
|
3
|
+
:controller_class_path,
|
4
|
+
:controller_file_path,
|
5
|
+
:controller_class_nesting,
|
6
|
+
:controller_class_nesting_depth,
|
7
|
+
:controller_class_name,
|
8
|
+
:controller_singular_name,
|
9
|
+
:controller_plural_name,
|
10
|
+
:resource_edit_path,
|
11
|
+
:default_file_extension,
|
12
|
+
:generator_default_file_extension
|
13
|
+
alias_method :controller_file_name, :controller_singular_name
|
14
|
+
alias_method :controller_table_name, :controller_plural_name
|
15
|
+
|
16
|
+
def initialize(runtime_args, runtime_options = {})
|
17
|
+
super
|
18
|
+
|
19
|
+
if has_rspec?
|
20
|
+
if ActionController::Base.respond_to?(:resource_action_separator)
|
21
|
+
@resource_edit_path = "/edit"
|
22
|
+
else
|
23
|
+
@resource_edit_path = ";edit"
|
24
|
+
end
|
25
|
+
else
|
26
|
+
raise "You do not have rspec installed. WTF are you doing?"
|
27
|
+
end
|
28
|
+
|
29
|
+
raise "You don't have haml installed, WTF are you, a joker?" unless defined?(Haml)
|
30
|
+
@generator_default_file_extension = "haml"
|
31
|
+
@default_file_extension = "html.#{@generator_default_file_extension}"
|
32
|
+
|
33
|
+
@controller_name = @name.pluralize
|
34
|
+
|
35
|
+
base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
|
36
|
+
@controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
|
37
|
+
|
38
|
+
if @controller_class_nesting.empty?
|
39
|
+
@controller_class_name = @controller_class_name_without_nesting
|
40
|
+
else
|
41
|
+
@controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def manifest
|
46
|
+
record do |m|
|
47
|
+
# Check for class naming collisions.
|
48
|
+
m.class_collisions(controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}Helper")
|
49
|
+
m.class_collisions(class_path, "#{class_name}")
|
50
|
+
|
51
|
+
# Controller, helper, views, and test directories.
|
52
|
+
m.directory(File.join('app/models', class_path))
|
53
|
+
m.directory(File.join('app/controllers', controller_class_path))
|
54
|
+
m.directory(File.join('app/helpers', controller_class_path))
|
55
|
+
m.directory(File.join('app/views', controller_class_path, controller_file_name))
|
56
|
+
|
57
|
+
m.directory(File.join('spec/controllers', controller_class_path))
|
58
|
+
m.directory(File.join('spec/helpers', class_path))
|
59
|
+
m.directory(File.join('spec/models', class_path))
|
60
|
+
m.directory File.join('spec/views', controller_class_path, controller_file_name)
|
61
|
+
|
62
|
+
scaffold_views.each do |action|
|
63
|
+
m.template(
|
64
|
+
"view_#{action}.#{generator_default_file_extension}",
|
65
|
+
File.join('app/views', controller_class_path, controller_file_name, "#{action}.#{default_file_extension}")
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
m.template('model.rb', File.join('app/models', class_path, "#{file_name}.rb"))
|
70
|
+
m.template('controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb"))
|
71
|
+
m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
|
72
|
+
|
73
|
+
m.template('rspec/functional_spec.rb', File.join('spec/controllers', controller_class_path, "#{controller_file_name}_controller_spec.rb"))
|
74
|
+
m.template('rspec/routing_spec.rb', File.join('spec/controllers', controller_class_path, "#{controller_file_name}_routing_spec.rb"))
|
75
|
+
m.template('rspec/helper_spec.rb', File.join('spec/helpers', class_path, "#{controller_file_name}_helper_spec.rb"))
|
76
|
+
m.template('rspec/unit_spec.rb', File.join('spec/models', class_path, "#{file_name}_spec.rb"))
|
77
|
+
|
78
|
+
#Use Factories instead of fixtures
|
79
|
+
model_factory = "\n\nFactory.define(:#{file_name}) do |f|\n"
|
80
|
+
for attribute in attributes
|
81
|
+
model_factory << "\tf.#{attribute.name} #{attribute.default_value}\n"
|
82
|
+
end
|
83
|
+
model_factory << "end\n"
|
84
|
+
append_file("spec/factories.rb", model_factory)
|
85
|
+
|
86
|
+
rspec_views.each do |action|
|
87
|
+
m.template(
|
88
|
+
"rspec/views/#{action}_spec.rb",
|
89
|
+
File.join('spec/views', controller_class_path, controller_file_name, "#{action}_spec.rb")
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
unless options[:skip_migration]
|
95
|
+
migration_template = 'migration.rb'
|
96
|
+
|
97
|
+
m.migration_template(
|
98
|
+
migration_template, 'db/migrate',
|
99
|
+
:assigns => {
|
100
|
+
:migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}",
|
101
|
+
:attributes => attributes
|
102
|
+
},
|
103
|
+
:migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
m.route_resources controller_file_name
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Lifted from Rick Olson's restful_authentication
|
112
|
+
def has_rspec?
|
113
|
+
options[:rspec] || (File.exist?('spec') && File.directory?('spec'))
|
114
|
+
end
|
115
|
+
|
116
|
+
protected
|
117
|
+
# Override with your own usage banner.
|
118
|
+
def banner
|
119
|
+
"Usage: #{$0} scaffold_resource ModelName [field:type, field:type]"
|
120
|
+
end
|
121
|
+
|
122
|
+
def rspec_views
|
123
|
+
%w[ index show new edit ]
|
124
|
+
end
|
125
|
+
|
126
|
+
def scaffold_views
|
127
|
+
rspec_views + %w[ _form ]
|
128
|
+
end
|
129
|
+
|
130
|
+
def model_name
|
131
|
+
class_name.demodulize
|
132
|
+
end
|
133
|
+
|
134
|
+
def add_options!(opt)
|
135
|
+
opt.separator ''
|
136
|
+
opt.separator 'Options:'
|
137
|
+
opt.on("--rspec", "Force rspec mode (checks for RAILS_ROOT/spec by default)") { |v| options[:rspec] = true }
|
138
|
+
end
|
139
|
+
|
140
|
+
def append_file(path, data)
|
141
|
+
File.open(path, 'ab') { |file| file.write(data) }
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
module Rails
|
146
|
+
module Generator
|
147
|
+
class GeneratedAttribute
|
148
|
+
def default_value
|
149
|
+
@default_value ||= case type
|
150
|
+
when :int, :integer then "\"1\""
|
151
|
+
when :float then "\"1.5\""
|
152
|
+
when :decimal then "\"9.99\""
|
153
|
+
when :datetime, :timestamp, :time then "Time.now"
|
154
|
+
when :date then "Date.today"
|
155
|
+
when :string then "\"MyString\""
|
156
|
+
when :text then "\"MyText\""
|
157
|
+
when :boolean then "false"
|
158
|
+
else
|
159
|
+
""
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def input_type
|
164
|
+
@input_type ||= case type
|
165
|
+
when :text then "textarea"
|
166
|
+
else
|
167
|
+
"input"
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class <%= migration_name %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :<%= table_name %>, :force => true do |t|
|
4
|
+
<% for attribute in attributes -%>
|
5
|
+
t.<%= attribute.type %> :<%= attribute.name %>
|
6
|
+
<% end -%>
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table :<%= table_name %>
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,247 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../spec_helper')
|
2
|
+
|
3
|
+
describe <%= controller_class_name %>Controller do
|
4
|
+
describe "handling GET /<%= table_name %>" do
|
5
|
+
|
6
|
+
it "should be successful" do
|
7
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
8
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return([<%= file_name %>])
|
9
|
+
get :index
|
10
|
+
response.should be_success
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should render index template" do
|
14
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
15
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return([<%= file_name %>])
|
16
|
+
get :index
|
17
|
+
response.should render_template('index')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should find all <%= table_name %>" do
|
21
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
22
|
+
<%= controller_class_name.singularize %>.should_receive(:find).with(:all).and_return([<%= file_name %>])
|
23
|
+
get :index
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should assign the found <%= table_name %> for the view" do
|
27
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
28
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return([<%= file_name %>])
|
29
|
+
get :index
|
30
|
+
assigns[:<%= table_name %>].should == [<%= file_name %>]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "handling GET /<%= table_name %>/1" do
|
35
|
+
|
36
|
+
it "should be successful" do
|
37
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
38
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
39
|
+
get :show, :id => "1"
|
40
|
+
response.should be_success
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should render show template" do
|
44
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
45
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
46
|
+
get :show, :id => "1"
|
47
|
+
response.should render_template('show')
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should find the <%= file_name %> requested" do
|
51
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
52
|
+
<%= controller_class_name.singularize %>.should_receive(:find).with("1").and_return(<%= file_name %>)
|
53
|
+
get :show, :id => "1"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should assign the found <%= file_name %> for the view" do
|
57
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
58
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
59
|
+
get :show, :id => "1"
|
60
|
+
assigns[:<%= file_name %>].should equal(<%= file_name %>)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "handling GET /<%= table_name %>/new" do
|
65
|
+
|
66
|
+
it "should be successful" do
|
67
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
68
|
+
<%= controller_class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
|
69
|
+
get :new
|
70
|
+
response.should be_success
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should render new template" do
|
74
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
75
|
+
<%= controller_class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
|
76
|
+
get :new
|
77
|
+
response.should render_template('new')
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should create an new <%= file_name %>" do
|
81
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
82
|
+
<%= controller_class_name.singularize %>.should_receive(:new).and_return(<%= file_name %>)
|
83
|
+
get :new
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should not save the new <%= file_name %>" do
|
87
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
88
|
+
<%= controller_class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
|
89
|
+
<%= file_name %>.should_not_receive(:save)
|
90
|
+
get :new
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should assign the new <%= file_name %> for the view" do
|
94
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
95
|
+
<%= controller_class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
|
96
|
+
get :new
|
97
|
+
assigns[:<%= file_name %>].should equal(<%= file_name %>)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "handling GET /<%= table_name %>/1/edit" do
|
102
|
+
|
103
|
+
it "should be successful" do
|
104
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
105
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
106
|
+
get :edit, :id => "1"
|
107
|
+
response.should be_success
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should render edit template" do
|
111
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
112
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
113
|
+
get :edit, :id => "1"
|
114
|
+
response.should render_template('edit')
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should find the <%= file_name %> requested" do
|
118
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
119
|
+
<%= controller_class_name.singularize %>.should_receive(:find).and_return(<%= file_name %>)
|
120
|
+
get :edit, :id => "1"
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should assign the found <%= controller_class_name %> for the view" do
|
124
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
125
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
126
|
+
get :edit, :id => "1"
|
127
|
+
assigns[:<%= file_name %>].should equal(<%= file_name %>)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "handling POST /<%= table_name %>" do
|
132
|
+
|
133
|
+
describe "with successful save" do
|
134
|
+
|
135
|
+
it "should create a new <%= file_name %>" do
|
136
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
137
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
138
|
+
<%= controller_class_name.singularize %>.should_receive(:new).with({}).and_return(<%= file_name %>)
|
139
|
+
<%= file_name %>.should_receive(:save).and_return(true)
|
140
|
+
post :create, :<%= file_name %> => {}
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should redirect to the new <%= file_name %>" do
|
144
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
145
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
146
|
+
<%= controller_class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
|
147
|
+
<%= file_name %>.should_receive(:save).and_return(true)
|
148
|
+
post :create, :<%= file_name %> => {}
|
149
|
+
response.should redirect_to(<%= table_name.singularize %>_url("1"))
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "with failed save" do
|
155
|
+
|
156
|
+
it "should re-render 'new'" do
|
157
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
158
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
159
|
+
<%= controller_class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
|
160
|
+
<%= file_name %>.should_receive(:save).and_return(false)
|
161
|
+
post :create, :<%= file_name %> => {}
|
162
|
+
response.should render_template('new')
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe "handling PUT /<%= table_name %>/1" do
|
169
|
+
|
170
|
+
describe "with successful update" do
|
171
|
+
|
172
|
+
it "should find the <%= file_name %> requested" do
|
173
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
174
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
175
|
+
<%= controller_class_name.singularize %>.should_receive(:find).with("1").and_return(<%= file_name %>)
|
176
|
+
<%= file_name %>.should_receive(:update_attributes).and_return(true)
|
177
|
+
put :update, :id => "1"
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should update the found <%= file_name %>" do
|
181
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
182
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
183
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
184
|
+
<%= file_name %>.should_receive(:update_attributes).and_return(true)
|
185
|
+
put :update, :id => "1"
|
186
|
+
assigns(:<%= file_name %>).should equal(<%= file_name %>)
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should assign the found <%= file_name %> for the view" do
|
190
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
191
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
192
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
193
|
+
<%= file_name %>.should_receive(:update_attributes).and_return(true)
|
194
|
+
put :update, :id => "1"
|
195
|
+
assigns(:<%= file_name %>).should equal(<%= file_name %>)
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should redirect to the <%= file_name %>" do
|
199
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
200
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
201
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
202
|
+
<%= file_name %>.should_receive(:update_attributes).and_return(true)
|
203
|
+
put :update, :id => "1"
|
204
|
+
response.should redirect_to(<%= table_name.singularize %>_url("1"))
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
describe "with failed update" do
|
210
|
+
|
211
|
+
it "should re-render 'edit'" do
|
212
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
213
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
214
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
215
|
+
<%= file_name %>.should_receive(:update_attributes).and_return(false)
|
216
|
+
put :update, :id => "1"
|
217
|
+
response.should render_template('edit')
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
describe "handling DELETE /<%= table_name %>/1" do
|
224
|
+
|
225
|
+
it "should find the <%= file_name %> requested" do
|
226
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
227
|
+
<%= file_name %>.stub!(:destroy).and_return(true)
|
228
|
+
<%= controller_class_name.singularize %>.should_receive(:find).with("1").and_return(<%= file_name %>)
|
229
|
+
delete :destroy, :id => "1"
|
230
|
+
end
|
231
|
+
|
232
|
+
it "should call destroy on the found <%= file_name %>" do
|
233
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
234
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
235
|
+
<%= file_name %>.should_receive(:destroy).and_return(true)
|
236
|
+
delete :destroy, :id => "1"
|
237
|
+
end
|
238
|
+
|
239
|
+
it "should redirect to the <%= table_name %> list" do
|
240
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
241
|
+
<%= file_name %>.stub!(:destroy).and_return(true)
|
242
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
243
|
+
delete :destroy, :id => "1"
|
244
|
+
response.should redirect_to(<%= table_name %>_url)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../spec_helper')
|
2
|
+
|
3
|
+
describe <%= controller_class_name %>Helper do
|
4
|
+
|
5
|
+
#Delete this example and add some real ones or delete this file
|
6
|
+
it "should be included in the object returned by #helper" do
|
7
|
+
included_modules = (class << helper; self; end).send :included_modules
|
8
|
+
included_modules.should include(<%= controller_class_name %>Helper)
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../spec_helper')
|
2
|
+
|
3
|
+
describe <%= controller_class_name %>Controller do
|
4
|
+
describe "route generation" do
|
5
|
+
|
6
|
+
it "should map { :controller => '<%= table_name %>', :action => 'index' } to /<%= table_name %>" do
|
7
|
+
route_for(:controller => "<%= table_name %>", :action => "index").should == "/<%= table_name %>"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should map { :controller => '<%= table_name %>', :action => 'new' } to /<%= table_name %>/new" do
|
11
|
+
route_for(:controller => "<%= table_name %>", :action => "new").should == "/<%= table_name %>/new"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should map { :controller => '<%= table_name %>', :action => 'show', :id => '1'} to /<%= table_name %>/1" do
|
15
|
+
route_for(:controller => "<%= table_name %>", :action => "show", :id => "1").should == "/<%= table_name %>/1"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should map { :controller => '<%= table_name %>', :action => 'edit', :id => '1' } to /<%= table_name %>/1<%= resource_edit_path %>" do
|
19
|
+
route_for(:controller => "<%= table_name %>", :action => "edit", :id => "1").should == "/<%= table_name %>/1<%= resource_edit_path %>"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should map { :controller => '<%= table_name %>', :action => 'update', :id => '1' } to /<%= table_name %>/1" do
|
23
|
+
route_for(:controller => "<%= table_name %>", :action => "update", :id => "1").should == {:path => "/<%= table_name %>/1", :method => :put}
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should map { :controller => '<%= table_name %>', :action => 'destroy', :id => '1' } to /<%= table_name %>/1" do
|
27
|
+
route_for(:controller => "<%= table_name %>", :action => "destroy", :id => "1").should == {:path => "/<%= table_name %>/1", :method => :delete}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "route recognition" do
|
32
|
+
|
33
|
+
it "should generate params { :controller => '<%= table_name %>', action => 'index' } from GET /<%= table_name %>" do
|
34
|
+
params_from(:get, "/<%= table_name %>").should == {:controller => "<%= table_name %>", :action => "index"}
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should generate params { :controller => '<%= table_name %>', action => 'new' } from GET /<%= table_name %>/new" do
|
38
|
+
params_from(:get, "/<%= table_name %>/new").should == {:controller => "<%= table_name %>", :action => "new"}
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should generate params { :controller => '<%= table_name %>', action => 'create' } from POST /<%= table_name %>" do
|
42
|
+
params_from(:post, "/<%= table_name %>").should == {:controller => "<%= table_name %>", :action => "create"}
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should generate params { :controller => '<%= table_name %>', action => 'show', id => '1' } from GET /<%= table_name %>/1" do
|
46
|
+
params_from(:get, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "show", :id => "1"}
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should generate params { :controller => '<%= table_name %>', action => 'edit', id => '1' } from GET /<%= table_name %>/1;edit" do
|
50
|
+
params_from(:get, "/<%= table_name %>/1<%= resource_edit_path %>").should == {:controller => "<%= table_name %>", :action => "edit", :id => "1"}
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should generate params { :controller => '<%= table_name %>', action => 'update', id => '1' } from PUT /<%= table_name %>/1" do
|
54
|
+
params_from(:put, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "update", :id => "1"}
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should generate params { :controller => '<%= table_name %>', action => 'destroy', id => '1' } from DELETE /<%= table_name %>/1" do
|
58
|
+
params_from(:delete, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "destroy", :id => "1"}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../spec_helper')
|
2
|
+
|
3
|
+
describe <%= class_name %> do
|
4
|
+
|
5
|
+
it "should be valid" do
|
6
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
7
|
+
<%= file_name %>.should be_valid
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../../spec_helper')
|
2
|
+
|
3
|
+
describe "/<%= table_name %>/edit.<%= default_file_extension %>" do
|
4
|
+
include <%= controller_class_name %>Helper
|
5
|
+
|
6
|
+
before do
|
7
|
+
@<%= file_name %> = Factory(:<%= file_name %>)
|
8
|
+
assigns[:<%= file_name %>] = @<%= file_name %>
|
9
|
+
|
10
|
+
template.should_receive(:object_url).twice.and_return(<%= file_name %>_path(@<%= file_name %>))
|
11
|
+
template.should_receive(:collection_url).and_return(<%= file_name.pluralize %>_path)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should render edit form" do
|
15
|
+
render "/<%= table_name %>/edit.<%= default_file_extension %>"
|
16
|
+
|
17
|
+
response.should have_tag("form[action=#{<%= file_name %>_path(@<%= file_name %>)}][method=post]") do
|
18
|
+
# Test attributes here
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../../spec_helper')
|
2
|
+
|
3
|
+
describe "/<%= table_name %>/index.<%= default_file_extension %>" do
|
4
|
+
include <%= controller_class_name %>Helper
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
<% [98,99].each do |id| -%>
|
8
|
+
<%= file_name %>_<%= id %> = Factory(:<%= file_name %>)
|
9
|
+
<% end -%>
|
10
|
+
assigns[:<%= table_name %>] = [<%= file_name %>_98, <%= file_name %>_99]
|
11
|
+
|
12
|
+
template.stub!(:object_url).and_return(<%= file_name %>_path(<%= file_name %>_99))
|
13
|
+
template.stub!(:new_object_url).and_return(new_<%= file_name %>_path)
|
14
|
+
template.stub!(:edit_object_url).and_return(edit_<%= file_name %>_path(<%= file_name %>_99))
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should render list of <%= table_name %>" do
|
18
|
+
render "/<%= table_name %>/index.<%= default_file_extension %>"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../../spec_helper')
|
2
|
+
|
3
|
+
describe "/<%= table_name %>/new.<%= default_file_extension %>" do
|
4
|
+
include <%= controller_class_name %>Helper
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@<%= file_name %> = Factory(:<%= file_name %>)
|
8
|
+
@<%= file_name %>.stub!(:new_record?).and_return(true)
|
9
|
+
assigns[:<%= file_name %>] = @<%= file_name %>
|
10
|
+
|
11
|
+
|
12
|
+
template.stub!(:object_url).and_return(<%= file_name %>_path(@<%= file_name %>))
|
13
|
+
template.stub!(:collection_url).and_return(<%= file_name.pluralize %>_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should render new form" do
|
17
|
+
render "/<%= table_name %>/new.<%= default_file_extension %>"
|
18
|
+
|
19
|
+
response.should have_tag("form[action=?][method=post]", <%= table_name %>_path) do
|
20
|
+
# Test attributes here
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../../spec_helper')
|
2
|
+
|
3
|
+
describe "/<%= table_name %>/show.<%= default_file_extension %>" do
|
4
|
+
include <%= controller_class_name %>Helper
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@<%= file_name %> = Factory(:<%= file_name %>)
|
8
|
+
|
9
|
+
assigns[:<%= file_name %>] = @<%= file_name %>
|
10
|
+
|
11
|
+
template.stub!(:edit_object_url).and_return(edit_<%= file_name %>_path(@<%= file_name %>))
|
12
|
+
template.stub!(:collection_url).and_return(<%= file_name.pluralize %>_path)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should render attributes in <p>" do
|
16
|
+
render "/<%= table_name %>/show.<%= default_file_extension %>"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
%h1 Editing <%= singular_name %>
|
2
|
+
|
3
|
+
= error_messages_for :<%= singular_name %>
|
4
|
+
|
5
|
+
- form_for(:<%= singular_name %>, :url => object_url, :html => { :method => :put }) do |f|
|
6
|
+
= render :partial => "form", :locals => { :f => f }
|
7
|
+
%p= submit_tag "Update"
|
8
|
+
|
9
|
+
= link_to 'Show', object_url
|
10
|
+
|
|
11
|
+
= link_to 'Back', collection_url
|
@@ -0,0 +1,19 @@
|
|
1
|
+
%h1 Listing <%= plural_name %>
|
2
|
+
|
3
|
+
%table
|
4
|
+
%tr
|
5
|
+
<% for attribute in attributes -%>
|
6
|
+
%th <%= attribute.column.human_name %>
|
7
|
+
<% end -%>
|
8
|
+
- @<%= plural_name %>.each do |<%= singular_name %>|
|
9
|
+
%tr
|
10
|
+
<% for attribute in attributes -%>
|
11
|
+
%td= h <%= singular_name %>.<%= attribute.name %>
|
12
|
+
<% end -%>
|
13
|
+
%td= link_to 'Show', object_url(<%= singular_name %>)
|
14
|
+
%td= link_to 'Edit', edit_object_url(<%= singular_name %>)
|
15
|
+
%td= link_to 'Destroy', object_url(<%= singular_name %>), :confirm => 'Are you sure?', :method => :delete
|
16
|
+
|
17
|
+
%br/
|
18
|
+
|
19
|
+
=link_to 'New <%= singular_name %>', new_object_url
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class ObjectiveSpecGenerator < Rails::Generator::Base
|
2
|
+
|
3
|
+
def initialize(runtime_args, runtime_options = {})
|
4
|
+
puts <<-INFO
|
5
|
+
|
6
|
+
You are installing Objective Spec. After this generator has completed, you
|
7
|
+
will need to add require 'objective_spec' to your spec/spec_helper.rb file
|
8
|
+
to load the library.
|
9
|
+
|
10
|
+
INFO
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def manifest
|
15
|
+
record do |m|
|
16
|
+
m.directory 'spec/mailers'
|
17
|
+
m.directory 'spec/matchers'
|
18
|
+
m.directory 'spec/spec_helpers'
|
19
|
+
m.file 'spec_helpers/common.rb', 'spec/spec_helpers/common.rb'
|
20
|
+
m.file 'spec_helpers/model.rb', 'spec/spec_helpers/model.rb'
|
21
|
+
m.file 'spec_helpers/view.rb', 'spec/spec_helpers/view.rb'
|
22
|
+
m.file 'spec_helpers/controller.rb', 'spec/spec_helpers/controller.rb'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def banner
|
29
|
+
"Usage: #{$0} objective_spec"
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/init.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module Spec
|
2
|
+
module Rails
|
3
|
+
module Example
|
4
|
+
# Mailer examples live in $RAILS_ROOT/spec/mailers/.
|
5
|
+
#
|
6
|
+
# Mailer examples use Spec::Rails::Example::MailerExampleGroup, which
|
7
|
+
# provides support for fixtures and some custom expectations via extensions
|
8
|
+
# to ActiveRecord::Base.
|
9
|
+
class MailerExampleGroup < ActiveSupport::TestCase
|
10
|
+
Spec::Example::ExampleGroupFactory.register(:mailer, self)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Objective3-objective_spec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Blake Watters
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-08 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: blake@objective3.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- .gitignore
|
27
|
+
- LICENSE
|
28
|
+
- README.rdoc
|
29
|
+
- Rakefile
|
30
|
+
- TODO
|
31
|
+
- VERSION
|
32
|
+
- generators/objective_controller/USAGE
|
33
|
+
- generators/objective_controller/objective_controller_generator.rb
|
34
|
+
- generators/objective_controller/templates/controller_spec.rb
|
35
|
+
- generators/objective_controller/templates/helper_spec.rb
|
36
|
+
- generators/objective_controller/templates/view_spec.rb
|
37
|
+
- generators/objective_resource/.DS_Store
|
38
|
+
- generators/objective_resource/objective_resource_generator.rb
|
39
|
+
- generators/objective_resource/templates/.DS_Store
|
40
|
+
- generators/objective_resource/templates/controller.rb
|
41
|
+
- generators/objective_resource/templates/helper.rb
|
42
|
+
- generators/objective_resource/templates/migration.rb
|
43
|
+
- generators/objective_resource/templates/model.rb
|
44
|
+
- generators/objective_resource/templates/rspec/functional_spec.rb
|
45
|
+
- generators/objective_resource/templates/rspec/helper_spec.rb
|
46
|
+
- generators/objective_resource/templates/rspec/routing_spec.rb
|
47
|
+
- generators/objective_resource/templates/rspec/unit_spec.rb
|
48
|
+
- generators/objective_resource/templates/rspec/views/edit_spec.rb
|
49
|
+
- generators/objective_resource/templates/rspec/views/index_spec.rb
|
50
|
+
- generators/objective_resource/templates/rspec/views/new_spec.rb
|
51
|
+
- generators/objective_resource/templates/rspec/views/show_spec.rb
|
52
|
+
- generators/objective_resource/templates/view__form.haml
|
53
|
+
- generators/objective_resource/templates/view_edit.haml
|
54
|
+
- generators/objective_resource/templates/view_index.haml
|
55
|
+
- generators/objective_resource/templates/view_new.haml
|
56
|
+
- generators/objective_resource/templates/view_show.haml
|
57
|
+
- generators/objective_spec/objective_spec_generator.rb
|
58
|
+
- generators/objective_spec/templates/spec_helpers/common.rb
|
59
|
+
- generators/objective_spec/templates/spec_helpers/controller.rb
|
60
|
+
- generators/objective_spec/templates/spec_helpers/model.rb
|
61
|
+
- generators/objective_spec/templates/spec_helpers/view.rb
|
62
|
+
- init.rb
|
63
|
+
- lib/objective_spec.rb
|
64
|
+
- lib/objective_spec/assets.rb
|
65
|
+
- lib/objective_spec/mailer_example_group.rb
|
66
|
+
- lib/objective_spec/matchers.rb
|
67
|
+
- lib/objective_spec/spec_helpers.rb
|
68
|
+
- spec/objective_spec_spec.rb
|
69
|
+
- spec/spec_helper.rb
|
70
|
+
has_rdoc: true
|
71
|
+
homepage: http://github.com/Objective3/objective_spec
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options:
|
74
|
+
- --charset=UTF-8
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0"
|
82
|
+
version:
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: "0"
|
88
|
+
version:
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.2.0
|
93
|
+
signing_key:
|
94
|
+
specification_version: 2
|
95
|
+
summary: TODO
|
96
|
+
test_files:
|
97
|
+
- spec/objective_spec_spec.rb
|
98
|
+
- spec/spec_helper.rb
|