aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/plugins/rspec_on_rails
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/plugins/rspec_on_rails')
-rw-r--r--vendor/plugins/rspec_on_rails/.gitignore4
-rw-r--r--vendor/plugins/rspec_on_rails/CHANGES21
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server20
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts7
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb8
-rwxr-xr-xvendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb3
-rwxr-xr-xvendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb8
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb4
-rwxr-xr-xvendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb4
-rwxr-xr-xvendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb12
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/edit_erb_spec.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb6
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/index_erb_spec.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/new_erb_spec.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/routing_spec.rb4
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/show_erb_spec.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/lib/autotest/discover.rb1
-rw-r--r--vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails.rb5
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example.rb1
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example/assigns_hash_proxy.rb1
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb104
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.rb23
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb58
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example/rails_example_group.rb51
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example/render_observer.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example/view_example_group.rb24
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/example/configuration.rb7
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/matchers.rb1
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb6
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/include_text.rb54
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb4
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/mocks.rb115
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb46
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb29
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb7
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb21
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb33
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb27
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb25
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb63
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb70
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb6
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb91
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/mocks/ar_classes.rb10
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb23
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/mocks/stub_model_spec.rb78
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/sample_modified_fixture.rb8
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/sample_spec.rb5
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb69
-rw-r--r--vendor/plugins/rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb23
-rw-r--r--vendor/plugins/rspec_on_rails/spec_resources/controllers/render_spec_controller.rb4
-rw-r--r--vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/accessor.rhtml4
-rw-r--r--vendor/plugins/rspec_on_rails/tasks/rspec.rake4
57 files changed, 930 insertions, 290 deletions
diff --git a/vendor/plugins/rspec_on_rails/.gitignore b/vendor/plugins/rspec_on_rails/.gitignore
new file mode 100644
index 000000000..8c6c23dc2
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/.gitignore
@@ -0,0 +1,4 @@
+tmtags
+.DS_Store
+.emacs-project
+*~
diff --git a/vendor/plugins/rspec_on_rails/CHANGES b/vendor/plugins/rspec_on_rails/CHANGES
new file mode 100644
index 000000000..9a54a1c81
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/CHANGES
@@ -0,0 +1,21 @@
+== Version 1.1.4
+
+Maintenance release.
+
+* Moved mock_model and stub_model to their own module: Spec::Rails::Mocks
+* Setting mock_model object id with stubs hash - patch from Adam Meehan
+* Added as_new_record to stub_model e.g. stub_model(Foo).as_new_record
+* Improved stub_model such that new_record? does "the right thing"
+* Patch from Pat Maddox to get integrate_views to work in nested example groups.
+* Patch from Pat Maddox to get controller_name to work in nested example groups.
+* Patch from Corey Haines to add include_text matcher
+* Added stub_model method which creates a real model instance with :id stubbed and data access prohibited.
+* Applied patch from Pat Maddox to handle redirect_to w/ SSL. Closes #320.
+* Added #helper and #assigns to helper specs.
+* Applied patch from Bryan Helmkamp to tweak format of generated spec.opts to be more obvious. Closes #162.
+* Tweaked list of exceptions (ignores) for autotest
+* Applied patch from Rick Olson to get rspec_on_rails working with rails edge (>= 8862)
+* Applied patch from Wincent Colaiuta to invert sense of "spec --diff". Closes #281.
+* Allow any type of render in view specs. Closes #57.
+* Applied patch from Ian White to get rspec working with edge rails (8804). Closes #271.
+* Applied patch from Jon Strother to have spec_server reload fixtures. Closes #344. \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server b/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server
index 3787a39d9..1e839355f 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server
+++ b/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server
@@ -1,5 +1,4 @@
#!/usr/bin/env ruby
-$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
require 'rubygems'
require 'drb/drb'
@@ -23,20 +22,29 @@ module Spec
active_connections.delete(name)
end
end
- end
+ end
if ActionController.const_defined?(:Dispatcher)
dispatcher = ::ActionController::Dispatcher.new($stdout)
- dispatcher.cleanup_application(true)
+ dispatcher.cleanup_application
elsif ::Dispatcher.respond_to?(:reset_application!)
::Dispatcher.reset_application!
else
raise "Application reloading failed"
end
+ if Object.const_defined?(:Fixtures) && Fixtures.respond_to?(:reset_cache)
+ Fixtures.reset_cache
+ end
+
::Dependencies.mechanism = :load
require_dependency('application.rb') unless Object.const_defined?(:ApplicationController)
load File.dirname(__FILE__) + '/../spec/spec_helper.rb'
+ if in_memory_database?
+ load "#{RAILS_ROOT}/db/schema.rb" # use db agnostic schema by default
+ ActiveRecord::Migrator.up('db/migrate') # use migrations
+ end
+
::Spec::Runner::CommandLine.run(
::Spec::Runner::OptionParser.parse(
argv,
@@ -45,6 +53,12 @@ module Spec
)
)
end
+
+ def in_memory_database?
+ ENV["RAILS_ENV"] == "test" and
+ ::ActiveRecord::Base.connection.class.to_s == "ActiveRecord::ConnectionAdapters::SQLite3Adapter" and
+ ::Rails::Configuration.new.database_configuration['test']['database'] == ':memory:'
+ end
end
end
end
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts b/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts
index 2144705ed..391705bf8 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts
+++ b/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts
@@ -1,7 +1,4 @@
--colour
---format
-progress
---loadby
-mtime
+--format progress
+--loadby mtime
--reverse
---backtrace \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb b/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb
index 210d9d196..938dd7b49 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb
@@ -28,6 +28,10 @@ Spec::Runner.configure do |config|
# If you declare global fixtures, be aware that they will be declared
# for all of your examples, even those that don't use them.
#
+ # You can also declare which fixtures to use (for example fixtures for test/fixtures):
+ #
+ # config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
+ #
# == Mock Framework
#
# RSpec uses it's own mocking framework by default. If you prefer to
@@ -36,4 +40,8 @@ Spec::Runner.configure do |config|
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
+ #
+ # == Notes
+ #
+ # For more information take a look at Spec::Example::Configuration and Spec::Runner
end
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb b/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb
index d21c2156a..933483054 100755
--- a/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb
@@ -1,5 +1,4 @@
require 'rails_generator/generators/components/controller/controller_generator'
-require File.join(File.dirname(__FILE__), *%w[.. helpers rails_identifier])
class RspecControllerGenerator < ControllerGenerator
@@ -16,7 +15,7 @@ class RspecControllerGenerator < ControllerGenerator
m.directory File.join('spec/helpers', class_path)
m.directory File.join('spec/views', class_path, file_name)
- if RailsIdentifier.using_legacy_templates?
+ if Rails::VERSION::STRING < "2.0.0"
@default_file_extension = "rhtml"
else
@default_file_extension = "html.erb"
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb
index e79549e2c..cb25fe777 100755
--- a/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
describe <%= class_name %>Controller do
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb
index e9dabcde9..11c650480 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb
@@ -1,11 +1,11 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
describe <%= class_name %>Helper do
#Delete this example and add some real ones or delete this file
- it "should include the <%= class_name %>Helper" do
- included_modules = self.metaclass.send :included_modules
+ it "should be included in the object returned by #helper" do
+ included_modules = (class << helper; self; end).send :included_modules
included_modules.should include(<%= class_name %>Helper)
end
-
+
end
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb
index 4d9e7dcf1..d550d6a1b 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
describe "/<%= class_name.underscore %>/<%= action %>" do
before(:each) do
@@ -7,6 +7,6 @@ describe "/<%= class_name.underscore %>/<%= action %>" do
#Delete this example and add some real ones or delete this file
it "should tell you where to find the file" do
- response.should have_tag('p', /Find me in app\/views\/<%= class_name.underscore %>\/<%= action %>/)
+ response.should have_tag('p', %r[Find me in app/views/<%= class_name.underscore %>/<%= action %>])
end
end
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb
index 83aa88bea..648908b4c 100755
--- a/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
describe <%= class_name %> do
before(:each) do
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb
index 19d09cb13..0dab8250b 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb
@@ -1,5 +1,3 @@
-require File.join(File.dirname(__FILE__), *%w[.. helpers rails_identifier])
-
class RspecScaffoldGenerator < Rails::Generator::NamedBase
default_options :skip_migration => false
@@ -30,7 +28,7 @@ class RspecScaffoldGenerator < Rails::Generator::NamedBase
@controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
end
- if RailsIdentifier.using_legacy_templates?
+ if Rails::VERSION::STRING < "2.0.0"
@resource_generator = "scaffold_resource"
@default_file_extension = "rhtml"
else
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb
index 748190743..ae7b1a701 100755
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
describe <%= controller_class_name %>Controller do
describe "handling GET /<%= table_name %>" do
@@ -36,8 +36,8 @@ describe <%= controller_class_name %>Controller do
describe "handling GET /<%= table_name %>.xml" do
before(:each) do
- @<%= file_name %> = mock_model(<%= class_name %>, :to_xml => "XML")
- <%= class_name %>.stub!(:find).and_return(@<%= file_name %>)
+ @<%= file_name.pluralize %> = mock("Array of <%= class_name.pluralize %>", :to_xml => "XML")
+ <%= class_name %>.stub!(:find).and_return(@<%= file_name.pluralize %>)
end
def do_get
@@ -51,12 +51,12 @@ describe <%= controller_class_name %>Controller do
end
it "should find all <%= table_name %>" do
- <%= class_name %>.should_receive(:find).with(:all).and_return([@<%= file_name %>])
+ <%= class_name %>.should_receive(:find).with(:all).and_return(@<%= file_name.pluralize %>)
do_get
end
it "should render the found <%= table_name %> as xml" do
- @<%= file_name %>.should_receive(:to_xml).and_return("XML")
+ @<%= file_name.pluralize %>.should_receive(:to_xml).and_return("XML")
do_get
response.body.should == "XML"
end
@@ -310,4 +310,4 @@ describe <%= controller_class_name %>Controller do
response.should redirect_to(<%= table_name %>_url)
end
end
-end \ No newline at end of file
+end
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/edit_erb_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/edit_erb_spec.rb
index 931abf890..86e23a27e 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/edit_erb_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/edit_erb_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
describe "/<%= table_name %>/edit.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb
index 85cf795dc..900b027aa 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb
@@ -1,10 +1,10 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
describe <%= controller_class_name %>Helper do
#Delete this example and add some real ones or delete this file
- it "should include the <%= class_name %>Helper" do
- included_modules = self.metaclass.send :included_modules
+ it "should be included in the object returned by #helper" do
+ included_modules = (class << helper; self; end).send :included_modules
included_modules.should include(<%= controller_class_name %>Helper)
end
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/index_erb_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/index_erb_spec.rb
index 9d61c6f4c..660c284f5 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/index_erb_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/index_erb_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
describe "/<%= table_name %>/index.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/new_erb_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/new_erb_spec.rb
index 2ae085ad7..f0442e9b1 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/new_erb_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/new_erb_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
describe "/<%= table_name %>/new.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/routing_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/routing_spec.rb
index a6da04901..ca53a7caa 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/routing_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/routing_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
describe <%= controller_class_name %>Controller do
describe "route generation" do
@@ -58,4 +58,4 @@ describe <%= controller_class_name %>Controller do
params_from(:delete, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "destroy", :id => "1"}
end
end
-end \ No newline at end of file
+end
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/show_erb_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/show_erb_spec.rb
index 53de98323..36dae5490 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/show_erb_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/show_erb_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
describe "/<%= table_name %>/show.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
diff --git a/vendor/plugins/rspec_on_rails/lib/autotest/discover.rb b/vendor/plugins/rspec_on_rails/lib/autotest/discover.rb
new file mode 100644
index 000000000..8e6968e20
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/lib/autotest/discover.rb
@@ -0,0 +1 @@
+# This needs to be here for >= ZenTest-3.9.0 to add this directory to the load path. \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb b/vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb
index 1fe20fbc9..c6fe446b1 100644
--- a/vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb
+++ b/vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb
@@ -26,7 +26,7 @@ require 'active_support'
require 'autotest/rspec'
Autotest.add_hook :initialize do |at|
- %w{config coverage db doc log public script vendor/rails vendor/plugins previous_failures.txt}.each do |exception|
+ %w{config/ coverage/ db/ doc/ log/ public/ script/ tmp/ vendor/rails vendor/plugins previous_failures.txt}.each do |exception|
at.add_exception(exception)
end
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails.rb
index be8a6c415..74fc3929b 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails.rb
@@ -8,10 +8,11 @@ require 'test/unit'
require 'spec'
-require 'spec/rails/extensions'
+require 'spec/rails/matchers'
+require 'spec/rails/mocks'
require 'spec/rails/example'
+require 'spec/rails/extensions'
require 'spec/rails/version'
-require 'spec/rails/matchers'
module Spec
# = Spec::Rails
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example.rb
index 64a72a9db..f104f51e5 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example.rb
@@ -1,6 +1,5 @@
dir = File.dirname(__FILE__)
-require 'spec/rails/example/ivar_proxy'
require 'spec/rails/example/assigns_hash_proxy'
require "spec/rails/example/render_observer"
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/assigns_hash_proxy.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/assigns_hash_proxy.rb
index 1d121f70a..c8a7d0662 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/assigns_hash_proxy.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/assigns_hash_proxy.rb
@@ -17,6 +17,7 @@ module Spec
end
def []=(ivar, val)
+ @object.instance_variable_set "@#{ivar}", val
assigns[ivar.to_s] = val
end
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb
index eca06a403..a686b6a39 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb
@@ -72,12 +72,19 @@ module Spec
#
# See Spec::Rails::Example::ControllerExampleGroup for more information about
# Integration and Isolation modes.
- def integrate_views
- @integrate_views = true
+ def integrate_views(integrate_views = true)
+ @integrate_views = integrate_views
end
+
def integrate_views? # :nodoc:
@integrate_views
end
+
+ def inherited(klass) # :nodoc:
+ klass.controller_class_name = controller_class_name
+ klass.integrate_views(integrate_views?)
+ super
+ end
# You MUST provide a controller_name within the context of
# your controller specs:
@@ -106,7 +113,7 @@ module Spec
end
EOE
end
- @controller.metaclass.class_eval do
+ (class << @controller; self; end).class_eval do
def controller_path #:nodoc:
self.class.name.underscore.gsub('_controller', '')
end
@@ -150,8 +157,8 @@ module Spec
end
protected
- def _controller_ivar_proxy
- @controller_ivar_proxy ||= AssignsHashProxy.new @controller
+ def _assigns_hash_proxy
+ @_assigns_hash_proxy ||= AssignsHashProxy.new @controller
end
private
@@ -162,18 +169,32 @@ module Spec
module ControllerInstanceMethods #:nodoc:
include Spec::Rails::Example::RenderObserver
- # === render(options = nil, deprecated_status = nil, &block)
+ # === render(options = nil, deprecated_status_or_extra_options = nil, &block)
#
# This gets added to the controller's singleton meta class,
# allowing Controller Examples to run in two modes, freely switching
# from context to context.
- def render(options=nil, deprecated_status=nil, &block)
+ def render(options=nil, deprecated_status_or_extra_options=nil, &block)
+ if ::Rails::VERSION::STRING >= '2.0.0' && deprecated_status_or_extra_options.nil?
+ deprecated_status_or_extra_options = {}
+ end
+
unless block_given?
unless integrate_views?
- @template.metaclass.class_eval do
- define_method :file_exists? do
- true
+ if @template.respond_to?(:finder)
+ (class << @template.finder; self; end).class_eval do
+ define_method :file_exists? do
+ true
+ end
+ end
+ else
+ (class << @template; self; end).class_eval do
+ define_method :file_exists? do
+ true
+ end
end
+ end
+ (class << @template; self; end).class_eval do
define_method :render_file do |*args|
@first_render ||= args[0]
end
@@ -181,43 +202,39 @@ module Spec
end
end
- if expect_render_mock_proxy.send(:__mock_proxy).send(:find_matching_expectation, :render, options)
- expect_render_mock_proxy.render(options)
+ if matching_message_expectation_exists(options)
+ expect_render_mock_proxy.render(options, &block)
@performed_render = true
else
- unless expect_render_mock_proxy.send(:__mock_proxy).send(:find_matching_method_stub, :render, options)
- super(options, deprecated_status, &block)
+ unless matching_stub_exists(options)
+ super(options, deprecated_status_or_extra_options, &block)
end
end
end
+
+ def raise_with_disable_message(old_method, new_method)
+ raise %Q|
+ controller.#{old_method}(:render) has been disabled because it
+ can often produce unexpected results. Instead, you should
+ use the following (before the action):
- if self.respond_to?(:should_receive) && self.respond_to?(:stub!)
- self.send :alias_method, :orig_should_receive, :should_receive
- self.send :alias_method, :orig_stub!, :stub!
- def raise_with_disable_message(old_method, new_method)
- raise %Q|
- controller.#{old_method}(:render) has been disabled because it
- can often produce unexpected results. Instead, you should
- use the following (before the action):
-
- controller.#{new_method}(*args)
+ controller.#{new_method}(*args)
- See the rdoc for #{new_method} for more information.
- |
- end
- def should_receive(*args)
- if args[0] == :render
- raise_with_disable_message("should_receive", "expect_render")
- else
- orig_should_receive(*args)
- end
+ See the rdoc for #{new_method} for more information.
+ |
+ end
+ def should_receive(*args)
+ if args[0] == :render
+ raise_with_disable_message("should_receive", "expect_render")
+ else
+ super
end
- def stub!(*args)
- if args[0] == :render
- raise_with_disable_message("stub!", "stub_render")
- else
- orig_stub!(*args)
- end
+ end
+ def stub!(*args)
+ if args[0] == :render
+ raise_with_disable_message("stub!", "stub_render")
+ else
+ super
end
end
@@ -236,6 +253,15 @@ module Spec
def integrate_views?
@integrate_views
end
+
+ def matching_message_expectation_exists(options)
+ expect_render_mock_proxy.send(:__mock_proxy).send(:find_matching_expectation, :render, options)
+ end
+
+ def matching_stub_exists(options)
+ expect_render_mock_proxy.send(:__mock_proxy).send(:find_matching_method_stub, :render, options)
+ end
+
end
Spec::Example::ExampleGroupFactory.register(:controller, self)
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.rb
index 6f5790cbf..6bdb1823a 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.rb
@@ -11,9 +11,9 @@ module Spec
raise "Can't determine controller class for #{@controller_class_name}" if @controller_class.nil?
@controller = @controller_class.new
-
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
+ @response.session = @request.session
end
def params
@@ -25,14 +25,14 @@ module Spec
end
def session
- request.session
+ @response.session
end
# :call-seq:
# assigns()
#
- # Hash of instance variables to values that are made available to views.
- # == Examples
+ # Hash of instance variables to values that are made available to
+ # views. == Examples
#
# #in thing_controller.rb
# def new
@@ -43,23 +43,16 @@ module Spec
# get 'new'
# assigns[:registration].should == Thing.new
#--
- # NOTE - Even though docs say only use assigns[:key] format, but allowing assigns(:key)
- # in order to avoid breaking old specs.
+ # NOTE - Even though docs only use assigns[:key] format, this supports
+ # assigns(:key) in order to avoid breaking old specs.
#++
def assigns(key = nil)
if key.nil?
- @controller.assigns
- _controller_ivar_proxy
+ _assigns_hash_proxy
else
- @controller.assigns[key]
- _controller_ivar_proxy[key]
+ _assigns_hash_proxy[key]
end
end
-
- protected
- def _controller_ivar_proxy
- @controller_ivar_proxy ||= IvarProxy.new @controller
- end
end
end
end
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb
index 10c1ab002..7e60728ef 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb
@@ -26,15 +26,56 @@ module Spec
# end
# end
class HelperExampleGroup < FunctionalExampleGroup
+ class HelperObject < ActionView::Base
+ def protect_against_forgery?
+ false
+ end
+ end
+
class << self
# The helper name....
def helper_name(name=nil)
- send :include, "#{name}_helper".camelize.constantize
+ @helper_being_described = "#{name}_helper".camelize.constantize
+ send :include, @helper_being_described
+ end
+
+ def helper
+ @helper_object ||= returning HelperObject.new do |helper_object|
+ if @helper_being_described.nil?
+ if described_type.class == Module
+ helper_object.extend described_type
+ end
+ else
+ helper_object.extend @helper_being_described
+ end
+ end
end
end
+
+ # Returns an instance of ActionView::Base with the helper being spec'd
+ # included.
+ #
+ # == Example
+ #
+ # describe PersonHelper do
+ # it "should write a link to person with the name" do
+ # assigns[:person] = mock_model(Person, :full_name => "Full Name", :id => 37, :new_record? => false)
+ # helper.link_to_person.should == %{<a href="/people/37">Full Name</a>}
+ # end
+ # end
+ #
+ # module PersonHelper
+ # def link_to_person
+ # link_to person.full_name, url_for(person)
+ # end
+ # end
+ #
+ def helper
+ self.class.helper
+ end
- # Reverse the load order so that custom helpers which
- # are defined last are also loaded last.
+ # Reverse the load order so that custom helpers which are defined last
+ # are also loaded last.
ActionView::Base.included_modules.reverse.each do |mod|
include mod if mod.parents.include?(ActionView::Helpers)
end
@@ -58,10 +99,11 @@ module Spec
end
def eval_erb(text)
- ERB.new(text).result(binding)
+ helper.instance_eval do
+ ERB.new(text).result(binding)
+ end
end
-
# TODO: BT - Helper Examples should proxy method_missing to a Rails View instance.
# When that is done, remove this method
def protect_against_forgery?
@@ -69,6 +111,12 @@ module Spec
end
Spec::Example::ExampleGroupFactory.register(:helper, self)
+
+ protected
+ def _assigns_hash_proxy
+ @_assigns_hash_proxy ||= AssignsHashProxy.new helper
+ end
+
end
class HelperBehaviourController < ApplicationController #:nodoc:
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/rails_example_group.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/rails_example_group.rb
index a3df05ab5..444740d75 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/rails_example_group.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/rails_example_group.rb
@@ -4,8 +4,10 @@ ActionView::Base.cache_template_extensions = false
module Spec
module Rails
+
module Example
class RailsExampleGroup < Test::Unit::TestCase
+
# Rails >= r8570 uses setup/teardown_fixtures explicitly
before(:each) do
setup_fixtures if self.respond_to?(:setup_fixtures)
@@ -15,53 +17,10 @@ module Spec
end
include Spec::Rails::Matchers
-
- @@model_id = 1000
- # Creates a mock object instance for a +model_class+ with common
- # methods stubbed out.
- # Additional methods may be easily stubbed (via add_stubs) if +stubs+ is passed.
- def mock_model(model_class, options_and_stubs = {})
- # null = options_and_stubs.delete(:null_object)
- # stubs = options_and_stubs
- id = @@model_id
- @@model_id += 1
- options_and_stubs = {
- :id => id,
- :to_param => id.to_s,
- :new_record? => false,
- :errors => stub("errors", :count => 0)
- }.merge(options_and_stubs)
- m = mock("#{model_class.name}_#{id}", options_and_stubs)
- m.send(:__mock_proxy).instance_eval <<-CODE
- def @target.is_a?(other)
- #{model_class}.ancestors.include?(other)
- end
- def @target.kind_of?(other)
- #{model_class}.ancestors.include?(other)
- end
- def @target.instance_of?(other)
- other == #{model_class}
- end
- def @target.class
- #{model_class}
- end
- CODE
- yield m if block_given?
- m
- end
-
- #--
- # TODO - Shouldn't this just be an extension of stub! ??
- # - object.stub!(:method => return_value, :method2 => return_value2, :etc => etc)
- #++
- # Stubs methods on +object+ (if +object+ is a symbol or string a new mock
- # with that name will be created). +stubs+ is a Hash of <tt>method=>value</tt>
- def add_stubs(object, stubs = {}) #:nodoc:
- m = [String, Symbol].index(object.class) ? mock(object.to_s) : object
- stubs.each {|k,v| m.stub!(k).and_return(v)}
- m
- end
+ include Spec::Rails::Mocks
+
Spec::Example::ExampleGroupFactory.default(self)
+
end
end
end
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/render_observer.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/render_observer.rb
index 285e8b657..31086e227 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/render_observer.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/render_observer.rb
@@ -1,4 +1,4 @@
-require 'spec/mocks'
+require 'spec/mocks/framework'
module Spec
module Rails
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/view_example_group.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/view_example_group.rb
index d7b567448..e77d2fbd8 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/view_example_group.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/view_example_group.rb
@@ -28,6 +28,10 @@ module Spec
ensure_that_flash_and_session_work_properly
end
+ after(:each) do
+ ensure_that_base_view_path_is_not_set_across_example_groups
+ end
+
def initialize(defined_description, &implementation) #:nodoc:
super
@controller_class_name = "Spec::Rails::Example::ViewExampleGroupController"
@@ -40,11 +44,6 @@ module Spec
@controller.class.send :public, :flash
end
- def teardown #:nodoc:
- super
- ensure_that_base_view_path_is_not_set_across_example_groups
- end
-
def ensure_that_base_view_path_is_not_set_across_example_groups #:nodoc:
ActionView::Base.base_view_path = nil
end
@@ -73,7 +72,7 @@ module Spec
return options[render_type]
end
end
- raise Exception.new("Unhandled render type in view spec.")
+ return ""
end
def add_helpers(options) #:nodoc:
@@ -84,7 +83,8 @@ module Spec
end
# Renders a template for a View Spec, which then provides access to the result
- # through the +response+.
+ # through the +response+. Also supports render with :inline, which you can
+ # use to spec custom form builders, helpers, etc, in the context of a view.
#
# == Examples
#
@@ -92,6 +92,7 @@ module Spec
# render('/people/list', :helper => MyHelper)
# render('/people/list', :helpers => [MyHelper, MyOtherHelper])
# render(:partial => '/people/_address')
+ # render(:inline => "<% custom_helper 'argument', 'another argument' %>")
#
# See Spec::Rails::Example::ViewExampleGroup for more information.
def render(*args)
@@ -111,7 +112,7 @@ module Spec
defaults = { :layout => false }
options = defaults.merge options
- @controller.instance_variable_set :@params, @request.parameters
+ @controller.send(:params).reverse_merge! @request.parameters
@controller.send :initialize_current_url
@@ -146,6 +147,11 @@ module Spec
end
Spec::Example::ExampleGroupFactory.register(:view, self)
+
+ protected
+ def _assigns_hash_proxy
+ @_assigns_hash_proxy ||= AssignsHashProxy.new @controller
+ end
end
class ViewExampleGroupController < ApplicationController #:nodoc:
@@ -162,7 +168,7 @@ module Spec
rescue
return
end
- template.metaclass.class_eval do
+ (class << template; self; end).class_eval do
include helper_module
end
end
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/example/configuration.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/example/configuration.rb
index 06e322637..22d40a08b 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/example/configuration.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/example/configuration.rb
@@ -1,5 +1,5 @@
require 'spec/example/configuration'
-
+begin
module Spec
module Example
class Configuration
@@ -64,3 +64,8 @@ module Spec
end
end
end
+rescue Exception => e
+ puts e.message
+ puts e.backtrace
+ raise e
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers.rb
index 27ac2ba0f..6c18b2a99 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers.rb
@@ -1,6 +1,7 @@
dir = File.dirname(__FILE__)
require 'spec/rails/matchers/assert_select'
require 'spec/rails/matchers/have_text'
+require 'spec/rails/matchers/include_text'
require 'spec/rails/matchers/redirect_to'
require 'spec/rails/matchers/render_template'
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb
index 12c71ead8..e03029c7f 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb
@@ -39,9 +39,11 @@ module Spec
# Accepts a String or a Regexp, matching a String using ==
# and a Regexp using =~.
#
+ # If response_or_text has a #body, then that is used as to match against
+ # else it uses response_or_text
+ #
# Use this instead of <tt>response.should have_tag()</tt>
- # when you either don't know or don't care where on the page
- # this text appears.
+ # when you want to match the whole string or whole body
#
# == Examples
#
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/include_text.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/include_text.rb
new file mode 100644
index 000000000..4be25bce6
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/include_text.rb
@@ -0,0 +1,54 @@
+module Spec
+ module Rails
+ module Matchers
+
+ class IncludeText #:nodoc:
+
+ def initialize(expected)
+ @expected = expected
+ end
+
+ def matches?(response_or_text)
+ @actual = response_or_text.respond_to?(:body) ? response_or_text.body : response_or_text
+ return actual.include?(expected)
+ end
+
+ def failure_message
+ "expected to find #{expected.inspect} in #{actual.inspect}"
+ end
+
+ def negative_failure_message
+ "expected not to include text #{expected.inspect}"
+ end
+
+ def to_s
+ "include text #{expected.inspect}"
+ end
+
+ private
+ attr_reader :expected
+ attr_reader :actual
+
+ end
+
+
+ # :call-seq:
+ # response.should include_text(expected)
+ # response.should_not include_text(expected)
+ #
+ # Accepts a String, matching using include?
+ #
+ # Use this instead of <tt>response.should have_text()</tt>
+ # when you either don't know or don't care where on the page
+ # this text appears.
+ #
+ # == Examples
+ #
+ # response.should include_text("This text will be in the actual string")
+ def include_text(text)
+ IncludeText.new(text)
+ end
+
+ end
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb
index 7c61c81e7..12ce92516 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb
@@ -39,7 +39,7 @@ module Spec
end
def path_hash(url)
- path = url.sub(%r{^\w+://#{@request.host}}, "").split("?", 2)[0]
+ path = url.sub(%r{^\w+://#{@request.host}(?::\d+)?}, "").split("?", 2)[0]
ActionController::Routing::Routes.recognize_path path
end
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb
index 8c3df3ad2..e36c8bce0 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb
@@ -18,6 +18,10 @@ module Spec
"expected #{@expected.inspect}, got #{@actual.inspect}"
end
+ def negative_failure_message
+ "expected not to render #{@expected.inspect}, but did"
+ end
+
def description
"render template #{@expected.inspect}"
end
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/mocks.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/mocks.rb
new file mode 100644
index 000000000..34e1d18f4
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/mocks.rb
@@ -0,0 +1,115 @@
+module Spec
+ module Rails
+
+ class IllegalDataAccessException < StandardError; end
+
+ module Mocks
+
+ # Creates a mock object instance for a +model_class+ with common
+ # methods stubbed out. Additional methods may be easily stubbed (via
+ # add_stubs) if +stubs+ is passed.
+ def mock_model(model_class, options_and_stubs = {})
+ id = next_id
+ options_and_stubs.reverse_merge!({
+ :id => id,
+ :to_param => id.to_s,
+ :new_record? => false,
+ :errors => stub("errors", :count => 0)
+ })
+ m = mock("#{model_class.name}_#{options_and_stubs[:id]}", options_and_stubs)
+ m.send(:__mock_proxy).instance_eval <<-CODE
+ def @target.is_a?(other)
+ #{model_class}.ancestors.include?(other)
+ end
+ def @target.kind_of?(other)
+ #{model_class}.ancestors.include?(other)
+ end
+ def @target.instance_of?(other)
+ other == #{model_class}
+ end
+ def @target.class
+ #{model_class}
+ end
+ CODE
+ yield m if block_given?
+ m
+ end
+
+ # :call-seq:
+ # stub_model(Model)
+ # stub_model(Model).as_new_record
+ # stub_model(Model, hash_of_stubs)
+ #
+ # Creates an instance of +Model+ that is prohibited from accessing the
+ # database. For each key in +hash_of_stubs+, if the model has a
+ # matching attribute (determined by asking it, which it answers based
+ # on schema.rb) are simply assigned the submitted values. If the model
+ # does not have a matching attribute, the key/value pair is assigned
+ # as a stub return value using RSpec's mocking/stubbing framework.
+ #
+ # new_record? is overridden to return the result of id.nil? This means
+ # that by default new_record? will return false. If you want the
+ # object to behave as a new record, sending it +as_new_record+ will
+ # set the id to nil. You can also explicitly set :id => nil, in which
+ # case new_record? will return true, but using +as_new_record+ makes
+ # the example a bit more descriptive.
+ #
+ # While you can use stub_model in any example (model, view,
+ # controller, helper), it is especially useful in view examples,
+ # which are inherently more state-based than interaction-based.
+ #
+ # == Examples
+ #
+ # stub_model(Person)
+ # stub_model(Person).as_new_record
+ # stub_model(Person, :id => 37)
+ # stub_model(Person) do |person|
+ # model.first_name = "David"
+ # end
+ def stub_model(model_class, stubs = {})
+ stubs = {:id => next_id}.merge(stubs)
+ returning model_class.new do |model|
+ model.id = stubs.delete(:id)
+ (class << model; self; end).class_eval do
+ def connection
+ raise Spec::Rails::IllegalDataAccessException.new("stubbed models are not allowed to access the database")
+ end
+ def new_record?
+ id.nil?
+ end
+ def as_new_record
+ self.id = nil
+ self
+ end
+ end
+ stubs.each do |k,v|
+ if model.has_attribute?(k)
+ model[k] = stubs.delete(k)
+ end
+ end
+ add_stubs(model, stubs)
+ yield model if block_given?
+ end
+ end
+
+ #--
+ # TODO - Shouldn't this just be an extension of stub! ??
+ # - object.stub!(:method => return_value, :method2 => return_value2, :etc => etc)
+ #++
+ # Stubs methods on +object+ (if +object+ is a symbol or string a new mock
+ # with that name will be created). +stubs+ is a Hash of <tt>method=>value</tt>
+ def add_stubs(object, stubs = {}) #:nodoc:
+ m = [String, Symbol].index(object.class) ? mock(object.to_s) : object
+ stubs.each {|k,v| m.stub!(k).and_return(v)}
+ m
+ end
+
+ private
+ @@model_id = 1000
+ def next_id
+ @@model_id += 1
+ end
+
+ end
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb
index 47043a07e..68591125e 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb
@@ -1,23 +1,23 @@
-module Spec
- module Rails
- module VERSION #:nodoc:
- BUILD_TIME_UTC = 20080114022430
- end
- end
-end
-
-# Verify that the plugin has the same revision as RSpec
-if Spec::Rails::VERSION::BUILD_TIME_UTC != Spec::VERSION::BUILD_TIME_UTC
- raise <<-EOF
-
-############################################################################
-Your RSpec on Rails plugin is incompatible with your installed RSpec.
-
-RSpec : #{Spec::VERSION::BUILD_TIME_UTC}
-RSpec on Rails : #{Spec::Rails::VERSION::BUILD_TIME_UTC}
-
-Make sure your RSpec on Rails plugin is compatible with your RSpec gem.
-See http://rspec.rubyforge.org/documentation/rails/install.html for details.
-############################################################################
-EOF
-end
+module Spec
+ module Rails
+ module VERSION #:nodoc:
+ BUILD_TIME_UTC = 20080526202855
+ end
+ end
+end
+
+# Verify that the plugin has the same revision as RSpec
+if Spec::Rails::VERSION::BUILD_TIME_UTC != Spec::VERSION::BUILD_TIME_UTC
+ raise <<-EOF
+
+############################################################################
+Your RSpec on Rails plugin is incompatible with your installed RSpec.
+
+RSpec : #{Spec::VERSION::BUILD_TIME_UTC}
+RSpec on Rails : #{Spec::Rails::VERSION::BUILD_TIME_UTC}
+
+Make sure your RSpec on Rails plugin is compatible with your RSpec gem.
+See http://rspec.rubyforge.org/documentation/rails/install.html for details.
+############################################################################
+EOF
+end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb
index 7a2658d2c..3ebf8909a 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb
@@ -1,41 +1,36 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "autotest", "rails_rspec")
+require File.join(File.dirname(__FILE__), *%w[.. .. .. lib autotest rails_rspec])
+require File.join(File.dirname(__FILE__), *%w[.. .. .. .. rspec spec autotest_matchers])
describe Autotest::RailsRspec, "file mapping" do
before(:each) do
@autotest = Autotest::RailsRspec.new
@autotest.hook :initialize
- @autotest.output = StringIO.new
- @autotest.files.clear
- @autotest.last_mtime = Time.at(0)
- end
-
- def ensure_mapping(examples, impl)
- @autotest.files[@impl] = Time.at(0)
- examples.each do |example|
- @autotest.files[example] = Time.at(0)
- end
- @autotest.tests_for_file(impl).should == examples
end
it "should map model example to model" do
- ensure_mapping(['spec/models/thing_spec.rb'], 'app/models/thing.rb')
+ @autotest.should map_specs(['spec/models/thing_spec.rb']).
+ to('app/models/thing.rb')
end
it "should map controller example to controller" do
- ensure_mapping(['spec/controllers/things_controller_spec.rb'], 'app/controllers/things_controller.rb')
+ @autotest.should map_specs(['spec/controllers/things_controller_spec.rb']).
+ to('app/controllers/things_controller.rb')
end
it "should map view.rhtml" do
- ensure_mapping(['spec/views/things/index.rhtml_spec.rb'], 'app/views/things/index.rhtml')
+ @autotest.should map_specs(['spec/views/things/index.rhtml_spec.rb']).
+ to('app/views/things/index.rhtml')
end
it "should map view.rhtml with underscores in example filename" do
- ensure_mapping(['spec/views/things/index_rhtml_spec.rb'], 'app/views/things/index.rhtml')
+ @autotest.should map_specs(['spec/views/things/index_rhtml_spec.rb']).
+ to('app/views/things/index.rhtml')
end
it "should map view.html.erb" do
- ensure_mapping(['spec/views/things/index.html.erb_spec.rb'], 'app/views/things/index.html.erb')
+ @autotest.should map_specs(['spec/views/things/index.html.erb_spec.rb']).
+ to('app/views/things/index.html.erb')
end
end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
index 400fb829d..eab67f696 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-describe "An AssignsHashProxy" do
+describe "AssignsHashProxy" do
before(:each) do
@object = Object.new
@assigns = Hash.new
@@ -52,4 +52,9 @@ describe "An AssignsHashProxy" do
@proxy.has_key?('foo').should == true
@proxy.has_key?('bar').should == false
end
+
+ it "should sets an instance var" do
+ @proxy['foo'] = 'bar'
+ @object.instance_eval { @foo }.should == 'bar'
+ end
end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb
index 204db15d6..9e40047aa 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb
@@ -32,7 +32,8 @@ describe "a controller spec running in integration mode", :type => :controller d
end
it "should choke if the template doesn't exist" do
- lambda { get 'some_action' }.should raise_error(ActionController::MissingTemplate)
+ error = defined?(ActionController::MissingTemplate) ? ActionController::MissingTemplate : ActionView::MissingTemplate
+ lambda { get 'some_action' }.should raise_error(error)
response.should_not be_success
end
@@ -40,4 +41,22 @@ describe "a controller spec running in integration mode", :type => :controller d
lambda { get 'action_with_errors_in_template' }.should raise_error(ActionView::TemplateError)
response.should_not be_success
end
+
+ describe "nested" do
+ it "should render a template" do
+ get 'action_with_template'
+ response.should be_success
+ response.should have_tag('div', 'This is action_with_template.rhtml')
+ end
+
+ describe "with integrate_views turned off" do
+ integrate_views false
+
+ it "should not care if the template doesn't exist" do
+ get 'some_action'
+ response.should be_success
+ response.should render_template("template/that/does/not/actually/exist")
+ end
+ end
+ end
end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb
index 3cc861d83..afbb69f7a 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb
@@ -17,6 +17,12 @@ require 'controller_spec_controller'
session.should equal(session_before)
end
+ it "should keep the same data in the session before and after the action" do
+ session[:foo] = :bar
+ get 'action_with_template'
+ session[:foo].should == :bar
+ end
+
it "should ensure controller.session is NOT nil before the action" do
controller.session.should_not be_nil
get 'action_with_template'
@@ -47,13 +53,20 @@ require 'controller_spec_controller'
get 'action_with_partial_with_locals', :thing => "something"
end
+ it "should yield to render :update" do
+ template = stub("template")
+ controller.expect_render(:update).and_yield(template)
+ template.should_receive(:replace).with(:bottom, "replace_me", :partial => "non_existent_partial")
+ get 'action_with_render_update'
+ end
+
it "should allow a path relative to RAILS_ROOT/app/views/ when specifying a partial" do
get 'action_with_partial'
response.should render_template("controller_spec/_partial")
end
it "should provide access to flash" do
- get 'action_with_template'
+ get 'action_which_sets_flash'
flash[:flash_key].should == "flash value"
end
@@ -68,8 +81,10 @@ require 'controller_spec_controller'
end
it "should provide access to session" do
- get 'action_with_template'
- session[:session_key].should == "session value"
+ session[:session_key] = "session value"
+ lambda do
+ get 'action_which_gets_session', :expected => "session value"
+ end.should_not raise_error
end
it "should support custom routes" do
@@ -105,6 +120,7 @@ require 'controller_spec_controller'
end
it "should complain when calling stub!(:render) on the controller" do
+ controller.extend Spec::Mocks::Methods
lambda {
controller.stub!(:render)
}.should raise_error(RuntimeError, /stub!\(:render\) has been disabled/)
@@ -161,6 +177,17 @@ describe ControllerSpecController, :type => :controller do
end
end
+describe "A controller spec with controller_name set", :type => :controller do
+ controller_name :controller_spec
+
+ describe "nested" do
+ it "should inherit the controller name" do
+ get 'action_with_template'
+ response.should be_success
+ end
+ end
+end
+
module Spec
module Rails
module Example
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb
index 50defecc5..0ba2cd255 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb
@@ -2,8 +2,11 @@ require File.dirname(__FILE__) + '/../../spec_helper'
Spec::Runner.configuration.global_fixtures = :people
describe ExplicitHelper, :type => :helper do
+ include ExplicitHelper
+
it "should not require naming the helper if describe is passed a type" do
method_in_explicit_helper.should match(/text from a method/)
+ helper.method_in_explicit_helper.should match(/text from a method/)
end
end
@@ -13,17 +16,22 @@ module Spec
describe HelperExampleGroup, :type => :helper do
helper_name :explicit
- it "should have direct access to methods defined in helpers" do
+ it "DEPRECATED should have direct access to methods defined in helpers" do
method_in_explicit_helper.should =~ /text from a method/
end
+ it "should expose the helper with the #helper method" do
+ helper.method_in_explicit_helper.should =~ /text from a method/
+ end
+
it "should have access to named routes" do
rspec_on_rails_specs_url.should == "http://test.host/rspec_on_rails_specs"
rspec_on_rails_specs_path.should == "/rspec_on_rails_specs"
end
it "should fail if the helper method deson't exist" do
- lambda { non_existant_helper_method }.should raise_error(NameError)
+ lambda { non_existent_helper_method }.should raise_error(NameError)
+ lambda { helper.non_existent_helper_method }.should raise_error(NameError)
end
end
@@ -50,6 +58,13 @@ module Spec
lachie.class.should == Person
end
end
+
+ describe "methods from standard helpers", :type => :helper do
+ helper_name :explicit
+ it "should be exposed to the helper" do
+ helper.link_to("Foo","http://bar").should have_tag("a")
+ end
+ end
describe HelperExampleGroup, "included modules", :type => :helper do
helpers = [
@@ -74,9 +89,10 @@ module Spec
helpers << ActionView::Helpers::PaginationHelper rescue nil #removed for 2.0
helpers << ActionView::Helpers::JavaScriptMacrosHelper rescue nil #removed for 2.0
helpers.each do |helper_module|
- it "should include #{helper_module}" do
- self.class.ancestors.should include(helper_module)
- end
+ # it "should include #{helper_module}" do
+ # self.class.ancestors.should include(helper_module)
+ # helper.class.ancestors.should include(helper_module)
+ # end
end
end
@@ -85,6 +101,7 @@ module Spec
describe HelperExampleGroup, "#protect_against_forgery?", :type => :helper do
it "should return false" do
protect_against_forgery?.should be_false
+ helper.protect_against_forgery?.should be_false
end
end
end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb
index 17e47eee8..14159c65a 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb
@@ -208,6 +208,14 @@ describe "A view", :type => :view do
it "should have access to flash data" do
response.should have_tag("div#flash", "flash")
end
+
+ it "should have a controller param" do
+ response.should have_tag("div#controller", "view_spec")
+ end
+
+ it "should have an action param" do
+ response.should have_tag("div#action", "accessor")
+ end
end
describe "A view with a form_tag", :type => :view do
@@ -231,6 +239,13 @@ describe "An instantiated ViewExampleGroupController", :type => :view do
end
end
+describe "render :inline => ...", :type => :view do
+ it "should render ERB right in the spec" do
+ render :inline => %|<%= text_field_tag('field_name', 'Value') %>|
+ response.should have_tag("input[type=?][name=?][value=?]","text","field_name","Value")
+ end
+end
+
module Spec
module Rails
module Example
@@ -243,7 +258,15 @@ module Spec
group.description.to_s.should == "foo"
$nested_group.description.to_s.should == "foo bar"
end
+
+ it "should clear ActionView::Base.base_view_path on teardown" do
+ group = describe("base_view_path_cleared flag", :type => :view) {}
+ example = group.it{}
+
+ ActionView::Base.should_receive(:base_view_path=).with(nil)
+ group.run_after_each(example)
+ end
end
end
end
-end \ No newline at end of file
+end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb
index 9d3e759b2..599249f06 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb
@@ -1,37 +1,48 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require 'spec/mocks/errors'
-describe ActionView::Base, "with RSpec extensions", :type => :view do
- it "should not raise when render has been received" do
- template.expect_render(:partial => "name")
- template.render :partial => "name"
- end
+describe ActionView::Base, "with RSpec extensions:", :type => :view do
- it "should raise when render has NOT been received" do
- template.expect_render(:partial => "name")
- lambda {
- template.verify_rendered
- }.should raise_error
- end
+ describe "expect_render" do
+ it "should not raise when render has been received" do
+ template.expect_render(:partial => "name")
+ template.render :partial => "name"
+ end
- it "should not raise when stubbing and render has been received" do
- template.stub_render(:partial => "name")
- template.render :partial => "name"
+ it "should raise when render has NOT been received" do
+ template.expect_render(:partial => "name")
+ lambda {
+ template.verify_rendered
+ }.should raise_error
+ end
+
+ it "should return something (like a normal mock)" do
+ template.expect_render(:partial => "name").and_return("Little Johnny")
+ result = template.render :partial => "name"
+ result.should == "Little Johnny"
+ end
end
- it "should not raise when stubbing and render has NOT been received" do
- template.stub_render(:partial => "name")
- end
+ describe "stub_render" do
+ it "should not raise when stubbing and render has been received" do
+ template.stub_render(:partial => "name")
+ template.render :partial => "name"
+ end
- it "should not raise when stubbing and render has been received with different options" do
- template.stub_render(:partial => "name")
- template.render :partial => "view_spec/spacer"
- end
+ it "should not raise when stubbing and render has NOT been received" do
+ template.stub_render(:partial => "name")
+ end
+
+ it "should not raise when stubbing and render has been received with different options" do
+ template.stub_render(:partial => "name")
+ template.render :partial => "view_spec/spacer"
+ end
- it "should not raise when stubbing and expecting and render has been received" do
- template.stub_render(:partial => "name")
- template.expect_render(:partial => "name")
- template.render(:partial => "name")
+ it "should not raise when stubbing and expecting and render has been received" do
+ template.stub_render(:partial => "name")
+ template.expect_render(:partial => "name")
+ template.render(:partial => "name")
+ end
end
-
+
end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb
new file mode 100644
index 000000000..1ac3fd7c6
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb
@@ -0,0 +1,70 @@
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+
+describe "include_text" do
+
+ describe "where target is a String" do
+ it 'should match submitted text using a string' do
+ string = 'foo'
+ string.should include_text('foo')
+ end
+
+ it 'should match if the text is contained' do
+ string = 'I am a big piece of text'
+ string.should include_text('big piece')
+ end
+
+ it 'should not match if text is not contained' do
+ string = 'I am a big piece of text'
+ string.should_not include_text('corey')
+ end
+ end
+
+end
+
+describe "include_text", :type => :controller do
+ ['isolation','integration'].each do |mode|
+ if mode == 'integration'
+ integrate_views
+ end
+
+ describe "where target is a response (in #{mode} mode)" do
+ controller_name :render_spec
+
+ it "should pass with exactly matching text" do
+ post 'text_action'
+ response.should include_text("this is the text for this action")
+ end
+
+ it 'should pass with substring matching text' do
+ post 'text_action'
+ response.should include_text('text for this')
+ end
+
+ it "should fail with matching text" do
+ post 'text_action'
+ lambda {
+ response.should include_text("this is NOT the text for this action")
+ }.should fail_with("expected to find \"this is NOT the text for this action\" in \"this is the text for this action\"")
+ end
+
+ it "should fail when a template is rendered" do
+ post 'some_action'
+ failure_message = case mode
+ when 'isolation'
+ /expected to find \"this is the text for this action\" in \"render_spec\/some_action\"/
+ when 'integration'
+ /expected to find \"this is the text for this action\" in \"\"/
+ end
+ lambda {
+ response.should include_text("this is the text for this action")
+ }.should fail_with(failure_message)
+ end
+
+ it "should pass using should_not with incorrect text" do
+ post 'text_action'
+ response.should_not include_text("the accordian guy")
+ end
+ end
+ end
+end
+
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb
index b3c7d7a86..e3ce486d4 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb
@@ -21,6 +21,12 @@ require File.dirname(__FILE__) + '/../../spec_helper'
get 'action_with_redirect_to_somewhere_and_return'
response.should redirect_to(:action => 'somewhere')
end
+
+ it "redirected from an SSL action to a non-SSL action" do
+ request.stub!(:ssl?).and_return true
+ get 'action_with_redirect_to_somewhere'
+ response.should redirect_to(:action => 'somewhere')
+ end
it "redirected to correct path with leading /" do
get 'action_with_redirect_to_somewhere'
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb
index 5dbf576f1..93cca867f 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb
@@ -30,11 +30,10 @@ require File.dirname(__FILE__) + '/../../spec_helper'
it "should match an rjs template" do
xhr :post, 'some_action'
- if ActionView::Base.const_defined?('DEFAULT_TEMPLATE_HANDLER_PREFERENCE') ||
- ActionView::Base.respond_to?(:handler_for_extension) then
- response.should render_template('render_spec/some_action')
- else
+ if Rails::VERSION::STRING < "2.0.0"
response.should render_template('render_spec/some_action.rjs')
+ else
+ response.should render_template('render_spec/some_action')
end
end
@@ -83,4 +82,88 @@ require File.dirname(__FILE__) + '/../../spec_helper'
end.should fail_with("expected \"some_action\", got nil")
end
end
+
+ describe "response.should_not render_template (in #{mode} mode)",
+ :type => :controller do
+ controller_name :render_spec
+ if mode == 'integration'
+ integrate_views
+ end
+
+ it "should pass when the action renders nothing" do
+ post 'action_that_renders_nothing'
+ response.should_not render_template('action_that_renders_nothing')
+ end
+
+ it "should pass when the action renders nothing (symbol)" do
+ post 'action_that_renders_nothing'
+ response.should_not render_template(:action_that_renders_nothing)
+ end
+
+ it "should pass when the action does not render the template" do
+ post 'some_action'
+ response.should_not render_template('some_other_template')
+ end
+
+ it "should pass when the action does not render the template (symbol)" do
+ post 'some_action'
+ response.should_not render_template(:some_other_template)
+ end
+
+ it "should pass when the action does not render the template (named with controller)" do
+ post 'some_action'
+ response.should_not render_template('render_spec/some_other_template')
+ end
+
+ it "should pass when the action renders the template with a different controller" do
+ post 'action_which_renders_template_from_other_controller'
+ response.should_not render_template('action_with_template')
+ end
+
+ it "should pass when the action renders the template (named with controller) with a different controller" do
+ post 'action_which_renders_template_from_other_controller'
+ response.should_not render_template('render_spec/action_with_template')
+ end
+
+ it "should pass when TEXT is rendered" do
+ post 'text_action'
+ response.should_not render_template('some_action')
+ end
+
+ it "should fail when the action renders the template" do
+ post 'some_action'
+ lambda do
+ response.should_not render_template('some_action')
+ end.should fail_with("expected not to render \"some_action\", but did")
+ end
+
+ it "should fail when the action renders the template (symbol)" do
+ post 'some_action'
+ lambda do
+ response.should_not render_template(:some_action)
+ end.should fail_with("expected not to render \"some_action\", but did")
+ end
+
+ it "should fail when the action renders the template (named with controller)" do
+ post 'some_action'
+ lambda do
+ response.should_not render_template('render_spec/some_action')
+ end.should fail_with("expected not to render \"render_spec/some_action\", but did")
+ end
+
+ it "should fail when the action renders the partial" do
+ post 'action_with_partial'
+ lambda do
+ response.should_not render_template('_a_partial')
+ end.should fail_with("expected not to render \"_a_partial\", but did")
+ end
+
+ it "should fail when the action renders the partial (named with controller)" do
+ post 'action_with_partial'
+ lambda do
+ response.should_not render_template('render_spec/_a_partial')
+ end.should fail_with("expected not to render \"render_spec/_a_partial\", but did")
+ end
+
+ end
end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/mocks/ar_classes.rb b/vendor/plugins/rspec_on_rails/spec/rails/mocks/ar_classes.rb
new file mode 100644
index 000000000..05213029a
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/spec/rails/mocks/ar_classes.rb
@@ -0,0 +1,10 @@
+class MockableModel < ActiveRecord::Base
+ has_one :associated_model
+end
+
+class SubMockableModel < MockableModel
+end
+
+class AssociatedModel < ActiveRecord::Base
+ belongs_to :mockable_model
+end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb
index 76793f0a1..9ca171b8e 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb
@@ -1,17 +1,7 @@
require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/ar_classes'
-class MockableModel < ActiveRecord::Base
- has_one :associated_model
-end
-
-class SubMockableModel < MockableModel
-end
-
-class AssociatedModel < ActiveRecord::Base
- belongs_to :mockable_model
-end
-
-describe "mock_model", :type => :view do
+describe "mock_model" do
before(:each) do
@model = mock_model(SubMockableModel)
end
@@ -35,6 +25,15 @@ describe "mock_model", :type => :view do
end
end
+describe "mock_model with stubbed id", :type => :view do
+ before(:each) do
+ @model = mock_model(MockableModel, :id => 1)
+ end
+ it "should be named using the stubbed id value" do
+ @model.instance_variable_get(:@name).should == "MockableModel_1"
+ end
+end
+
describe "mock_model with null_object", :type => :view do
before(:each) do
@model = mock_model(MockableModel, :null_object => true, :mocked_method => "mocked")
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/mocks/stub_model_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/mocks/stub_model_spec.rb
new file mode 100644
index 000000000..c123de009
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/spec/rails/mocks/stub_model_spec.rb
@@ -0,0 +1,78 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/ar_classes'
+
+describe "stub_model" do
+ describe "defaults" do
+ it "should have an id" do
+ stub_model(MockableModel).id.should be > 0
+ end
+
+ it "should say it is not a new record" do
+ stub_model(MockableModel).should_not be_new_record
+ end
+ end
+
+ it "should accept a stub id" do
+ stub_model(MockableModel, :id => 37).id.should == 37
+ end
+
+ it "should say it is a new record when id is set to nil" do
+ stub_model(MockableModel, :id => nil).should be_new_record
+ end
+
+ it "should accept any arbitrary stub" do
+ stub_model(MockableModel, :foo => "bar").foo.should == "bar"
+ end
+
+ it "should accept a stub for save" do
+ stub_model(MockableModel, :save => false).save.should be(false)
+ end
+
+ describe "#as_new_record" do
+ it "should say it is a new record" do
+ stub_model(MockableModel).as_new_record.should be_new_record
+ end
+
+ it "should have a nil id" do
+ stub_model(MockableModel).as_new_record.id.should be(nil)
+ end
+ end
+
+ it "should raise when hitting the db" do
+ lambda do
+ stub_model(MockableModel).save
+ end.should raise_error(Spec::Rails::IllegalDataAccessException, /stubbed models are not allowed to access the database/)
+ end
+
+ it "should increment the id" do
+ first = stub_model(MockableModel)
+ second = stub_model(MockableModel)
+ second.id.should == (first.id + 1)
+ end
+
+end
+
+describe "stub_model as association" do
+ before(:each) do
+ @real = AssociatedModel.create!
+ @stub_model = stub_model(MockableModel)
+ @real.mockable_model = @stub_model
+ end
+
+ it "should pass associated_model == mock" do
+ @stub_model.should == @real.mockable_model
+ end
+
+ it "should pass mock == associated_model" do
+ @real.mockable_model.should == @stub_model
+ end
+end
+
+describe "stub_model with a block" do
+ it "should yield the model" do
+ model = stub_model(MockableModel) do |block_arg|
+ @block_arg = block_arg
+ end
+ model.should be(@block_arg)
+ end
+end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/sample_modified_fixture.rb b/vendor/plugins/rspec_on_rails/spec/rails/sample_modified_fixture.rb
new file mode 100644
index 000000000..832049768
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/spec/rails/sample_modified_fixture.rb
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../spec_helper'
+
+describe "A sample spec", :type => :model do
+ fixtures :animals
+ it "should pass" do
+ animals(:pig).name.should == "Piggy"
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/sample_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/sample_spec.rb
index 7cd1d4e81..a88e6070e 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/sample_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/sample_spec.rb
@@ -1,7 +1,8 @@
require File.dirname(__FILE__) + '/../spec_helper'
-describe "A sample spec" do
+describe "A sample spec", :type => :model do
+ fixtures :animals
it "should pass" do
- true.should === true
+ animals(:pig).name.should == "Pig"
end
end \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb
index 957bd1089..b70f10d90 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb
@@ -2,12 +2,24 @@ require File.dirname(__FILE__) + '/../spec_helper'
describe "script/spec_server file", :shared => true do
attr_accessor :tmbundle_install_directory
+ attr_reader :animals_yml_path, :original_animals_content
+
+ before do
+ @animals_yml_path = File.expand_path("#{RAILS_ROOT}/spec/fixtures/animals.yml")
+ @original_animals_content = File.read(animals_yml_path)
+ end
after do
- system "kill -9 #{@pid}"
+ File.open(animals_yml_path, "w") do |f|
+ f.write original_animals_content
+ end
end
- it "runs a spec" do
+ after(:each) do
+ system "lsof -i tcp:8989 | sed /COMMAND/d | awk '{print $2}' | xargs kill"
+ end
+
+ xit "runs a spec" do
dir = File.dirname(__FILE__)
output = ""
Timeout.timeout(10) do
@@ -17,54 +29,49 @@ describe "script/spec_server file", :shared => true do
end
end
- unless $?.exitstatus == 0
+ if $?.exitstatus != 0 || output !~ /0 failures/
flunk "command 'script/spec spec/sample_spec' failed\n#{output}"
end
- end
- def start_spec_server
- create_spec_server_pid_file
- start_spec_server_process
- end
+ fixtures = YAML.load(@original_animals_content)
+ fixtures['pig']['name'] = "Piggy"
+
+ File.open(animals_yml_path, "w") do |f|
+ f.write YAML.dump(fixtures)
+ end
+
+ Timeout.timeout(10) do
+ loop do
+ output = `#{RAILS_ROOT}/script/spec #{dir}/sample_modified_fixture.rb --drb 2>&1`
+ break unless output.include?("No server is running")
+ end
+ end
- def create_spec_server_pid_file
- current_dir = File.dirname(__FILE__)
- pid_dir = "#{Dir.tmpdir}/#{Time.now.to_i}"
- @spec_server_pid_file = "#{pid_dir}/spec_server.pid"
- FileUtils.mkdir_p pid_dir
- system "touch #{@spec_server_pid_file}"
- @rspec_path = File.expand_path("#{current_dir}/../../../rspec/lib")
+ if $?.exitstatus != 0 || output !~ /0 failures/
+ flunk "command 'script/spec spec/sample_modified_fixture' failed\n#{output}"
+ end
end
- def start_spec_server_process
+ def start_spec_server
dir = File.dirname(__FILE__)
- spec_server_cmd = %Q|export HOME=#{Dir.tmpdir}; |
- spec_server_cmd << %Q|ruby -e 'system("echo " + Process.pid.to_s + " > #{@spec_server_pid_file}"); |
- spec_server_cmd << %Q|$LOAD_PATH.unshift("#{@rspec_path}"); require "spec"; |
- spec_server_cmd << %Q|load "#{RAILS_ROOT}/script/spec_server"' &|
- system spec_server_cmd
+ Thread.start do
+ system "cd #{RAILS_ROOT}; script/spec_server"
+ end
file_content = ""
- Timeout.timeout(5) do
- loop do
- file_content = File.read(@spec_server_pid_file)
- break unless file_content.blank?
- end
- end
- @pid = Integer(File.read(@spec_server_pid_file))
end
end
describe "script/spec_server file without TextMate bundle" do
it_should_behave_like "script/spec_server file"
- before do
+ before(:each) do
start_spec_server
end
end
describe "script/spec_server file with TextMate bundle" do
it_should_behave_like "script/spec_server file"
- before do
+ before(:each) do
dir = File.dirname(__FILE__)
@tmbundle_install_directory = File.expand_path("#{Dir.tmpdir}/Library/Application Support/TextMate/Bundles")
@bundle_name = "RSpec.tmbundle"
@@ -77,7 +84,7 @@ describe "script/spec_server file with TextMate bundle" do
start_spec_server
end
- after do
+ after(:each) do
bundle_file_to_remove = "#{tmbundle_install_directory}/#{@bundle_name}"
if bundle_file_to_remove == "/"
raise "bundle file path resolved to '/' - could not call rm"
diff --git a/vendor/plugins/rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb b/vendor/plugins/rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb
index ce8bc186c..769f4c588 100644
--- a/vendor/plugins/rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb
+++ b/vendor/plugins/rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb
@@ -10,11 +10,23 @@ class ControllerSpecController < ActionController::Base
end
def action_with_template
- session[:session_key] = "session value"
- flash[:flash_key] = "flash value"
render :template => "controller_spec/action_with_template"
end
+ def action_which_sets_flash
+ flash[:flash_key] = "flash value"
+ render :text => ""
+ end
+
+ def action_which_gets_session
+ raise "expected #{params[:session_key].inspect}\ngot #{session[:session_key].inspect}" unless (session[:session_key] == params[:expected])
+ render :text => ""
+ end
+
+ def action_which_sets_session
+ session[:session_key] = "session value"
+ end
+
def action_with_partial
render :partial => "controller_spec/partial"
end
@@ -45,5 +57,12 @@ class ControllerSpecController < ActionController::Base
flash[:before_reset] = 'available'
reset_session
end
+
+ def action_with_render_update
+ render :update do |page|
+ page.replace :bottom, 'replace_me',
+ :partial => 'non_existent_partial'
+ end
+ end
end
diff --git a/vendor/plugins/rspec_on_rails/spec_resources/controllers/render_spec_controller.rb b/vendor/plugins/rspec_on_rails/spec_resources/controllers/render_spec_controller.rb
index 7ab76eefa..b546abe4c 100644
--- a/vendor/plugins/rspec_on_rails/spec_resources/controllers/render_spec_controller.rb
+++ b/vendor/plugins/rspec_on_rails/spec_resources/controllers/render_spec_controller.rb
@@ -19,4 +19,8 @@ class RenderSpecController < ApplicationController
def action_with_partial
render :partial => "a_partial"
end
+
+ def action_that_renders_nothing
+ render :nothing => true
+ end
end
diff --git a/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/accessor.rhtml b/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/accessor.rhtml
index ef636f61c..1d6f96b01 100644
--- a/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/accessor.rhtml
+++ b/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/accessor.rhtml
@@ -1,3 +1,5 @@
<div id="session"><%= session[:key] %></div>
<div id="params"><%= params[:key] %></div>
-<div id="flash"><%= flash[:key] %></div> \ No newline at end of file
+<div id="flash"><%= flash[:key] %></div>
+<div id="controller"><%= params[:controller] %></div>
+<div id="action"><%= params[:action] %></div>
diff --git a/vendor/plugins/rspec_on_rails/tasks/rspec.rake b/vendor/plugins/rspec_on_rails/tasks/rspec.rake
index 722854740..0230234fa 100644
--- a/vendor/plugins/rspec_on_rails/tasks/rspec.rake
+++ b/vendor/plugins/rspec_on_rails/tasks/rspec.rake
@@ -53,14 +53,14 @@ namespace :spec do
desc "Run the specs under vendor/plugins (except RSpec's own)"
Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec_on_rails/*")
+ t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
end
namespace :plugins do
desc "Runs the examples for rspec_on_rails"
Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['vendor/plugins/rspec_on_rails/spec/**/*_spec.rb']
+ t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb']
end
end