rspec-rails 1.3.4 → 2.0.0.a2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -7
- data/README.markdown +58 -0
- data/Rakefile +51 -9
- data/example_app_template.rb +33 -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 +15 -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 +14 -0
- data/lib/generators/rspec/install/install_generator.rb +29 -0
- data/lib/generators/rspec/install/templates/lib/tasks/rspec.rake +119 -0
- data/lib/generators/rspec/install/templates/script/rspec.tt +4 -0
- data/{generators/rspec/templates → lib/generators/rspec/install/templates/spec}/rcov.opts +0 -0
- data/{generators/rspec/templates → lib/generators/rspec/install/templates/spec}/spec.opts +0 -0
- data/{generators/rspec/templates → lib/generators/rspec/install/templates/spec}/spec_helper.rb +14 -12
- data/lib/generators/rspec/integration/integration_generator.rb +12 -0
- data/{generators/integration_spec/templates/integration_spec.rb → lib/generators/rspec/integration/templates/request_spec.rb} +0 -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/{generators/rspec_model → lib/generators/rspec/model}/templates/model_spec.rb +1 -1
- 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/{generators/rspec_scaffold/templates/edit_erb_spec.rb → lib/generators/rspec/scaffold/templates/edit_spec.rb} +3 -3
- data/{generators/rspec_scaffold/templates/index_erb_spec.rb → lib/generators/rspec/scaffold/templates/index_spec.rb} +4 -4
- data/{generators/rspec_scaffold/templates/new_erb_spec.rb → lib/generators/rspec/scaffold/templates/new_spec.rb} +3 -3
- data/{generators/rspec_scaffold → lib/generators/rspec/scaffold}/templates/routing_spec.rb +4 -0
- data/{generators/rspec_scaffold/templates/show_erb_spec.rb → lib/generators/rspec/scaffold/templates/show_spec.rb} +4 -4
- data/lib/rspec/rails.rb +2 -0
- data/lib/rspec/rails/example.rb +2 -0
- data/lib/rspec/rails/example/controller_example_group.rb +31 -0
- data/lib/rspec/rails/example/request_example_group.rb +26 -0
- data/lib/rspec/rails/matchers.rb +14 -0
- data/lib/rspec/rails/transactional_database_support.rb +38 -0
- data/lib/rspec/rails/version.rb +16 -0
- data/rspec-rails.gemspec +78 -18
- metadata +97 -321
- data/.document +0 -7
- data/Contribute.rdoc +0 -4
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -27
- data/History.rdoc +0 -321
- data/License.txt +0 -33
- data/Manifest.txt +0 -165
- data/README.rdoc +0 -48
- data/TODO.txt +0 -17
- data/Upgrade.rdoc +0 -148
- data/generators/integration_spec/integration_spec_generator.rb +0 -10
- data/generators/rspec/CHANGES +0 -1
- data/generators/rspec/rspec_generator.rb +0 -72
- data/generators/rspec/templates/previous_failures.txt +0 -0
- data/generators/rspec/templates/rspec.rake +0 -144
- data/generators/rspec/templates/script/autospec +0 -6
- data/generators/rspec/templates/script/spec +0 -10
- data/generators/rspec_controller/USAGE +0 -33
- data/generators/rspec_controller/rspec_controller_generator.rb +0 -47
- data/generators/rspec_controller/templates/controller_spec.rb +0 -25
- data/generators/rspec_controller/templates/helper_spec.rb +0 -11
- data/generators/rspec_controller/templates/view_spec.rb +0 -12
- data/generators/rspec_default_values.rb +0 -28
- data/generators/rspec_model/USAGE +0 -18
- data/generators/rspec_model/rspec_model_generator.rb +0 -35
- data/generators/rspec_scaffold/rspec_scaffold_generator.rb +0 -154
- data/generators/rspec_scaffold/templates/controller_spec.rb +0 -131
- data/generators/rspec_scaffold/templates/helper_spec.rb +0 -11
- data/init.rb +0 -9
- data/lib/autotest/discover.rb +0 -5
- data/lib/autotest/rails_rspec.rb +0 -76
- data/lib/spec/rails.rb +0 -26
- data/lib/spec/rails/example.rb +0 -48
- data/lib/spec/rails/example/assigns_hash_proxy.rb +0 -39
- data/lib/spec/rails/example/controller_example_group.rb +0 -285
- data/lib/spec/rails/example/cookies_proxy.rb +0 -29
- data/lib/spec/rails/example/functional_example_group.rb +0 -106
- data/lib/spec/rails/example/helper_example_group.rb +0 -153
- data/lib/spec/rails/example/integration_example_group.rb +0 -16
- data/lib/spec/rails/example/model_example_group.rb +0 -15
- data/lib/spec/rails/example/render_observer.rb +0 -80
- data/lib/spec/rails/example/routing_example_group.rb +0 -16
- data/lib/spec/rails/example/routing_helpers.rb +0 -66
- data/lib/spec/rails/example/view_example_group.rb +0 -203
- data/lib/spec/rails/extensions.rb +0 -11
- data/lib/spec/rails/extensions/action_controller/rescue.rb +0 -42
- data/lib/spec/rails/extensions/action_controller/test_case.rb +0 -16
- data/lib/spec/rails/extensions/action_controller/test_response.rb +0 -21
- data/lib/spec/rails/extensions/action_view/base.rb +0 -35
- data/lib/spec/rails/extensions/active_record/base.rb +0 -45
- data/lib/spec/rails/extensions/active_support/test_case.rb +0 -7
- data/lib/spec/rails/extensions/spec/matchers/have.rb +0 -23
- data/lib/spec/rails/extensions/spec/runner/configuration.rb +0 -45
- data/lib/spec/rails/interop/testcase.rb +0 -14
- data/lib/spec/rails/matchers.rb +0 -32
- data/lib/spec/rails/matchers/ar_be_valid.rb +0 -27
- data/lib/spec/rails/matchers/assert_select.rb +0 -180
- data/lib/spec/rails/matchers/change.rb +0 -13
- data/lib/spec/rails/matchers/have_text.rb +0 -57
- data/lib/spec/rails/matchers/include_text.rb +0 -54
- data/lib/spec/rails/matchers/redirect_to.rb +0 -126
- data/lib/spec/rails/matchers/render_template.rb +0 -129
- data/lib/spec/rails/matchers/route_to.rb +0 -149
- data/lib/spec/rails/mocks.rb +0 -140
- data/lib/spec/rails/version.rb +0 -16
- data/spec/autotest/mappings_spec.rb +0 -86
- data/spec/rails_suite.rb +0 -7
- data/spec/resources/controllers/action_view_base_spec_controller.rb +0 -2
- data/spec/resources/controllers/application.rb +0 -9
- data/spec/resources/controllers/controller_spec_controller.rb +0 -127
- data/spec/resources/controllers/example.txt +0 -1
- data/spec/resources/controllers/redirect_spec_controller.rb +0 -70
- data/spec/resources/controllers/render_spec_controller.rb +0 -34
- data/spec/resources/controllers/rjs_spec_controller.rb +0 -58
- data/spec/resources/helpers/addition_helper.rb +0 -5
- data/spec/resources/helpers/explicit_helper.rb +0 -46
- data/spec/resources/helpers/more_explicit_helper.rb +0 -5
- data/spec/resources/helpers/plugin_application_helper.rb +0 -6
- data/spec/resources/helpers/view_spec_helper.rb +0 -13
- data/spec/resources/models/animal.rb +0 -4
- data/spec/resources/models/person.rb +0 -18
- data/spec/resources/models/thing.rb +0 -3
- data/spec/resources/views/controller_spec/_partial.html.erb +0 -0
- data/spec/resources/views/controller_spec/action_setting_flash_after_session_reset.html.erb +0 -1
- data/spec/resources/views/controller_spec/action_setting_flash_before_session_reset.html.erb +0 -1
- data/spec/resources/views/controller_spec/action_setting_the_assigns_hash.html.erb +0 -0
- data/spec/resources/views/controller_spec/action_with_errors_in_template.html.erb +0 -1
- data/spec/resources/views/controller_spec/action_with_template.html.erb +0 -1
- data/spec/resources/views/controller_spec/non_existent_action_with_existent_template.html.erb +0 -1
- data/spec/resources/views/layouts/application.html.erb +0 -0
- data/spec/resources/views/layouts/simple.html.erb +0 -0
- data/spec/resources/views/objects/_object.html.erb +0 -1
- data/spec/resources/views/render_spec/_a_partial.html.erb +0 -0
- data/spec/resources/views/render_spec/action_with_alternate_layout.html.erb +0 -0
- data/spec/resources/views/render_spec/some_action.html.erb +0 -0
- data/spec/resources/views/render_spec/some_action.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/_replacement_partial.html.erb +0 -1
- data/spec/resources/views/rjs_spec/hide_div.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/hide_page_element.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/insert_html.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/replace.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/replace_html.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/replace_html_with_partial.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/visual_effect.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/visual_toggle_effect.js.rjs +0 -1
- data/spec/resources/views/tag_spec/no_tags.html.erb +0 -1
- data/spec/resources/views/tag_spec/single_div_with_no_attributes.html.erb +0 -1
- data/spec/resources/views/tag_spec/single_div_with_one_attribute.html.erb +0 -1
- data/spec/resources/views/view_spec/_partial.html.erb +0 -2
- data/spec/resources/views/view_spec/_partial_used_twice.html.erb +0 -0
- data/spec/resources/views/view_spec/_partial_with_local_variable.html.erb +0 -1
- data/spec/resources/views/view_spec/_partial_with_sub_partial.html.erb +0 -1
- data/spec/resources/views/view_spec/_spacer.html.erb +0 -1
- data/spec/resources/views/view_spec/accessor.html.erb +0 -6
- data/spec/resources/views/view_spec/block_helper.html.erb +0 -3
- data/spec/resources/views/view_spec/entry_form.html.erb +0 -2
- data/spec/resources/views/view_spec/explicit_helper.html.erb +0 -2
- data/spec/resources/views/view_spec/foo/show.html.erb +0 -1
- data/spec/resources/views/view_spec/implicit_helper.html.erb +0 -2
- data/spec/resources/views/view_spec/multiple_helpers.html.erb +0 -3
- data/spec/resources/views/view_spec/path_params.html.erb +0 -1
- data/spec/resources/views/view_spec/should_not_receive.html.erb +0 -3
- data/spec/resources/views/view_spec/template_with_partial.html.erb +0 -5
- data/spec/resources/views/view_spec/template_with_partial_using_collection.html.erb +0 -3
- data/spec/resources/views/view_spec/template_with_partial_with_array.html.erb +0 -1
- data/spec/resources/views/view_spec/view_helpers.html.erb +0 -1
- data/spec/spec/rails/example/assigns_hash_proxy_spec.rb +0 -109
- data/spec/spec/rails/example/configuration_spec.rb +0 -67
- data/spec/spec/rails/example/controller_example_group_spec.rb +0 -307
- data/spec/spec/rails/example/controller_isolation_spec.rb +0 -75
- data/spec/spec/rails/example/cookies_proxy_spec.rb +0 -87
- data/spec/spec/rails/example/error_handling_spec.rb +0 -90
- data/spec/spec/rails/example/example_group_factory_spec.rb +0 -112
- data/spec/spec/rails/example/helper_example_group_spec.rb +0 -247
- data/spec/spec/rails/example/model_example_group_spec.rb +0 -32
- data/spec/spec/rails/example/routing_example_group_spec.rb +0 -9
- data/spec/spec/rails/example/shared_routing_example_group_examples.rb +0 -237
- data/spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb +0 -33
- data/spec/spec/rails/example/view_example_group_spec.rb +0 -346
- data/spec/spec/rails/extensions/action_view_base_spec.rb +0 -79
- data/spec/spec/rails/extensions/active_record_spec.rb +0 -14
- data/spec/spec/rails/interop/testcase_spec.rb +0 -70
- data/spec/spec/rails/matchers/ar_be_valid_spec.rb +0 -19
- data/spec/spec/rails/matchers/assert_select_spec.rb +0 -835
- data/spec/spec/rails/matchers/errors_on_spec.rb +0 -37
- data/spec/spec/rails/matchers/have_text_spec.rb +0 -69
- data/spec/spec/rails/matchers/include_text_spec.rb +0 -62
- data/spec/spec/rails/matchers/redirect_to_spec.rb +0 -253
- data/spec/spec/rails/matchers/render_template_spec.rb +0 -208
- data/spec/spec/rails/matchers/should_change_spec.rb +0 -15
- data/spec/spec/rails/mocks/ar_classes.rb +0 -10
- data/spec/spec/rails/mocks/mock_model_spec.rb +0 -112
- data/spec/spec/rails/mocks/stub_model_spec.rb +0 -80
- data/spec/spec/rails/sample_modified_fixture.rb +0 -8
- data/spec/spec/rails/sample_spec.rb +0 -8
- data/spec/spec/rails/spec_spec.rb +0 -11
- data/spec/spec_helper.rb +0 -78
data/.gitignore
CHANGED
data/README.markdown
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
RSpec-2 for Rails-3
|
2
|
+
|
3
|
+
### Backwards compatibility
|
4
|
+
|
5
|
+
None. This is a rewrite of the rspec-rails extension designed to work
|
6
|
+
with rails-3.x and rspec-2.x. It will not work with older versions of
|
7
|
+
either rspec or rails.
|
8
|
+
|
9
|
+
### Current state
|
10
|
+
|
11
|
+
Currently in super-pre-alpha state - explore at your own risk!
|
12
|
+
|
13
|
+
Install:
|
14
|
+
|
15
|
+
git clone git://github.com/rspec/rspec-dev
|
16
|
+
cd rspec-dev
|
17
|
+
rake git:clone
|
18
|
+
rake gem:build
|
19
|
+
rake gem:install
|
20
|
+
|
21
|
+
This installs the following gems:
|
22
|
+
|
23
|
+
* rspec
|
24
|
+
* rspec-core
|
25
|
+
* rspec-expectations
|
26
|
+
* rspec-mocks
|
27
|
+
* rspec-rails
|
28
|
+
|
29
|
+
### What works
|
30
|
+
|
31
|
+
Currently supported:
|
32
|
+
|
33
|
+
* controller specs in spec/controllers
|
34
|
+
* no view isolation yet
|
35
|
+
* model specs in spec/models
|
36
|
+
* request specs in spec/requests
|
37
|
+
* these wrap rails integration tests
|
38
|
+
* rails assertions
|
39
|
+
* webrat matchers
|
40
|
+
* rails-specific matchers
|
41
|
+
* response.should redirect_to(...)
|
42
|
+
* wraps assert_redirected_to
|
43
|
+
* only works with should (not should_not)
|
44
|
+
* generators
|
45
|
+
* borrowed from José Valim's third_rails repo on github
|
46
|
+
* the generators work, but not all the generated specs
|
47
|
+
work yet :(
|
48
|
+
|
49
|
+
### Known issues
|
50
|
+
|
51
|
+
None (or very little) of the following are supported yet (but will be soon):
|
52
|
+
|
53
|
+
* rails-specific matchers
|
54
|
+
* only supports "response.should redirect_to(..)"
|
55
|
+
* isolation from views in controller specs
|
56
|
+
* view specs
|
57
|
+
* helper specs
|
58
|
+
* routing specs
|
data/Rakefile
CHANGED
@@ -1,14 +1,56 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'jeweler', '>= 1.4.0'
|
3
|
+
require 'rake'
|
4
|
+
require 'yaml'
|
3
5
|
|
4
|
-
$:.unshift
|
5
|
-
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__),"lib")))
|
6
|
+
$:.unshift File.expand_path(File.join(File.dirname(__FILE__),'lib'))
|
6
7
|
|
7
|
-
require '
|
8
|
-
require '
|
9
|
-
require 'cucumber/rake/task'
|
8
|
+
require 'rake/rdoctask'
|
9
|
+
require 'rspec/rails/version'
|
10
10
|
|
11
|
-
|
11
|
+
begin
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
gem.name = "rspec-rails"
|
15
|
+
gem.version = Rspec::Rails::Version::STRING
|
16
|
+
gem.summary = "Rspec-2 for Rails-3"
|
17
|
+
gem.email = "dchelimsky@gmail.com;chad.humphries@gmail.com"
|
18
|
+
gem.homepage = "http://github.com/rspec/rspec-rails"
|
19
|
+
gem.authors = ["David Chelimsky", "Chad Humphries"]
|
20
|
+
gem.add_dependency "rspec", ">= #{Rspec::Rails::Version::STRING}"
|
21
|
+
gem.add_dependency "webrat", "0.7.0"
|
22
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
23
|
+
end
|
24
|
+
Jeweler::GemcutterTasks.new
|
25
|
+
rescue LoadError
|
26
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
27
|
+
end
|
12
28
|
|
13
|
-
|
29
|
+
|
30
|
+
desc 'create app, generate a bunch of stuff, and run rake spec'
|
31
|
+
task :create_app do |t|
|
32
|
+
if File.directory?('./tmp/rails')
|
33
|
+
rm_rf "tmp/example_app"
|
34
|
+
ruby "./tmp/rails/railties/bin/rails tmp/example_app --dev -m example_app_template.rb"
|
35
|
+
else
|
36
|
+
puts <<-MESSAGE
|
37
|
+
|
38
|
+
You need to install rails in ./tmp/rails before you can run the
|
39
|
+
#{t.name} task:
|
40
|
+
|
41
|
+
git clone git://github.com/rails/rails tmp/rails
|
42
|
+
|
43
|
+
(We'll automate this eventually, but running 'git clone' from rake in this
|
44
|
+
project is mysteriously full of fail)
|
45
|
+
|
46
|
+
MESSAGE
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
desc 'clobber generated files'
|
51
|
+
task :clobber do
|
52
|
+
rm_rf "pkg"
|
53
|
+
end
|
54
|
+
|
55
|
+
task :default => :create_app
|
14
56
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../../lib', __FILE__))
|
2
|
+
require 'rspec/rails/version'
|
3
|
+
# This needs to be installed on the system, as well as all of its rspec-2 deps
|
4
|
+
# - would be nicer if we could source them from the <repo>/pkg dirs
|
5
|
+
gem 'rspec-rails', :version => "'#{Rspec::Rails::Version::STRING}'"
|
6
|
+
|
7
|
+
initializer 'generators.rb', <<-CODE
|
8
|
+
module ExampleApp
|
9
|
+
class Application < Rails::Application
|
10
|
+
config.generators do |g|
|
11
|
+
g.test_framework :rspec,
|
12
|
+
:fixtures => false,
|
13
|
+
:integration_tool => false,
|
14
|
+
:routes => true,
|
15
|
+
:views => false
|
16
|
+
|
17
|
+
g.integration_tool :rspec
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
CODE
|
22
|
+
|
23
|
+
run('gem bundle')
|
24
|
+
|
25
|
+
generate('rspec:install')
|
26
|
+
generate('model', 'thing', 'name:string')
|
27
|
+
generate('controller', 'widgets', 'index')
|
28
|
+
generate('integration_test', 'widgets')
|
29
|
+
|
30
|
+
run('rake db:migrate')
|
31
|
+
run('rake db:test:prepare')
|
32
|
+
run('script/rspec spec')
|
33
|
+
run('rake spec')
|
@@ -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,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe <%= class_name %>Controller do
|
4
|
+
|
5
|
+
<% for action in actions -%>
|
6
|
+
|
7
|
+
describe "GET '<%= action %>'" do
|
8
|
+
it "should be successful" do
|
9
|
+
get '<%= action %>'
|
10
|
+
response.should be_success
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
<% end -%>
|
15
|
+
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,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Specs in this file have access to a helper object that includes
|
4
|
+
# the <%= class_name %>Helper. For example:
|
5
|
+
#
|
6
|
+
# describe <%= class_name %>Helper
|
7
|
+
# describe "string concat" do
|
8
|
+
# it "concats two strings with spaces" do
|
9
|
+
# helper.concat_strings("this","that").should == "this that"
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
describe <%= class_name %>Helper do
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
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
|
+
chmod "script/rspec", 0755, :verbose => false
|
22
|
+
end
|
23
|
+
|
24
|
+
def copy_spec_files
|
25
|
+
directory 'spec'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
begin
|
2
|
+
require 'rspec/core'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
rescue MissingSourceFile
|
5
|
+
module Rspec
|
6
|
+
module Core
|
7
|
+
class RakeTask
|
8
|
+
def initialize(name)
|
9
|
+
task name do
|
10
|
+
# if rspec-rails is a configured gem, this will output helpful material and exit ...
|
11
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
|
12
|
+
|
13
|
+
# ... otherwise, do this:
|
14
|
+
raise <<-MSG
|
15
|
+
|
16
|
+
#{"*" * 80}
|
17
|
+
* You are trying to run an rspec rake task defined in
|
18
|
+
* #{__FILE__},
|
19
|
+
* but rspec can not be found in vendor/gems, vendor/plugins or system gems.
|
20
|
+
#{"*" * 80}
|
21
|
+
MSG
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Rake.application.instance_variable_get('@tasks').delete('default')
|
30
|
+
|
31
|
+
spec_prereq = File.exist?(File.join(Rails.root, 'config', 'database.yml')) ? "db:test:prepare" : :noop
|
32
|
+
task :noop do
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :spec
|
36
|
+
task :stats => "spec:statsetup"
|
37
|
+
|
38
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
39
|
+
Rspec::Core::RakeTask.new(:spec => spec_prereq)
|
40
|
+
|
41
|
+
# namespace :spec do
|
42
|
+
# desc "Run all specs in spec directory with RCov (excluding plugin specs)"
|
43
|
+
# Rspec::Core::RakeTask.new(:rcov) do |t|
|
44
|
+
# t.spec_opts = ['--options', "\"#{Rails.root}/spec/spec.opts\""]
|
45
|
+
# t.spec_files = FileList['spec/**/*_spec.rb']
|
46
|
+
# t.rcov = true
|
47
|
+
# t.rcov_opts = lambda do
|
48
|
+
# IO.readlines("#{Rails.root}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
|
52
|
+
# desc "Print Rspecdoc for all specs (excluding plugin specs)"
|
53
|
+
# Rspec::Core::RakeTask.new(:doc) do |t|
|
54
|
+
# t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
55
|
+
# t.spec_files = FileList['spec/**/*_spec.rb']
|
56
|
+
# end
|
57
|
+
|
58
|
+
# desc "Print Rspecdoc for all plugin examples"
|
59
|
+
# Rspec::Core::RakeTask.new(:plugin_doc) do |t|
|
60
|
+
# t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
61
|
+
# t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*')
|
62
|
+
# end
|
63
|
+
|
64
|
+
# [:models, :controllers, :views, :helpers, :lib, :integration].each do |sub|
|
65
|
+
# desc "Run the code examples in spec/#{sub}"
|
66
|
+
# Rspec::Core::RakeTask.new(sub => spec_prereq) do |t|
|
67
|
+
# t.spec_opts = ['--options', "\"#{Rails.root}/spec/spec.opts\""]
|
68
|
+
# t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
69
|
+
# end
|
70
|
+
# end
|
71
|
+
|
72
|
+
# desc "Run the code examples in vendor/plugins (except RRspec's own)"
|
73
|
+
# Rspec::Core::RakeTask.new(:plugins => spec_prereq) do |t|
|
74
|
+
# t.spec_opts = ['--options', "\"#{Rails.root}/spec/spec.opts\""]
|
75
|
+
# t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
|
76
|
+
# end
|
77
|
+
|
78
|
+
# namespace :plugins do
|
79
|
+
# desc "Runs the examples for rspec_on_rails"
|
80
|
+
# Rspec::Core::RakeTask.new(:rspec_on_rails) do |t|
|
81
|
+
# t.spec_opts = ['--options', "\"#{Rails.root}/spec/spec.opts\""]
|
82
|
+
# t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb']
|
83
|
+
# end
|
84
|
+
# end
|
85
|
+
|
86
|
+
# task :statsetup do
|
87
|
+
# require 'code_statistics'
|
88
|
+
# ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
|
89
|
+
# ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
|
90
|
+
# ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
|
91
|
+
# ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
|
92
|
+
# ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
|
93
|
+
# ::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing')
|
94
|
+
# ::STATS_DIRECTORIES << %w(Integration\ specs spec/integration) if File.exist?('spec/integration')
|
95
|
+
# ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
|
96
|
+
# ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
|
97
|
+
# ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
|
98
|
+
# ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
|
99
|
+
# ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
|
100
|
+
# ::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
|
101
|
+
# ::CodeStatistics::TEST_TYPES << "Integration specs" if File.exist?('spec/integration')
|
102
|
+
# end
|
103
|
+
|
104
|
+
# namespace :db do
|
105
|
+
# namespace :fixtures do
|
106
|
+
# 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."
|
107
|
+
# task :load => :environment do
|
108
|
+
# ActiveRecord::Base.establish_connection(Rails.env)
|
109
|
+
# base_dir = File.join(Rails.root, 'spec', 'fixtures')
|
110
|
+
# fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
|
111
|
+
|
112
|
+
# require 'active_record/fixtures'
|
113
|
+
# (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
|
114
|
+
# Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
|
115
|
+
# end
|
116
|
+
# end
|
117
|
+
# end
|
118
|
+
# end
|
119
|
+
# end
|
File without changes
|
File without changes
|
data/{generators/rspec/templates → lib/generators/rspec/install/templates/spec}/spec_helper.rb
RENAMED
@@ -1,24 +1,26 @@
|
|
1
1
|
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
|
2
2
|
# from the project root directory.
|
3
3
|
ENV["RAILS_ENV"] ||= 'test'
|
4
|
-
require File.
|
5
|
-
require '
|
6
|
-
require 'spec/rails'
|
4
|
+
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
|
5
|
+
require 'rspec/rails'
|
7
6
|
|
8
|
-
# Uncomment the next line to use webrat's matchers
|
9
|
-
#require 'webrat/integrations/rspec-rails'
|
10
7
|
|
11
8
|
# Requires supporting files with custom matchers and macros, etc,
|
12
9
|
# in ./support/ and its subdirectories.
|
13
|
-
Dir[File.
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
11
|
+
|
12
|
+
Rspec::Core.configure do |config|
|
13
|
+
# Remove this line if you don't want Rspec's should and should_not
|
14
|
+
# methods or matchers
|
15
|
+
require 'rspec/expectations'
|
16
|
+
config.include Rspec::Matchers
|
14
17
|
|
15
|
-
Spec::Runner.configure do |config|
|
16
18
|
# If you're not using ActiveRecord you should remove these
|
17
19
|
# lines, delete config/database.yml and disable :active_record
|
18
20
|
# in your config/boot.rb
|
19
|
-
config.use_transactional_fixtures = true
|
20
|
-
config.use_instantiated_fixtures = false
|
21
|
-
config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
21
|
+
# config.use_transactional_fixtures = true
|
22
|
+
# config.use_instantiated_fixtures = false
|
23
|
+
# config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
22
24
|
|
23
25
|
# == Fixtures
|
24
26
|
#
|
@@ -41,7 +43,7 @@ Spec::Runner.configure do |config|
|
|
41
43
|
#
|
42
44
|
# == Mock Framework
|
43
45
|
#
|
44
|
-
# RSpec uses
|
46
|
+
# RSpec uses it's own mocking framework by default. If you prefer to
|
45
47
|
# use mocha, flexmock or RR, uncomment the appropriate line:
|
46
48
|
#
|
47
49
|
# config.mock_with :mocha
|
@@ -50,5 +52,5 @@ Spec::Runner.configure do |config|
|
|
50
52
|
#
|
51
53
|
# == Notes
|
52
54
|
#
|
53
|
-
# For more information take a look at
|
55
|
+
# For more information take a look at Rspec::Core::Configuration
|
54
56
|
end
|