dchelimsky-rspec-rails 1.1.12 → 1.1.99.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +29 -2
- data/License.txt +1 -1
- data/Manifest.txt +7 -6
- data/README.txt +5 -4
- data/Rakefile +14 -2
- data/TODO.txt +1 -0
- data/Upgrade.txt +30 -0
- data/generators/rspec/templates/rspec.rake +12 -10
- data/generators/rspec/templates/script/spec_server +10 -111
- data/generators/rspec_controller/rspec_controller_generator.rb +1 -5
- data/generators/rspec_scaffold/rspec_scaffold_generator.rb +9 -13
- data/generators/rspec_scaffold/templates/controller_spec.rb +25 -25
- data/generators/rspec_scaffold/templates/edit_erb_spec.rb +1 -1
- data/generators/rspec_scaffold/templates/helper_spec.rb +1 -1
- data/generators/rspec_scaffold/templates/index_erb_spec.rb +1 -1
- data/generators/rspec_scaffold/templates/new_erb_spec.rb +1 -1
- data/generators/rspec_scaffold/templates/routing_spec.rb +24 -20
- data/generators/rspec_scaffold/templates/show_erb_spec.rb +1 -1
- data/lib/spec/rails/example/controller_example_group.rb +46 -16
- data/lib/spec/rails/example/functional_example_group.rb +7 -22
- data/lib/spec/rails/example/helper_example_group.rb +6 -9
- data/lib/spec/rails/example/model_example_group.rb +1 -1
- data/lib/spec/rails/example/render_observer.rb +0 -26
- data/lib/spec/rails/example/view_example_group.rb +32 -34
- data/lib/spec/rails/example.rb +0 -2
- data/lib/spec/rails/extensions/active_support/test_case.rb +7 -0
- data/lib/spec/rails/extensions/spec/runner/configuration.rb +12 -44
- data/lib/spec/rails/extensions.rb +1 -1
- data/lib/spec/rails/matchers/ar_be_valid.rb +3 -0
- data/lib/spec/rails/matchers/have_text.rb +1 -1
- data/lib/spec/rails/matchers/include_text.rb +2 -2
- data/lib/spec/rails/matchers/redirect_to.rb +6 -14
- data/lib/spec/rails/matchers/render_template.rb +5 -1
- data/lib/spec/rails/spec_server.rb +86 -0
- data/lib/spec/rails/version.rb +2 -2
- data/lib/spec/rails.rb +10 -9
- data/rspec-rails.gemspec +12 -9
- data/spec/resources/controllers/controller_spec_controller.rb +1 -1
- data/spec/resources/controllers/render_spec_controller.rb +1 -1
- data/spec/resources/controllers/rjs_spec_controller.rb +1 -1
- data/spec/spec/rails/example/configuration_spec.rb +15 -29
- data/spec/spec/rails/example/{controller_spec_spec.rb → controller_example_group_spec.rb} +84 -60
- data/spec/spec/rails/example/cookies_proxy_spec.rb +32 -36
- data/spec/spec/rails/example/example_group_factory_spec.rb +5 -5
- data/spec/spec/rails/example/{helper_spec_spec.rb → helper_example_group_spec.rb} +8 -2
- data/spec/spec/rails/example/{model_spec_spec.rb → model_example_group_spec.rb} +3 -1
- data/spec/spec/rails/example/{view_spec_spec.rb → view_example_group_spec.rb} +33 -15
- data/spec/spec/rails/matchers/ar_be_valid_spec.rb +10 -0
- data/spec/spec/rails/matchers/assert_select_spec.rb +1 -0
- data/spec/spec/rails/matchers/have_text_spec.rb +12 -4
- data/spec/spec/rails/matchers/include_text_spec.rb +11 -13
- data/spec/spec/rails/matchers/redirect_to_spec.rb +221 -210
- data/spec/spec/rails/matchers/render_template_spec.rb +161 -158
- data/spec/spec/rails/spec_server_spec.rb +18 -7
- data/spec/spec_helper.rb +20 -9
- metadata +21 -10
- data/lib/spec/rails/example/rails_example_group.rb +0 -28
- data/lib/spec/rails/extensions/action_controller/base.rb +0 -14
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'drb/drb'
|
2
|
+
require 'rbconfig'
|
3
|
+
|
4
|
+
# This is based on Florian Weber's TDDMate
|
5
|
+
module Spec
|
6
|
+
module Rails
|
7
|
+
class SpecServer
|
8
|
+
class << self
|
9
|
+
def restart_test_server
|
10
|
+
puts "restarting"
|
11
|
+
config = ::Config::CONFIG
|
12
|
+
ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
|
13
|
+
command_line = [ruby, $0, ARGV].flatten.join(' ')
|
14
|
+
exec(command_line)
|
15
|
+
end
|
16
|
+
|
17
|
+
def daemonize(pid_file = nil)
|
18
|
+
return yield if $DEBUG
|
19
|
+
pid = Process.fork{
|
20
|
+
Process.setsid
|
21
|
+
Dir.chdir(RAILS_ROOT)
|
22
|
+
trap("SIGINT"){ exit! 0 }
|
23
|
+
trap("SIGTERM"){ exit! 0 }
|
24
|
+
trap("SIGHUP"){ restart_test_server }
|
25
|
+
File.open("/dev/null"){|f|
|
26
|
+
STDERR.reopen f
|
27
|
+
STDIN.reopen f
|
28
|
+
STDOUT.reopen f
|
29
|
+
}
|
30
|
+
run
|
31
|
+
}
|
32
|
+
puts "spec_server launched (PID: %d)" % pid
|
33
|
+
File.open(pid_file,"w"){|f| f.puts pid } if pid_file
|
34
|
+
exit! 0
|
35
|
+
end
|
36
|
+
|
37
|
+
def run
|
38
|
+
trap("USR2") { ::Spec::Rails::SpecServer.restart_test_server } if Signal.list.has_key?("USR2")
|
39
|
+
DRb.start_service("druby://127.0.0.1:8989", ::Spec::Rails::SpecServer.new)
|
40
|
+
DRb.thread.join
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def run(argv, stderr, stdout)
|
45
|
+
$stdout = stdout
|
46
|
+
$stderr = stderr
|
47
|
+
|
48
|
+
require 'action_controller/dispatcher'
|
49
|
+
dispatcher = ::ActionController::Dispatcher.new($stdout)
|
50
|
+
dispatcher.respond_to?(:cleanup_application) ?
|
51
|
+
dispatcher.cleanup_application :
|
52
|
+
dispatcher.reload_application
|
53
|
+
|
54
|
+
if Object.const_defined?(:Fixtures) && Fixtures.respond_to?(:reset_cache)
|
55
|
+
Fixtures.reset_cache
|
56
|
+
end
|
57
|
+
|
58
|
+
::ActiveSupport.const_defined?(:Dependencies) ?
|
59
|
+
::ActiveSupport::Dependencies.mechanism = :load :
|
60
|
+
::Dependencies.mechanism = :load
|
61
|
+
|
62
|
+
require_dependency('application.rb') unless Object.const_defined?(:ApplicationController)
|
63
|
+
load "#{RAILS_ROOT}/spec/spec_helper.rb"
|
64
|
+
|
65
|
+
if in_memory_database?
|
66
|
+
load "#{RAILS_ROOT}/db/schema.rb" # use db agnostic schema by default
|
67
|
+
ActiveRecord::Migrator.up('db/migrate') # use migrations
|
68
|
+
end
|
69
|
+
|
70
|
+
::Spec::Runner::CommandLine.run(
|
71
|
+
::Spec::Runner::OptionParser.parse(
|
72
|
+
argv,
|
73
|
+
$stderr,
|
74
|
+
$stdout
|
75
|
+
)
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
def in_memory_database?
|
80
|
+
ENV["RAILS_ENV"] == "test" and
|
81
|
+
::ActiveRecord::Base.connection.class.to_s == "ActiveRecord::ConnectionAdapters::SQLite3Adapter" and
|
82
|
+
::Rails::Configuration.new.database_configuration['test']['database'] == ':memory:'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/lib/spec/rails/version.rb
CHANGED
data/lib/spec/rails.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
|
-
|
1
|
+
RAILS_ENV ||= "test"
|
2
2
|
|
3
3
|
begin
|
4
4
|
require_dependency 'application_controller'
|
5
5
|
rescue MissingSourceFile
|
6
6
|
require_dependency 'application'
|
7
7
|
end
|
8
|
+
require 'rack/utils'
|
8
9
|
|
9
10
|
require 'action_controller/test_process'
|
10
11
|
require 'action_controller/integration'
|
12
|
+
require 'active_support/test_case'
|
11
13
|
require 'active_record/fixtures' if defined?(ActiveRecord::Base)
|
12
|
-
require 'test/unit'
|
13
14
|
|
14
|
-
require 'spec'
|
15
|
+
require 'spec/test/unit'
|
15
16
|
|
16
17
|
require 'spec/rails/matchers'
|
17
18
|
require 'spec/rails/mocks'
|
@@ -19,9 +20,9 @@ require 'spec/rails/example'
|
|
19
20
|
require 'spec/rails/extensions'
|
20
21
|
require 'spec/rails/interop/testcase'
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
Spec::Example::ExampleGroupFactory.default(ActiveSupport::TestCase)
|
24
|
+
|
25
|
+
if ActionView::Base.respond_to?(:cache_template_extension)
|
26
|
+
ActionView::Base.cache_template_extensions = false
|
27
|
+
end
|
28
|
+
|
data/rspec-rails.gemspec
CHANGED
@@ -2,35 +2,38 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rspec-rails}
|
5
|
-
s.version = "1.1.
|
5
|
+
s.version = "1.1.99.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["RSpec Development Team"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-02-11}
|
10
10
|
s.description = %q{Behaviour Driven Development for Ruby on Rails.}
|
11
11
|
s.email = ["rspec-devel@rubyforge.org"]
|
12
|
-
s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "TODO.txt", "generators/rspec/templates/previous_failures.txt"]
|
13
|
-
s.files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "Rakefile", "TODO.txt", "features/step_definitions/people.rb", "features/support/env.rb", "features/transactions/transactions_should_rollback.feature", "generators/rspec/CHANGES", "generators/rspec/rspec_generator.rb", "generators/rspec/templates/previous_failures.txt", "generators/rspec/templates/rcov.opts", "generators/rspec/templates/rspec.rake", "generators/rspec/templates/script/autospec", "generators/rspec/templates/script/spec", "generators/rspec/templates/script/spec_server", "generators/rspec/templates/spec.opts", "generators/rspec/templates/spec_helper.rb", "generators/rspec_controller/USAGE", "generators/rspec_controller/rspec_controller_generator.rb", "generators/rspec_controller/templates/controller_spec.rb", "generators/rspec_controller/templates/helper_spec.rb", "generators/rspec_controller/templates/view_spec.rb", "generators/rspec_default_values.rb", "generators/rspec_model/USAGE", "generators/rspec_model/rspec_model_generator.rb", "generators/rspec_model/templates/model_spec.rb", "generators/rspec_scaffold/rspec_scaffold_generator.rb", "generators/rspec_scaffold/templates/controller_spec.rb", "generators/rspec_scaffold/templates/edit_erb_spec.rb", "generators/rspec_scaffold/templates/helper_spec.rb", "generators/rspec_scaffold/templates/index_erb_spec.rb", "generators/rspec_scaffold/templates/new_erb_spec.rb", "generators/rspec_scaffold/templates/routing_spec.rb", "generators/rspec_scaffold/templates/show_erb_spec.rb", "init.rb", "lib/autotest/discover.rb", "lib/autotest/rails_rspec.rb", "lib/spec/rails.rb", "lib/spec/rails/example.rb", "lib/spec/rails/example/assigns_hash_proxy.rb", "lib/spec/rails/example/controller_example_group.rb", "lib/spec/rails/example/cookies_proxy.rb", "lib/spec/rails/example/functional_example_group.rb", "lib/spec/rails/example/helper_example_group.rb", "lib/spec/rails/example/model_example_group.rb", "lib/spec/rails/example/
|
12
|
+
s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "TODO.txt", "Upgrade.txt", "generators/rspec/templates/previous_failures.txt"]
|
13
|
+
s.files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "Rakefile", "TODO.txt", "Upgrade.txt", "features/step_definitions/people.rb", "features/support/env.rb", "features/transactions/transactions_should_rollback.feature", "generators/rspec/CHANGES", "generators/rspec/rspec_generator.rb", "generators/rspec/templates/previous_failures.txt", "generators/rspec/templates/rcov.opts", "generators/rspec/templates/rspec.rake", "generators/rspec/templates/script/autospec", "generators/rspec/templates/script/spec", "generators/rspec/templates/script/spec_server", "generators/rspec/templates/spec.opts", "generators/rspec/templates/spec_helper.rb", "generators/rspec_controller/USAGE", "generators/rspec_controller/rspec_controller_generator.rb", "generators/rspec_controller/templates/controller_spec.rb", "generators/rspec_controller/templates/helper_spec.rb", "generators/rspec_controller/templates/view_spec.rb", "generators/rspec_default_values.rb", "generators/rspec_model/USAGE", "generators/rspec_model/rspec_model_generator.rb", "generators/rspec_model/templates/model_spec.rb", "generators/rspec_scaffold/rspec_scaffold_generator.rb", "generators/rspec_scaffold/templates/controller_spec.rb", "generators/rspec_scaffold/templates/edit_erb_spec.rb", "generators/rspec_scaffold/templates/helper_spec.rb", "generators/rspec_scaffold/templates/index_erb_spec.rb", "generators/rspec_scaffold/templates/new_erb_spec.rb", "generators/rspec_scaffold/templates/routing_spec.rb", "generators/rspec_scaffold/templates/show_erb_spec.rb", "init.rb", "lib/autotest/discover.rb", "lib/autotest/rails_rspec.rb", "lib/spec/rails.rb", "lib/spec/rails/example.rb", "lib/spec/rails/example/assigns_hash_proxy.rb", "lib/spec/rails/example/controller_example_group.rb", "lib/spec/rails/example/cookies_proxy.rb", "lib/spec/rails/example/functional_example_group.rb", "lib/spec/rails/example/helper_example_group.rb", "lib/spec/rails/example/model_example_group.rb", "lib/spec/rails/example/render_observer.rb", "lib/spec/rails/example/view_example_group.rb", "lib/spec/rails/extensions.rb", "lib/spec/rails/extensions/action_controller/rescue.rb", "lib/spec/rails/extensions/action_controller/test_response.rb", "lib/spec/rails/extensions/action_view/base.rb", "lib/spec/rails/extensions/active_record/base.rb", "lib/spec/rails/extensions/active_support/test_case.rb", "lib/spec/rails/extensions/spec/matchers/have.rb", "lib/spec/rails/extensions/spec/runner/configuration.rb", "lib/spec/rails/interop/testcase.rb", "lib/spec/rails/matchers.rb", "lib/spec/rails/matchers/ar_be_valid.rb", "lib/spec/rails/matchers/assert_select.rb", "lib/spec/rails/matchers/change.rb", "lib/spec/rails/matchers/have_text.rb", "lib/spec/rails/matchers/include_text.rb", "lib/spec/rails/matchers/redirect_to.rb", "lib/spec/rails/matchers/render_template.rb", "lib/spec/rails/mocks.rb", "lib/spec/rails/spec_server.rb", "lib/spec/rails/story_adapter.rb", "lib/spec/rails/version.rb", "rspec-rails.gemspec", "spec/autotest/mappings_spec.rb", "spec/rails_suite.rb", "spec/resources/controllers/action_view_base_spec_controller.rb", "spec/resources/controllers/application.rb", "spec/resources/controllers/controller_spec_controller.rb", "spec/resources/controllers/redirect_spec_controller.rb", "spec/resources/controllers/render_spec_controller.rb", "spec/resources/controllers/rjs_spec_controller.rb", "spec/resources/helpers/addition_helper.rb", "spec/resources/helpers/explicit_helper.rb", "spec/resources/helpers/more_explicit_helper.rb", "spec/resources/helpers/plugin_application_helper.rb", "spec/resources/helpers/view_spec_helper.rb", "spec/resources/models/animal.rb", "spec/resources/models/person.rb", "spec/resources/models/thing.rb", "spec/resources/views/controller_spec/_partial.rhtml", "spec/resources/views/controller_spec/action_setting_flash_after_session_reset.rhtml", "spec/resources/views/controller_spec/action_setting_flash_before_session_reset.rhtml", "spec/resources/views/controller_spec/action_setting_the_assigns_hash.rhtml", "spec/resources/views/controller_spec/action_with_errors_in_template.rhtml", "spec/resources/views/controller_spec/action_with_template.rhtml", "spec/resources/views/layouts/application.rhtml", "spec/resources/views/layouts/simple.rhtml", "spec/resources/views/objects/_object.html.erb", "spec/resources/views/render_spec/_a_partial.rhtml", "spec/resources/views/render_spec/action_with_alternate_layout.rhtml", "spec/resources/views/render_spec/some_action.html.erb", "spec/resources/views/render_spec/some_action.js.rjs", "spec/resources/views/render_spec/some_action.rjs", "spec/resources/views/rjs_spec/_replacement_partial.rhtml", "spec/resources/views/rjs_spec/hide_div.rjs", "spec/resources/views/rjs_spec/hide_page_element.rjs", "spec/resources/views/rjs_spec/insert_html.rjs", "spec/resources/views/rjs_spec/replace.rjs", "spec/resources/views/rjs_spec/replace_html.rjs", "spec/resources/views/rjs_spec/replace_html_with_partial.rjs", "spec/resources/views/rjs_spec/visual_effect.rjs", "spec/resources/views/rjs_spec/visual_toggle_effect.rjs", "spec/resources/views/tag_spec/no_tags.rhtml", "spec/resources/views/tag_spec/single_div_with_no_attributes.rhtml", "spec/resources/views/tag_spec/single_div_with_one_attribute.rhtml", "spec/resources/views/view_spec/_partial.rhtml", "spec/resources/views/view_spec/_partial_used_twice.rhtml", "spec/resources/views/view_spec/_partial_with_local_variable.rhtml", "spec/resources/views/view_spec/_partial_with_sub_partial.rhtml", "spec/resources/views/view_spec/_spacer.rhtml", "spec/resources/views/view_spec/accessor.rhtml", "spec/resources/views/view_spec/block_helper.rhtml", "spec/resources/views/view_spec/entry_form.rhtml", "spec/resources/views/view_spec/explicit_helper.rhtml", "spec/resources/views/view_spec/foo/show.rhtml", "spec/resources/views/view_spec/implicit_helper.rhtml", "spec/resources/views/view_spec/multiple_helpers.rhtml", "spec/resources/views/view_spec/path_params.html.erb", "spec/resources/views/view_spec/should_not_receive.rhtml", "spec/resources/views/view_spec/template_with_partial.rhtml", "spec/resources/views/view_spec/template_with_partial_using_collection.rhtml", "spec/resources/views/view_spec/template_with_partial_with_array.rhtml", "spec/spec/rails/example/assigns_hash_proxy_spec.rb", "spec/spec/rails/example/configuration_spec.rb", "spec/spec/rails/example/controller_example_group_spec.rb", "spec/spec/rails/example/controller_isolation_spec.rb", "spec/spec/rails/example/cookies_proxy_spec.rb", "spec/spec/rails/example/example_group_factory_spec.rb", "spec/spec/rails/example/helper_example_group_spec.rb", "spec/spec/rails/example/model_example_group_spec.rb", "spec/spec/rails/example/shared_behaviour_spec.rb", "spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb", "spec/spec/rails/example/view_example_group_spec.rb", "spec/spec/rails/extensions/action_controller_rescue_action_spec.rb", "spec/spec/rails/extensions/action_view_base_spec.rb", "spec/spec/rails/extensions/active_record_spec.rb", "spec/spec/rails/interop/testcase_spec.rb", "spec/spec/rails/matchers/ar_be_valid_spec.rb", "spec/spec/rails/matchers/assert_select_spec.rb", "spec/spec/rails/matchers/errors_on_spec.rb", "spec/spec/rails/matchers/have_text_spec.rb", "spec/spec/rails/matchers/include_text_spec.rb", "spec/spec/rails/matchers/redirect_to_spec.rb", "spec/spec/rails/matchers/render_template_spec.rb", "spec/spec/rails/matchers/should_change_spec.rb", "spec/spec/rails/mocks/ar_classes.rb", "spec/spec/rails/mocks/mock_model_spec.rb", "spec/spec/rails/mocks/stub_model_spec.rb", "spec/spec/rails/sample_modified_fixture.rb", "spec/spec/rails/sample_spec.rb", "spec/spec/rails/spec_server_spec.rb", "spec/spec/rails/spec_spec.rb", "spec/spec_helper.rb"]
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.homepage = %q{http://rspec.info/}
|
16
16
|
s.rdoc_options = ["--main", "README.txt"]
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
s.rubyforge_project = %q{rspec}
|
19
19
|
s.rubygems_version = %q{1.3.1}
|
20
|
-
s.summary = %q{rspec-rails 1.1.
|
20
|
+
s.summary = %q{rspec-rails 1.1.99.1}
|
21
21
|
|
22
22
|
if s.respond_to? :specification_version then
|
23
23
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
24
|
s.specification_version = 2
|
25
25
|
|
26
26
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
-
s.add_runtime_dependency(%q<rspec>, ["= 1.1.
|
27
|
+
s.add_runtime_dependency(%q<rspec>, ["= 1.1.99.1"])
|
28
|
+
s.add_runtime_dependency(%q<rack>, [">= 0.4.0"])
|
28
29
|
s.add_development_dependency(%q<cucumber>, [">= 0.1.13"])
|
29
|
-
s.add_development_dependency(%q<hoe>, [">= 1.8.
|
30
|
+
s.add_development_dependency(%q<hoe>, [">= 1.8.3"])
|
30
31
|
else
|
31
|
-
s.add_dependency(%q<rspec>, ["= 1.1.
|
32
|
+
s.add_dependency(%q<rspec>, ["= 1.1.99.1"])
|
33
|
+
s.add_dependency(%q<rack>, [">= 0.4.0"])
|
32
34
|
end
|
33
35
|
else
|
34
|
-
s.add_dependency(%q<rspec>, ["= 1.1.
|
36
|
+
s.add_dependency(%q<rspec>, ["= 1.1.99.1"])
|
37
|
+
s.add_dependency(%q<rack>, [">= 0.4.0"])
|
35
38
|
end
|
36
39
|
end
|
@@ -7,7 +7,7 @@ class ControllerSpecController < ActionController::Base
|
|
7
7
|
|
8
8
|
skip_before_filter :raise_error
|
9
9
|
|
10
|
-
|
10
|
+
prepend_view_path File.join(File.dirname(__FILE__), "..", "views")
|
11
11
|
|
12
12
|
def some_action
|
13
13
|
render :template => "template/that/does/not/actually/exist"
|
@@ -9,41 +9,33 @@ module Spec
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "#use_transactional_fixtures" do
|
12
|
-
it "should return
|
13
|
-
config.use_transactional_fixtures.should ==
|
12
|
+
it "should return ActiveSupport::TestCase.use_transactional_fixtures" do
|
13
|
+
config.use_transactional_fixtures.should == ActiveSupport::TestCase.use_transactional_fixtures
|
14
14
|
end
|
15
15
|
|
16
|
-
it "should set
|
17
|
-
|
18
|
-
example_group.should_receive(:use_transactional_fixtures=).with(false)
|
19
|
-
end
|
16
|
+
it "should set ActiveSupport::TestCase.use_transactional_fixtures to false" do
|
17
|
+
ActiveSupport::TestCase.should_receive(:use_transactional_fixtures=).with(false)
|
20
18
|
config.use_transactional_fixtures = false
|
21
19
|
end
|
22
20
|
|
23
|
-
it "should set
|
24
|
-
|
25
|
-
example_group.should_receive(:use_transactional_fixtures=).with(true)
|
26
|
-
end
|
21
|
+
it "should set ActiveSupport::TestCase.use_transactional_fixtures to true" do
|
22
|
+
ActiveSupport::TestCase.should_receive(:use_transactional_fixtures=).with(true)
|
27
23
|
config.use_transactional_fixtures = true
|
28
24
|
end
|
29
25
|
end
|
30
26
|
|
31
27
|
describe "#use_instantiated_fixtures" do
|
32
|
-
it "should return
|
33
|
-
config.use_instantiated_fixtures.should ==
|
28
|
+
it "should return ActiveSupport::TestCase.use_transactional_fixtures" do
|
29
|
+
config.use_instantiated_fixtures.should == ActiveSupport::TestCase.use_instantiated_fixtures
|
34
30
|
end
|
35
31
|
|
36
|
-
it "should set
|
37
|
-
|
38
|
-
example_group.should_receive(:use_instantiated_fixtures=).with(false)
|
39
|
-
end
|
32
|
+
it "should set ActiveSupport::TestCase.use_instantiated_fixtures to false" do
|
33
|
+
ActiveSupport::TestCase.should_receive(:use_instantiated_fixtures=).with(false)
|
40
34
|
config.use_instantiated_fixtures = false
|
41
35
|
end
|
42
36
|
|
43
|
-
it "should set
|
44
|
-
|
45
|
-
example_group.should_receive(:use_instantiated_fixtures=).with(true)
|
46
|
-
end
|
37
|
+
it "should set ActiveSupport::TestCase.use_instantiated_fixtures to true" do
|
38
|
+
ActiveSupport::TestCase.should_receive(:use_instantiated_fixtures=).with(true)
|
47
39
|
config.use_instantiated_fixtures = true
|
48
40
|
end
|
49
41
|
end
|
@@ -51,25 +43,19 @@ module Spec
|
|
51
43
|
describe "#fixture_path" do
|
52
44
|
it "should default to RAILS_ROOT + '/spec/fixtures'" do
|
53
45
|
config.fixture_path.should == RAILS_ROOT + '/spec/fixtures'
|
54
|
-
|
55
|
-
example_group.fixture_path.should == RAILS_ROOT + '/spec/fixtures'
|
56
|
-
end
|
46
|
+
ActiveSupport::TestCase.fixture_path.should == RAILS_ROOT + '/spec/fixtures'
|
57
47
|
end
|
58
48
|
|
59
49
|
it "should set fixture_path" do
|
60
50
|
config.fixture_path = "/new/path"
|
61
51
|
config.fixture_path.should == "/new/path"
|
62
|
-
|
63
|
-
example_group.fixture_path.should == "/new/path"
|
64
|
-
end
|
52
|
+
ActiveSupport::TestCase.fixture_path.should == "/new/path"
|
65
53
|
end
|
66
54
|
end
|
67
55
|
|
68
56
|
describe "#global_fixtures" do
|
69
57
|
it "should set fixtures on TestCase" do
|
70
|
-
|
71
|
-
example_group.should_receive(:fixtures).with(:blah)
|
72
|
-
end
|
58
|
+
ActiveSupport::TestCase.should_receive(:fixtures).with(:blah)
|
73
59
|
config.global_fixtures = [:blah]
|
74
60
|
end
|
75
61
|
end
|
@@ -5,6 +5,20 @@ require 'controller_spec_controller'
|
|
5
5
|
describe "A controller example running in #{mode} mode", :type => :controller do
|
6
6
|
controller_name :controller_spec
|
7
7
|
integrate_views if mode == 'integration'
|
8
|
+
|
9
|
+
accesses_configured_helper_methods
|
10
|
+
|
11
|
+
it "should use the controller as the implicit subject" do
|
12
|
+
subject.should == controller
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "with a specified subject" do
|
16
|
+
subject { 'specified' }
|
17
|
+
|
18
|
+
it "should use the specified subject instead of the controller" do
|
19
|
+
subject.should == 'specified'
|
20
|
+
end
|
21
|
+
end
|
8
22
|
|
9
23
|
it "should provide controller.session as session" do
|
10
24
|
get 'action_with_template'
|
@@ -101,22 +115,6 @@ require 'controller_spec_controller'
|
|
101
115
|
end
|
102
116
|
end
|
103
117
|
|
104
|
-
describe "handling deprecated expect_render" do
|
105
|
-
it "should warn" do
|
106
|
-
Kernel.should_receive(:warn).with(/expect_render is deprecated/)
|
107
|
-
controller.expect_render(:template => "controller_spec/action_with_template")
|
108
|
-
get :action_with_template
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe "handling deprecated stub_render" do
|
113
|
-
it "should warn" do
|
114
|
-
Kernel.should_receive(:warn).with(/stub_render is deprecated/)
|
115
|
-
controller.stub_render(:template => "controller_spec/action_with_template")
|
116
|
-
get :action_with_template
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
118
|
describe "setting cookies in the request" do
|
121
119
|
|
122
120
|
it "should support a String key" do
|
@@ -129,11 +127,9 @@ require 'controller_spec_controller'
|
|
129
127
|
get 'action_which_gets_cookie', :expected => "cookie value"
|
130
128
|
end
|
131
129
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
get 'action_which_gets_cookie', :expected => {'value' => 'cookie value', 'path' => '/not/default'}
|
136
|
-
end
|
130
|
+
it "should support a Hash value" do
|
131
|
+
cookies[:cookie_key] = {'value' => 'cookie value', 'path' => '/not/default'}
|
132
|
+
get 'action_which_gets_cookie', :expected => {'value' => 'cookie value', 'path' => '/not/default'}
|
137
133
|
end
|
138
134
|
|
139
135
|
end
|
@@ -170,80 +166,107 @@ require 'controller_spec_controller'
|
|
170
166
|
end
|
171
167
|
context "with rails' error handling" do
|
172
168
|
it "does not raise the error" do
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
169
|
+
pending "deal with use_rails_error_handling" do
|
170
|
+
controller.use_rails_error_handling!
|
171
|
+
lambda do
|
172
|
+
get 'other_error_action'
|
173
|
+
end.should_not raise_error
|
174
|
+
end
|
177
175
|
end
|
178
176
|
end
|
179
177
|
end
|
180
178
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
lambda do
|
186
|
-
get 'rescued_error_action'
|
187
|
-
end.should_not raise_error
|
188
|
-
end
|
189
|
-
|
190
|
-
it "executes rescue_from" do
|
179
|
+
describe "with an error that is rescued in the controller" do
|
180
|
+
context "without rails' error handling" do
|
181
|
+
it "does not raise error" do
|
182
|
+
lambda do
|
191
183
|
get 'rescued_error_action'
|
192
|
-
|
193
|
-
end
|
184
|
+
end.should_not raise_error
|
194
185
|
end
|
195
186
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
lambda do
|
202
|
-
get 'rescued_error_action'
|
203
|
-
end.should_not raise_error
|
204
|
-
end
|
187
|
+
it "executes rescue_from" do
|
188
|
+
get 'rescued_error_action'
|
189
|
+
response.body.should == 'Rescued!'
|
190
|
+
end
|
191
|
+
end
|
205
192
|
|
206
|
-
|
193
|
+
context "with rails' error handling" do
|
194
|
+
before(:each) do
|
195
|
+
controller.use_rails_error_handling!
|
196
|
+
end
|
197
|
+
it "does not raise error" do
|
198
|
+
lambda do
|
207
199
|
get 'rescued_error_action'
|
208
|
-
|
209
|
-
|
200
|
+
end.should_not raise_error
|
201
|
+
end
|
202
|
+
|
203
|
+
it "executes rescue_from" do
|
204
|
+
get 'rescued_error_action'
|
205
|
+
response.body.should == 'Rescued!'
|
210
206
|
end
|
211
207
|
end
|
212
208
|
end
|
213
209
|
|
210
|
+
class CustomRouteSpecController < ActionController::Base; end
|
211
|
+
class RspecOnRailsSpecsController < ActionController::Base; end
|
212
|
+
|
214
213
|
it "should support custom routes" do
|
215
|
-
route_for(:controller => "custom_route_spec", :action => "custom_route").
|
214
|
+
route_for(:controller => "custom_route_spec", :action => "custom_route").
|
215
|
+
should == "/custom_route"
|
216
216
|
end
|
217
217
|
|
218
218
|
it "should support existing routes" do
|
219
|
-
route_for(:controller => "controller_spec", :action => "some_action").
|
219
|
+
route_for(:controller => "controller_spec", :action => "some_action").
|
220
|
+
should == "/controller_spec/some_action"
|
220
221
|
end
|
221
222
|
|
222
|
-
it "should
|
223
|
-
|
223
|
+
it "should support existing routes with additional parameters" do
|
224
|
+
route_for(:controller => "controller_spec", :action => "some_action", :param => '1').
|
225
|
+
should == "/controller_spec/some_action?param=1"
|
224
226
|
end
|
225
227
|
|
228
|
+
it "recognizes routes with methods besides :get" do
|
229
|
+
route_for(:controller => "rspec_on_rails_specs", :action => "update", :id => "37").
|
230
|
+
should == {:path => "/rspec_on_rails_specs/37", :method => :put}
|
231
|
+
end
|
232
|
+
|
233
|
+
it "should generate params for custom routes" do
|
234
|
+
params_from(:get, '/custom_route').
|
235
|
+
should == {:controller => "custom_route_spec", :action => "custom_route"}
|
236
|
+
end
|
237
|
+
|
226
238
|
it "should generate params for existing routes" do
|
227
|
-
params_from(:get, '/controller_spec/some_action').
|
239
|
+
params_from(:get, '/controller_spec/some_action').
|
240
|
+
should == {:controller => "controller_spec", :action => "some_action"}
|
228
241
|
end
|
229
|
-
|
242
|
+
|
243
|
+
it "should generate params for an existing route with a query parameter" do
|
244
|
+
params_from(:get, '/controller_spec/some_action?param=1').
|
245
|
+
should == {:controller => "controller_spec", :action => "some_action", :param => '1'}
|
246
|
+
end
|
247
|
+
|
248
|
+
it "should generate params for an existing route with multiple query parameters" do
|
249
|
+
params_from(:get, '/controller_spec/some_action?param1=1¶m2=2').
|
250
|
+
should == {:controller => "controller_spec", :action => "some_action", :param1 => '1', :param2 => '2' }
|
251
|
+
end
|
252
|
+
|
230
253
|
it "should expose instance vars through the assigns hash" do
|
231
254
|
get 'action_setting_the_assigns_hash'
|
232
255
|
assigns[:indirect_assigns_key].should == :indirect_assigns_key_value
|
233
256
|
end
|
234
|
-
|
257
|
+
|
235
258
|
it "should expose instance vars through the assigns hash that are set to false" do
|
236
259
|
get 'action_that_assigns_false_to_a_variable'
|
237
260
|
assigns[:a_variable].should be_false
|
238
261
|
end
|
239
|
-
|
262
|
+
|
240
263
|
it "should NOT complain when calling should_receive with arguments other than :render" do
|
241
264
|
controller.should_receive(:anything_besides_render)
|
242
265
|
lambda {
|
243
266
|
controller.rspec_verify
|
244
267
|
}.should raise_error(Exception, /expected :anything_besides_render/)
|
245
268
|
end
|
246
|
-
|
269
|
+
|
247
270
|
it "should not run a skipped before_filter" do
|
248
271
|
lambda {
|
249
272
|
get 'action_with_skipped_before_filter'
|
@@ -301,9 +324,10 @@ end
|
|
301
324
|
end
|
302
325
|
end
|
303
326
|
|
304
|
-
|
327
|
+
# # FIXME - not sure why this fails against 2.0.5, since generated controller
|
328
|
+
# # specs that use the implicit controller pass.
|
305
329
|
describe ControllerSpecController, :type => :controller do
|
306
|
-
it "should
|
330
|
+
it "should use the controller passed to #describe" do
|
307
331
|
end
|
308
332
|
end
|
309
333
|
|