dchelimsky-rspec-rails 1.1.11 → 1.1.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -0
- data/Manifest.txt +52 -52
- data/Rakefile +1 -1
- data/generators/rspec/templates/rspec.rake +118 -97
- data/generators/rspec_scaffold/templates/edit_erb_spec.rb +7 -6
- data/generators/rspec_scaffold/templates/index_erb_spec.rb +8 -7
- data/generators/rspec_scaffold/templates/new_erb_spec.rb +7 -6
- data/generators/rspec_scaffold/templates/show_erb_spec.rb +8 -8
- data/lib/spec/rails/example/controller_example_group.rb +4 -1
- data/lib/spec/rails/example/view_example_group.rb +5 -5
- data/lib/spec/rails/extensions/action_view/base.rb +4 -2
- data/lib/spec/rails/matchers/render_template.rb +19 -9
- data/lib/spec/rails/version.rb +2 -1
- data/rspec-rails.gemspec +14 -7
- data/spec/rails/example/configuration_spec.rb +51 -55
- data/spec/rails/example/view_spec_spec.rb +21 -0
- data/spec/spec_helper.rb +14 -14
- metadata +56 -56
- /data/{spec_resources → spec/resources}/controllers/action_view_base_spec_controller.rb +0 -0
- /data/{spec_resources → spec/resources}/controllers/controller_spec_controller.rb +0 -0
- /data/{spec_resources → spec/resources}/controllers/redirect_spec_controller.rb +0 -0
- /data/{spec_resources → spec/resources}/controllers/render_spec_controller.rb +0 -0
- /data/{spec_resources → spec/resources}/controllers/rjs_spec_controller.rb +0 -0
- /data/{spec_resources → spec/resources}/helpers/addition_helper.rb +0 -0
- /data/{spec_resources → spec/resources}/helpers/explicit_helper.rb +0 -0
- /data/{spec_resources → spec/resources}/helpers/more_explicit_helper.rb +0 -0
- /data/{spec_resources → spec/resources}/helpers/plugin_application_helper.rb +0 -0
- /data/{spec_resources → spec/resources}/helpers/view_spec_helper.rb +0 -0
- /data/{spec_resources → spec/resources}/views/controller_spec/_partial.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/controller_spec/action_setting_flash_after_session_reset.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/controller_spec/action_setting_flash_before_session_reset.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/controller_spec/action_setting_the_assigns_hash.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/controller_spec/action_with_errors_in_template.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/controller_spec/action_with_template.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/layouts/application.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/layouts/simple.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/objects/_object.html.erb +0 -0
- /data/{spec_resources → spec/resources}/views/render_spec/_a_partial.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/render_spec/action_with_alternate_layout.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/render_spec/some_action.js.rjs +0 -0
- /data/{spec_resources → spec/resources}/views/render_spec/some_action.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/render_spec/some_action.rjs +0 -0
- /data/{spec_resources → spec/resources}/views/rjs_spec/_replacement_partial.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/rjs_spec/hide_div.rjs +0 -0
- /data/{spec_resources → spec/resources}/views/rjs_spec/hide_page_element.rjs +0 -0
- /data/{spec_resources → spec/resources}/views/rjs_spec/insert_html.rjs +0 -0
- /data/{spec_resources → spec/resources}/views/rjs_spec/replace.rjs +0 -0
- /data/{spec_resources → spec/resources}/views/rjs_spec/replace_html.rjs +0 -0
- /data/{spec_resources → spec/resources}/views/rjs_spec/replace_html_with_partial.rjs +0 -0
- /data/{spec_resources → spec/resources}/views/rjs_spec/visual_effect.rjs +0 -0
- /data/{spec_resources → spec/resources}/views/rjs_spec/visual_toggle_effect.rjs +0 -0
- /data/{spec_resources → spec/resources}/views/tag_spec/no_tags.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/tag_spec/single_div_with_no_attributes.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/tag_spec/single_div_with_one_attribute.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/_partial.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/_partial_used_twice.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/_partial_with_local_variable.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/_partial_with_sub_partial.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/_spacer.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/accessor.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/block_helper.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/entry_form.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/explicit_helper.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/foo/show.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/implicit_helper.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/multiple_helpers.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/should_not_receive.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/template_with_partial.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/template_with_partial_using_collection.rhtml +0 -0
- /data/{spec_resources → spec/resources}/views/view_spec/template_with_partial_with_array.rhtml +0 -0
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== Maintenance
|
2
|
+
|
3
|
+
* 1 major enhancement
|
4
|
+
|
5
|
+
* support controller and action path params in view specs (Mike Vincent).
|
6
|
+
|
7
|
+
* 1 minor enhancement
|
8
|
+
|
9
|
+
* improve rdoc for render_template (Patch from Andrew Premdas). Fixes #571.
|
10
|
+
|
1
11
|
=== Version 1.1.11 / 2008-10-24
|
2
12
|
|
3
13
|
* No changes to rspec-rails - release to align with bug-fix release in rspec ... again :(
|
data/Manifest.txt
CHANGED
@@ -100,59 +100,59 @@ spec/rails/sample_spec.rb
|
|
100
100
|
spec/rails/spec_server_spec.rb
|
101
101
|
spec/rails/spec_spec.rb
|
102
102
|
spec/rails_suite.rb
|
103
|
+
spec/resources/controllers/action_view_base_spec_controller.rb
|
104
|
+
spec/resources/controllers/controller_spec_controller.rb
|
105
|
+
spec/resources/controllers/redirect_spec_controller.rb
|
106
|
+
spec/resources/controllers/render_spec_controller.rb
|
107
|
+
spec/resources/controllers/rjs_spec_controller.rb
|
108
|
+
spec/resources/helpers/addition_helper.rb
|
109
|
+
spec/resources/helpers/explicit_helper.rb
|
110
|
+
spec/resources/helpers/more_explicit_helper.rb
|
111
|
+
spec/resources/helpers/plugin_application_helper.rb
|
112
|
+
spec/resources/helpers/view_spec_helper.rb
|
113
|
+
spec/resources/views/controller_spec/_partial.rhtml
|
114
|
+
spec/resources/views/controller_spec/action_setting_flash_after_session_reset.rhtml
|
115
|
+
spec/resources/views/controller_spec/action_setting_flash_before_session_reset.rhtml
|
116
|
+
spec/resources/views/controller_spec/action_setting_the_assigns_hash.rhtml
|
117
|
+
spec/resources/views/controller_spec/action_with_errors_in_template.rhtml
|
118
|
+
spec/resources/views/controller_spec/action_with_template.rhtml
|
119
|
+
spec/resources/views/layouts/application.rhtml
|
120
|
+
spec/resources/views/layouts/simple.rhtml
|
121
|
+
spec/resources/views/objects/_object.html.erb
|
122
|
+
spec/resources/views/render_spec/_a_partial.rhtml
|
123
|
+
spec/resources/views/render_spec/action_with_alternate_layout.rhtml
|
124
|
+
spec/resources/views/render_spec/some_action.js.rjs
|
125
|
+
spec/resources/views/render_spec/some_action.rhtml
|
126
|
+
spec/resources/views/render_spec/some_action.rjs
|
127
|
+
spec/resources/views/rjs_spec/_replacement_partial.rhtml
|
128
|
+
spec/resources/views/rjs_spec/hide_div.rjs
|
129
|
+
spec/resources/views/rjs_spec/hide_page_element.rjs
|
130
|
+
spec/resources/views/rjs_spec/insert_html.rjs
|
131
|
+
spec/resources/views/rjs_spec/replace.rjs
|
132
|
+
spec/resources/views/rjs_spec/replace_html.rjs
|
133
|
+
spec/resources/views/rjs_spec/replace_html_with_partial.rjs
|
134
|
+
spec/resources/views/rjs_spec/visual_effect.rjs
|
135
|
+
spec/resources/views/rjs_spec/visual_toggle_effect.rjs
|
136
|
+
spec/resources/views/tag_spec/no_tags.rhtml
|
137
|
+
spec/resources/views/tag_spec/single_div_with_no_attributes.rhtml
|
138
|
+
spec/resources/views/tag_spec/single_div_with_one_attribute.rhtml
|
139
|
+
spec/resources/views/view_spec/_partial.rhtml
|
140
|
+
spec/resources/views/view_spec/_partial_used_twice.rhtml
|
141
|
+
spec/resources/views/view_spec/_partial_with_local_variable.rhtml
|
142
|
+
spec/resources/views/view_spec/_partial_with_sub_partial.rhtml
|
143
|
+
spec/resources/views/view_spec/_spacer.rhtml
|
144
|
+
spec/resources/views/view_spec/accessor.rhtml
|
145
|
+
spec/resources/views/view_spec/block_helper.rhtml
|
146
|
+
spec/resources/views/view_spec/entry_form.rhtml
|
147
|
+
spec/resources/views/view_spec/explicit_helper.rhtml
|
148
|
+
spec/resources/views/view_spec/foo/show.rhtml
|
149
|
+
spec/resources/views/view_spec/implicit_helper.rhtml
|
150
|
+
spec/resources/views/view_spec/multiple_helpers.rhtml
|
151
|
+
spec/resources/views/view_spec/should_not_receive.rhtml
|
152
|
+
spec/resources/views/view_spec/template_with_partial.rhtml
|
153
|
+
spec/resources/views/view_spec/template_with_partial_using_collection.rhtml
|
154
|
+
spec/resources/views/view_spec/template_with_partial_with_array.rhtml
|
103
155
|
spec/spec_helper.rb
|
104
|
-
spec_resources/controllers/action_view_base_spec_controller.rb
|
105
|
-
spec_resources/controllers/controller_spec_controller.rb
|
106
|
-
spec_resources/controllers/redirect_spec_controller.rb
|
107
|
-
spec_resources/controllers/render_spec_controller.rb
|
108
|
-
spec_resources/controllers/rjs_spec_controller.rb
|
109
|
-
spec_resources/helpers/addition_helper.rb
|
110
|
-
spec_resources/helpers/explicit_helper.rb
|
111
|
-
spec_resources/helpers/more_explicit_helper.rb
|
112
|
-
spec_resources/helpers/plugin_application_helper.rb
|
113
|
-
spec_resources/helpers/view_spec_helper.rb
|
114
|
-
spec_resources/views/controller_spec/_partial.rhtml
|
115
|
-
spec_resources/views/controller_spec/action_setting_flash_after_session_reset.rhtml
|
116
|
-
spec_resources/views/controller_spec/action_setting_flash_before_session_reset.rhtml
|
117
|
-
spec_resources/views/controller_spec/action_setting_the_assigns_hash.rhtml
|
118
|
-
spec_resources/views/controller_spec/action_with_errors_in_template.rhtml
|
119
|
-
spec_resources/views/controller_spec/action_with_template.rhtml
|
120
|
-
spec_resources/views/layouts/application.rhtml
|
121
|
-
spec_resources/views/layouts/simple.rhtml
|
122
|
-
spec_resources/views/objects/_object.html.erb
|
123
|
-
spec_resources/views/render_spec/_a_partial.rhtml
|
124
|
-
spec_resources/views/render_spec/action_with_alternate_layout.rhtml
|
125
|
-
spec_resources/views/render_spec/some_action.js.rjs
|
126
|
-
spec_resources/views/render_spec/some_action.rhtml
|
127
|
-
spec_resources/views/render_spec/some_action.rjs
|
128
|
-
spec_resources/views/rjs_spec/_replacement_partial.rhtml
|
129
|
-
spec_resources/views/rjs_spec/hide_div.rjs
|
130
|
-
spec_resources/views/rjs_spec/hide_page_element.rjs
|
131
|
-
spec_resources/views/rjs_spec/insert_html.rjs
|
132
|
-
spec_resources/views/rjs_spec/replace.rjs
|
133
|
-
spec_resources/views/rjs_spec/replace_html.rjs
|
134
|
-
spec_resources/views/rjs_spec/replace_html_with_partial.rjs
|
135
|
-
spec_resources/views/rjs_spec/visual_effect.rjs
|
136
|
-
spec_resources/views/rjs_spec/visual_toggle_effect.rjs
|
137
|
-
spec_resources/views/tag_spec/no_tags.rhtml
|
138
|
-
spec_resources/views/tag_spec/single_div_with_no_attributes.rhtml
|
139
|
-
spec_resources/views/tag_spec/single_div_with_one_attribute.rhtml
|
140
|
-
spec_resources/views/view_spec/_partial.rhtml
|
141
|
-
spec_resources/views/view_spec/_partial_used_twice.rhtml
|
142
|
-
spec_resources/views/view_spec/_partial_with_local_variable.rhtml
|
143
|
-
spec_resources/views/view_spec/_partial_with_sub_partial.rhtml
|
144
|
-
spec_resources/views/view_spec/_spacer.rhtml
|
145
|
-
spec_resources/views/view_spec/accessor.rhtml
|
146
|
-
spec_resources/views/view_spec/block_helper.rhtml
|
147
|
-
spec_resources/views/view_spec/entry_form.rhtml
|
148
|
-
spec_resources/views/view_spec/explicit_helper.rhtml
|
149
|
-
spec_resources/views/view_spec/foo/show.rhtml
|
150
|
-
spec_resources/views/view_spec/implicit_helper.rhtml
|
151
|
-
spec_resources/views/view_spec/multiple_helpers.rhtml
|
152
|
-
spec_resources/views/view_spec/should_not_receive.rhtml
|
153
|
-
spec_resources/views/view_spec/template_with_partial.rhtml
|
154
|
-
spec_resources/views/view_spec/template_with_partial_using_collection.rhtml
|
155
|
-
spec_resources/views/view_spec/template_with_partial_with_array.rhtml
|
156
156
|
stories/all.rb
|
157
157
|
stories/configuration/stories.rb
|
158
158
|
stories/helper.rb
|
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ Hoe.new('rspec-rails', Spec::Rails::VERSION::STRING) do |p|
|
|
15
15
|
p.description = "Behaviour Driven Development for Ruby on Rails."
|
16
16
|
p.rubyforge_name = 'rspec'
|
17
17
|
p.developer('RSpec Development Team', 'rspec-devel@rubyforge.org')
|
18
|
-
p.extra_deps = [["rspec","1.1.11"]]
|
18
|
+
p.extra_deps = [["rspec","1.1.11.1"]]
|
19
19
|
p.remote_rdoc_dir = "rspec-rails/#{Spec::Rails::VERSION::STRING}"
|
20
20
|
end
|
21
21
|
|
@@ -6,127 +6,148 @@ raise "To avoid rake task loading problems: run 'rake clobber' in vendor/plugins
|
|
6
6
|
# it if it is. If not, use the gem version.
|
7
7
|
rspec_base = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec/lib')
|
8
8
|
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
|
9
|
-
require 'spec/rake/spectask'
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
begin
|
11
|
+
require 'spec/rake/spectask'
|
12
|
+
Rake.application.instance_variable_get('@tasks').delete('default')
|
14
13
|
|
15
|
-
|
16
|
-
task :
|
14
|
+
spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
|
15
|
+
task :noop do
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
21
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
22
|
-
end
|
18
|
+
task :default => :spec
|
19
|
+
task :stats => "spec:statsetup"
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
Spec::Rake::SpecTask.new(:rcov) do |t|
|
21
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
22
|
+
Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
|
27
23
|
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
28
24
|
t.spec_files = FileList['spec/**/*_spec.rb']
|
29
|
-
t.rcov = true
|
30
|
-
t.rcov_opts = lambda do
|
31
|
-
IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
desc "Print Specdoc for all specs (excluding plugin specs)"
|
36
|
-
Spec::Rake::SpecTask.new(:doc) do |t|
|
37
|
-
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
38
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
39
|
-
end
|
40
|
-
|
41
|
-
desc "Print Specdoc for all plugin specs"
|
42
|
-
Spec::Rake::SpecTask.new(:plugin_doc) do |t|
|
43
|
-
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
44
|
-
t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*')
|
45
25
|
end
|
46
26
|
|
47
|
-
|
48
|
-
desc "Run
|
49
|
-
Spec::Rake::SpecTask.new(
|
27
|
+
namespace :spec do
|
28
|
+
desc "Run all specs in spec directory with RCov (excluding plugin specs)"
|
29
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
50
30
|
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
51
|
-
t.spec_files = FileList[
|
31
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
32
|
+
t.rcov = true
|
33
|
+
t.rcov_opts = lambda do
|
34
|
+
IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
35
|
+
end
|
52
36
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
|
59
|
-
end
|
60
|
-
|
61
|
-
namespace :plugins do
|
62
|
-
desc "Runs the examples for rspec_on_rails"
|
63
|
-
Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
|
64
|
-
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
65
|
-
t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb']
|
37
|
+
|
38
|
+
desc "Print Specdoc for all specs (excluding plugin specs)"
|
39
|
+
Spec::Rake::SpecTask.new(:doc) do |t|
|
40
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
41
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
66
42
|
end
|
67
|
-
end
|
68
43
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
|
75
|
-
::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
|
76
|
-
::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
|
77
|
-
::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
|
78
|
-
::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
|
79
|
-
::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
|
80
|
-
::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
|
81
|
-
::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
|
82
|
-
::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
|
83
|
-
end
|
44
|
+
desc "Print Specdoc for all plugin examples"
|
45
|
+
Spec::Rake::SpecTask.new(:plugin_doc) do |t|
|
46
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
47
|
+
t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*')
|
48
|
+
end
|
84
49
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
91
|
-
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
92
|
-
Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
|
93
|
-
end
|
50
|
+
[:models, :controllers, :views, :helpers, :lib].each do |sub|
|
51
|
+
desc "Run the code examples in spec/#{sub}"
|
52
|
+
Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
|
53
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
54
|
+
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
94
55
|
end
|
95
56
|
end
|
96
|
-
end
|
97
57
|
|
98
|
-
|
99
|
-
|
58
|
+
desc "Run the code examples in vendor/plugins (except RSpec's own)"
|
59
|
+
Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
|
60
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
61
|
+
t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
|
62
|
+
end
|
100
63
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
$stderr.puts "Starting up spec server."
|
107
|
-
system("ruby", "script/spec_server", "--daemon", "--pid", daemonized_server_pid)
|
64
|
+
namespace :plugins do
|
65
|
+
desc "Runs the examples for rspec_on_rails"
|
66
|
+
Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
|
67
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
68
|
+
t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb']
|
108
69
|
end
|
109
70
|
end
|
110
71
|
|
111
|
-
|
112
|
-
task :
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
72
|
+
# Setup specs for stats
|
73
|
+
task :statsetup do
|
74
|
+
require 'code_statistics'
|
75
|
+
::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
|
76
|
+
::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
|
77
|
+
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
|
78
|
+
::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
|
79
|
+
::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
|
80
|
+
::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
|
81
|
+
::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
|
82
|
+
::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
|
83
|
+
::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
|
84
|
+
::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
|
85
|
+
::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
|
86
|
+
end
|
87
|
+
|
88
|
+
namespace :db do
|
89
|
+
namespace :fixtures do
|
90
|
+
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
91
|
+
task :load => :environment do
|
92
|
+
require 'active_record/fixtures'
|
93
|
+
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
94
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
95
|
+
Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
|
96
|
+
end
|
97
|
+
end
|
119
98
|
end
|
120
99
|
end
|
121
100
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
101
|
+
namespace :server do
|
102
|
+
daemonized_server_pid = File.expand_path("spec_server.pid", RAILS_ROOT + "/tmp")
|
103
|
+
|
104
|
+
desc "start spec_server."
|
105
|
+
task :start do
|
106
|
+
if File.exist?(daemonized_server_pid)
|
107
|
+
$stderr.puts "spec_server is already running."
|
108
|
+
else
|
109
|
+
$stderr.puts "Starting up spec server."
|
110
|
+
system("ruby", "script/spec_server", "--daemon", "--pid", daemonized_server_pid)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
desc "stop spec_server."
|
115
|
+
task :stop do
|
116
|
+
unless File.exist?(daemonized_server_pid)
|
117
|
+
$stderr.puts "No server running."
|
118
|
+
else
|
119
|
+
$stderr.puts "Shutting down spec_server."
|
120
|
+
system("kill", "-s", "TERM", File.read(daemonized_server_pid).strip) &&
|
121
|
+
File.delete(daemonized_server_pid)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
desc "reload spec_server."
|
126
|
+
task :restart do
|
127
|
+
unless File.exist?(daemonized_server_pid)
|
128
|
+
$stderr.puts "No server running."
|
129
|
+
else
|
130
|
+
$stderr.puts "Reloading down spec_server."
|
131
|
+
system("kill", "-s", "USR2", File.read(daemonized_server_pid).strip)
|
132
|
+
end
|
129
133
|
end
|
130
134
|
end
|
131
135
|
end
|
136
|
+
rescue MissingSourceFile
|
137
|
+
# if rspec-rails is a configured gem, this will output helpful material and exit ...
|
138
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
|
139
|
+
|
140
|
+
# ... otherwise, do this:
|
141
|
+
raise <<-MSG
|
142
|
+
|
143
|
+
You have rspec-rails rake tasks installed in
|
144
|
+
#{__FILE__},
|
145
|
+
but rspec-rails is not configured as a gem in
|
146
|
+
config/environment.rb
|
147
|
+
|
148
|
+
Either remove #{__FILE__}
|
149
|
+
or configure the rspec-rails gem in config/environment.rb.
|
150
|
+
|
151
|
+
MSG
|
132
152
|
end
|
153
|
+
|
@@ -1,14 +1,15 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
|
2
2
|
|
3
|
+
<% output_attributes = attributes.reject{|attribute| attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
|
3
4
|
describe "/<%= table_name %>/edit.<%= default_file_extension %>" do
|
4
5
|
include <%= controller_class_name %>Helper
|
5
6
|
|
6
7
|
before(:each) do
|
7
8
|
assigns[:<%= file_name %>] = @<%= file_name %> = stub_model(<%= class_name %>,
|
8
|
-
:new_record? => false<%=
|
9
|
-
<%
|
10
|
-
:<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index ==
|
11
|
-
<% end
|
9
|
+
:new_record? => false<%= output_attributes.empty? ? '' : ',' %>
|
10
|
+
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
|
11
|
+
:<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
|
12
|
+
<% end -%>
|
12
13
|
)
|
13
14
|
end
|
14
15
|
|
@@ -16,9 +17,9 @@ describe "/<%= table_name %>/edit.<%= default_file_extension %>" do
|
|
16
17
|
render "/<%= table_name %>/edit.<%= default_file_extension %>"
|
17
18
|
|
18
19
|
response.should have_tag("form[action=#{<%= file_name %>_path(@<%= file_name %>)}][method=post]") do
|
19
|
-
<% for attribute in
|
20
|
+
<% for attribute in output_attributes -%>
|
20
21
|
with_tag('<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>[name=?]', "<%= file_name %>[<%= attribute.name %>]")
|
21
|
-
<% end
|
22
|
+
<% end -%>
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -1,16 +1,17 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
|
2
2
|
|
3
|
+
<% output_attributes = attributes.reject{|attribute| attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
|
3
4
|
describe "/<%= table_name %>/index.<%= default_file_extension %>" do
|
4
5
|
include <%= controller_class_name %>Helper
|
5
6
|
|
6
7
|
before(:each) do
|
7
8
|
assigns[:<%= table_name %>] = [
|
8
9
|
<% [1,2].each_with_index do |id, model_index| -%>
|
9
|
-
stub_model(<%= class_name %><%=
|
10
|
-
<%
|
11
|
-
:<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index ==
|
12
|
-
<% end
|
13
|
-
<% if !
|
10
|
+
stub_model(<%= class_name %><%= output_attributes.empty? ? (model_index == 1 ? ')' : '),') : ',' %>
|
11
|
+
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
|
12
|
+
:<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
|
13
|
+
<% end -%>
|
14
|
+
<% if !output_attributes.empty? -%>
|
14
15
|
<%= model_index == 1 ? ')' : '),' %>
|
15
16
|
<% end -%>
|
16
17
|
<% end -%>
|
@@ -19,9 +20,9 @@ describe "/<%= table_name %>/index.<%= default_file_extension %>" do
|
|
19
20
|
|
20
21
|
it "should render list of <%= table_name %>" do
|
21
22
|
render "/<%= table_name %>/index.<%= default_file_extension %>"
|
22
|
-
<% for attribute in
|
23
|
+
<% for attribute in output_attributes -%>
|
23
24
|
response.should have_tag("tr>td", <%= attribute.default_value %>, 2)
|
24
|
-
<% end
|
25
|
+
<% end -%>
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
@@ -1,14 +1,15 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
|
2
2
|
|
3
|
+
<% output_attributes = attributes.reject{|attribute| attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
|
3
4
|
describe "/<%= table_name %>/new.<%= default_file_extension %>" do
|
4
5
|
include <%= controller_class_name %>Helper
|
5
6
|
|
6
7
|
before(:each) do
|
7
8
|
assigns[:<%= file_name %>] = stub_model(<%= class_name %>,
|
8
|
-
:new_record? => true<%=
|
9
|
-
<%
|
10
|
-
:<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index ==
|
11
|
-
<% end
|
9
|
+
:new_record? => true<%= output_attributes.empty? ? '' : ',' %>
|
10
|
+
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
|
11
|
+
:<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
|
12
|
+
<% end -%>
|
12
13
|
)
|
13
14
|
end
|
14
15
|
|
@@ -16,9 +17,9 @@ describe "/<%= table_name %>/new.<%= default_file_extension %>" do
|
|
16
17
|
render "/<%= table_name %>/new.<%= default_file_extension %>"
|
17
18
|
|
18
19
|
response.should have_tag("form[action=?][method=post]", <%= table_name %>_path) do
|
19
|
-
<% for attribute in
|
20
|
+
<% for attribute in output_attributes -%>
|
20
21
|
with_tag("<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>[name=?]", "<%= file_name %>[<%= attribute.name %>]")
|
21
|
-
<% end
|
22
|
+
<% end -%>
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -1,23 +1,23 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
|
2
2
|
|
3
|
+
<% output_attributes = attributes.reject{|attribute| attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
|
3
4
|
describe "/<%= table_name %>/show.<%= default_file_extension %>" do
|
4
5
|
include <%= controller_class_name %>Helper
|
5
|
-
|
6
6
|
before(:each) do
|
7
|
-
assigns[:<%= file_name %>] = @<%= file_name %> = stub_model(<%= class_name %><%=
|
8
|
-
<%
|
9
|
-
:<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index ==
|
10
|
-
<% end
|
11
|
-
<% if !
|
7
|
+
assigns[:<%= file_name %>] = @<%= file_name %> = stub_model(<%= class_name %><%= output_attributes.empty? ? ')' : ',' %>
|
8
|
+
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
|
9
|
+
:<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
|
10
|
+
<% end -%>
|
11
|
+
<% if !output_attributes.empty? -%>
|
12
12
|
)
|
13
13
|
<% end -%>
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should render attributes in <p>" do
|
17
17
|
render "/<%= table_name %>/show.<%= default_file_extension %>"
|
18
|
-
<% for attribute in
|
18
|
+
<% for attribute in output_attributes -%>
|
19
19
|
response.should have_text(/<%= Regexp.escape(attribute.default_value)[1..-2]%>/)
|
20
|
-
<% end
|
20
|
+
<% end -%>
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -247,8 +247,11 @@ module Spec
|
|
247
247
|
Spec::Example::ExampleGroupFactory.register(:controller, self)
|
248
248
|
end
|
249
249
|
|
250
|
-
|
250
|
+
# Returned by _pick_template when running controller examples in isolation mode.
|
251
|
+
class PickedTemplate
|
252
|
+
# Do nothing when running controller examples in isolation mode.
|
251
253
|
def render_template(*ignore_args); end
|
254
|
+
# Do nothing when running controller examples in isolation mode.
|
252
255
|
def render_partial(*ignore_args); end
|
253
256
|
end
|
254
257
|
end
|
@@ -103,11 +103,11 @@ module Spec
|
|
103
103
|
add_helpers(options)
|
104
104
|
|
105
105
|
assigns[:action_name] = @action_name
|
106
|
-
|
107
|
-
@request.path_parameters =
|
108
|
-
|
109
|
-
|
110
|
-
}
|
106
|
+
|
107
|
+
@request.path_parameters = @request.path_parameters.merge(
|
108
|
+
:controller => derived_controller_name(options),
|
109
|
+
:action => derived_action_name(options)
|
110
|
+
).merge(options[:path_parameters] || {})
|
111
111
|
|
112
112
|
defaults = { :layout => false }
|
113
113
|
options = defaults.merge options
|
@@ -2,6 +2,8 @@ module ActionView #:nodoc:
|
|
2
2
|
class Base #:nodoc:
|
3
3
|
include Spec::Rails::Example::RenderObserver
|
4
4
|
cattr_accessor :base_view_path
|
5
|
+
|
6
|
+
alias_method :orig_render_partial, :render_partial
|
5
7
|
def render_partial(partial_path, local_assigns = nil, deprecated_local_assigns = nil) #:nodoc:
|
6
8
|
if partial_path.is_a?(String)
|
7
9
|
unless partial_path.include?("/")
|
@@ -11,9 +13,9 @@ module ActionView #:nodoc:
|
|
11
13
|
end
|
12
14
|
end
|
13
15
|
begin
|
14
|
-
|
16
|
+
orig_render_partial(partial_path, local_assigns, deprecated_local_assigns)
|
15
17
|
rescue ArgumentError # edge rails > 2.1 changed render_partial to accept only one arg
|
16
|
-
|
18
|
+
orig_render_partial(partial_path)
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
@@ -53,16 +53,25 @@ module Spec
|
|
53
53
|
end
|
54
54
|
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
# :call-seq:
|
58
|
-
# response.should render_template(
|
59
|
-
# response.should_not render_template(
|
58
|
+
# response.should render_template(template)
|
59
|
+
# response.should_not render_template(template)
|
60
|
+
#
|
61
|
+
# For use in controller code examples (integration or isolation mode).
|
62
|
+
#
|
63
|
+
# Passes if the specified template (view file) is rendered by the
|
64
|
+
# response. This file can be any view file, including a partial. However
|
65
|
+
# if it is a partial it must be rendered directly i.e. you can't detect
|
66
|
+
# that a partial has been rendered as part of a view using
|
67
|
+
# render_template. For that you should use a message expectation
|
68
|
+
# (mock) instead:
|
60
69
|
#
|
61
|
-
#
|
62
|
-
# Useful in controller specs (integration or isolation mode).
|
70
|
+
# controller.should_receive(:render).with(:partial => 'path/to/partial')
|
63
71
|
#
|
64
|
-
# <code>
|
65
|
-
#
|
72
|
+
# <code>template</code> can include the controller path. It can also
|
73
|
+
# include an optional extension, which you only need to use when there
|
74
|
+
# is ambiguity.
|
66
75
|
#
|
67
76
|
# Note that partials must be spelled with the preceding underscore.
|
68
77
|
#
|
@@ -72,12 +81,13 @@ module Spec
|
|
72
81
|
# response.should render_template('same_controller/list')
|
73
82
|
# response.should render_template('other_controller/list')
|
74
83
|
#
|
75
|
-
# #
|
84
|
+
# # with extensions
|
76
85
|
# response.should render_template('list.rjs')
|
86
|
+
# response.should render_template('list.haml')
|
77
87
|
# response.should render_template('same_controller/list.rjs')
|
78
88
|
# response.should render_template('other_controller/list.rjs')
|
79
89
|
#
|
80
|
-
# #partials
|
90
|
+
# # partials
|
81
91
|
# response.should render_template('_a_partial')
|
82
92
|
# response.should render_template('same_controller/_a_partial')
|
83
93
|
# response.should render_template('other_controller/_a_partial')
|