aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/plugins/rspec_on_rails/spec
diff options
context:
space:
mode:
authorfrancis <francis>2008-01-23 01:55:01 +0000
committerfrancis <francis>2008-01-23 01:55:01 +0000
commitf906a3ab0b3f1ed0f18e5b605787cfa7c084b19a (patch)
treec7c35b6831f57f24f7d7cab780c065f4d3cd3f9a /vendor/plugins/rspec_on_rails/spec
parentfdaa98e06ba6d6f8b62480a83e9ecffdbcb21402 (diff)
Upgrade to new rspec_on_rails (that is with rspec 1.1.2)
Diffstat (limited to 'vendor/plugins/rspec_on_rails/spec')
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/dsl/assigns_hash_proxy_spec.rb55
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/dsl/behaviour_factory_spec.rb73
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/dsl/configuration_spec.rb56
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/dsl/controller_isolation_spec.rb43
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/dsl/controller_spec_spec.rb158
-rwxr-xr-xvendor/plugins/rspec_on_rails/spec/rails/dsl/helper_spec_spec.rb92
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/dsl/ivar_proxy_spec.rb64
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/dsl/model_spec_spec.rb14
-rwxr-xr-xvendor/plugins/rspec_on_rails/spec/rails/dsl/shared_behaviour_spec.rb16
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/dsl/test_unit_assertion_accessibility_spec.rb28
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/dsl/view_spec_spec.rb240
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb17
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/extensions/active_record_spec.rb5
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/matchers/assert_select_spec.rb72
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/matchers/description_generation_spec.rb25
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb8
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb51
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb36
-rw-r--r--vendor/plugins/rspec_on_rails/spec/spec_helper.rb39
20 files changed, 151 insertions, 943 deletions
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 8098be519..7a2658d2c 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
@@ -4,6 +4,7 @@ require File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "autotest", "
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)
@@ -36,4 +37,5 @@ describe Autotest::RailsRspec, "file mapping" do
it "should map view.html.erb" do
ensure_mapping(['spec/views/things/index.html.erb_spec.rb'], 'app/views/things/index.html.erb')
end
+
end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/dsl/assigns_hash_proxy_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/dsl/assigns_hash_proxy_spec.rb
deleted file mode 100644
index 47532b3a2..000000000
--- a/vendor/plugins/rspec_on_rails/spec/rails/dsl/assigns_hash_proxy_spec.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-
-describe "An AssignsHashProxy" do
- before(:each) do
- @object = Object.new
- @assigns = Hash.new
- @object.stub!(:assigns).and_return(@assigns)
- @proxy = Spec::Rails::DSL::AssignsHashProxy.new(@object)
- end
-
- it "has [] accessor" do
- @proxy['foo'] = 'bar'
- @assigns['foo'].should == 'bar'
- @proxy['foo'].should == 'bar'
- end
-
- it "checks for string key before symbol key" do
- @assigns[:foo] = 2
- @proxy[:foo].should == 2
- end
-
- it "checks for string key before symbol key" do
- @assigns['foo'] = false
- @assigns[:foo] = 2
- @proxy[:foo].should == false
- end
-
- it "each method iterates through each element like a Hash" do
- values = {
- 'foo' => 1,
- 'bar' => 2,
- 'baz' => 3
- }
- @proxy['foo'] = values['foo']
- @proxy['bar'] = values['bar']
- @proxy['baz'] = values['baz']
-
- @proxy.each do |key, value|
- key.should == key
- value.should == values[key]
- end
- end
-
- it "delete method deletes the element of passed in key" do
- @proxy['foo'] = 'bar'
- @proxy.delete('foo').should == 'bar'
- @proxy['foo'].should be_nil
- end
-
- it "has_key? detects the presence of a key" do
- @proxy['foo'] = 'bar'
- @proxy.has_key?('foo').should == true
- @proxy.has_key?('bar').should == false
- end
-end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/dsl/behaviour_factory_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/dsl/behaviour_factory_spec.rb
deleted file mode 100644
index 84d43bfcd..000000000
--- a/vendor/plugins/rspec_on_rails/spec/rails/dsl/behaviour_factory_spec.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-
-describe "the BehaviourFactory" do
- it "should return a ModelBehaviour when given :behaviour_type => :model" do
- Spec::DSL::BehaviourFactory.create("name", :behaviour_type => :model) {
- }.should be_an_instance_of(Spec::Rails::DSL::ModelBehaviour)
- end
-
- it "should return a ModelBehaviour when given :spec_path => '/blah/spec/models/'" do
- Spec::DSL::BehaviourFactory.create("name", :spec_path => '/blah/spec/models/blah.rb') {
- }.should be_an_instance_of(Spec::Rails::DSL::ModelBehaviour)
- end
-
- it "should return a ModelBehaviour when given :spec_path => '\\blah\\spec\\models\\' (windows format)" do
- Spec::DSL::BehaviourFactory.create("name", :spec_path => '\\blah\\spec\\models\\blah.rb') {
- }.should be_an_instance_of(Spec::Rails::DSL::ModelBehaviour)
- end
-
- it "should return a ViewBehaviour when given :behaviour_type => :model" do
- Spec::DSL::BehaviourFactory.create("name", :behaviour_type => :view) {
- }.should be_an_instance_of(Spec::Rails::DSL::ViewBehaviour)
- end
-
- it "should return a ViewBehaviour when given :spec_path => '/blah/spec/views/'" do
- Spec::DSL::BehaviourFactory.create("name", :spec_path => '/blah/spec/views/blah.rb') {
- }.should be_an_instance_of(Spec::Rails::DSL::ViewBehaviour)
- end
-
- it "should return a ModelBehaviour when given :spec_path => '\\blah\\spec\\views\\' (windows format)" do
- Spec::DSL::BehaviourFactory.create("name", :spec_path => '\\blah\\spec\\views\\blah.rb') {
- }.should be_an_instance_of(Spec::Rails::DSL::ViewBehaviour)
- end
-
- it "should return a HelperBehaviour when given :behaviour_type => :helper" do
- Spec::DSL::BehaviourFactory.create("name", :behaviour_type => :helper) {
- }.should be_an_instance_of(Spec::Rails::DSL::HelperBehaviour)
- end
-
- it "should return a HelperBehaviour when given :spec_path => '/blah/spec/helpers/'" do
- Spec::DSL::BehaviourFactory.create("name", :spec_path => '/blah/spec/helpers/blah.rb') {
- }.should be_an_instance_of(Spec::Rails::DSL::HelperBehaviour)
- end
-
- it "should return a ModelBehaviour when given :spec_path => '\\blah\\spec\\helpers\\' (windows format)" do
- Spec::DSL::BehaviourFactory.create("name", :spec_path => '\\blah\\spec\\helpers\\blah.rb') {
- }.should be_an_instance_of(Spec::Rails::DSL::HelperBehaviour)
- end
-
- it "should return a ControllerBehaviour when given :behaviour_type => :controller" do
- Spec::DSL::BehaviourFactory.create("name", :behaviour_type => :controller) {
- }.should be_an_instance_of(Spec::Rails::DSL::ControllerBehaviour)
- end
-
- it "should return a ControllerBehaviour when given :spec_path => '/blah/spec/controllers/'" do
- Spec::DSL::BehaviourFactory.create("name", :spec_path => '/blah/spec/controllers/blah.rb') {
- }.should be_an_instance_of(Spec::Rails::DSL::ControllerBehaviour)
- end
-
- it "should return a ModelBehaviour when given :spec_path => '\\blah\\spec\\controllers\\' (windows format)" do
- Spec::DSL::BehaviourFactory.create("name", :spec_path => '\\blah\\spec\\controllers\\blah.rb') {
- }.should be_an_instance_of(Spec::Rails::DSL::ControllerBehaviour)
- end
-
- it "should favor the :behaviour_type over the :spec_path" do
- Spec::DSL::BehaviourFactory.create("name", :spec_path => '/blah/spec/models/blah.rb', :behaviour_type => :controller) {
- }.should be_an_instance_of(Spec::Rails::DSL::ControllerBehaviour)
- end
-
- it "should create a Spec::DSL::Behaviour if :shared => true" do
- Spec::DSL::BehaviourFactory.create("name", :spec_path => '/blah/spec/models/blah.rb', :behaviour_type => :controller, :shared => true) {
- }.should be_an_instance_of(Spec::DSL::Behaviour)
- end
-end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/dsl/configuration_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/dsl/configuration_spec.rb
deleted file mode 100644
index 4984222e1..000000000
--- a/vendor/plugins/rspec_on_rails/spec/rails/dsl/configuration_spec.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-
-module Spec
- module DSL
- describe Configuration do
- before(:each) { @config = Configuration.new }
-
- it "should default use_transactional_fixtures to true" do
- @config.use_transactional_fixtures.should be(true)
- end
-
- it "should let you set use_transactional_fixtures false" do
- @config.use_transactional_fixtures = false
- @config.use_transactional_fixtures.should be(false)
- end
-
- it "should let you set use_transactional_fixtures true" do
- @config.use_transactional_fixtures = true
- @config.use_transactional_fixtures.should be(true)
- end
-
- it "should default use_instantiated_fixtures to false" do
- @config.use_instantiated_fixtures.should be(false)
- end
-
- it "should let you set use_instantiated_fixtures false" do
- @config.use_instantiated_fixtures = false
- @config.use_instantiated_fixtures.should be(false)
- end
-
- it "should let you set use_instantiated_fixtures true" do
- @config.use_instantiated_fixtures = true
- @config.use_instantiated_fixtures.should be(true)
- end
-
- it "should default fixture_path to RAILS_ROOT + '/spec/fixtures'" do
- @config.fixture_path.should == RAILS_ROOT + '/spec/fixtures'
- end
-
- it "should let you set fixture_path false" do
- @config.fixture_path = "/new/path"
- @config.fixture_path.should == "/new/path"
- end
-
- it "should default global_fixtures to []" do
- @config.global_fixtures.should == []
- end
-
- it "should let you set global_fixtures false" do
- @config.global_fixtures << :blah
- @config.global_fixtures.should == [:blah]
- end
-
- end
- end
-end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/dsl/controller_isolation_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/dsl/controller_isolation_spec.rb
deleted file mode 100644
index 0c0eea1d8..000000000
--- a/vendor/plugins/rspec_on_rails/spec/rails/dsl/controller_isolation_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'controller_spec_controller'
-
-describe "a controller spec running in isolation mode", :behaviour_type => :controller do
- controller_name :controller_spec
-
- 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
-
- it "should not care if the template has errors" do
- get 'action_with_errors_in_template'
- response.should be_success
- response.should render_template("action_with_errors_in_template")
- end
-end
-
-describe "a controller spec running in integration mode", :behaviour_type => :controller do
- controller_name :controller_spec
- integrate_views
-
- before(:each) do
- controller.class.send(:define_method, :rescue_action) { |e| raise e }
- end
-
- 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
-
- it "should choke if the template doesn't exist" do
- lambda { get 'some_action' }.should raise_error(ActionController::MissingTemplate)
- response.should_not be_success
- end
-
- it "should choke if the template has errors" do
- lambda { get 'action_with_errors_in_template' }.should raise_error(ActionView::TemplateError)
- response.should_not be_success
- end
-end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/dsl/controller_spec_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/dsl/controller_spec_spec.rb
deleted file mode 100644
index bfe7ea638..000000000
--- a/vendor/plugins/rspec_on_rails/spec/rails/dsl/controller_spec_spec.rb
+++ /dev/null
@@ -1,158 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'controller_spec_controller'
-
-['integration', 'isolation'].each do |mode|
- describe "A controller example running in #{mode} mode", :behaviour_type => :controller do
- controller_name :controller_spec
- integrate_views if mode == 'integration'
-
- it "should provide controller.session as session" do
- get 'action_with_template'
- session.should equal(controller.session)
- end
-
- it "should provide the same session object before and after the action" do
- session_before = session
- get 'action_with_template'
- session.should equal(session_before)
- end
-
- it "should ensure controller.session is NOT nil before the action" do
- controller.session.should_not be_nil
- get 'action_with_template'
- end
-
- it "should ensure controller.session is NOT nil after the action" do
- get 'action_with_template'
- controller.session.should_not be_nil
- end
-
- it "should allow specifying a partial with partial name only" do
- get 'action_with_partial'
- response.should render_template("_partial")
- end
-
- it "should allow specifying a partial with expect_render" do
- controller.expect_render(:partial => "controller_spec/partial")
- get 'action_with_partial'
- end
-
- it "should allow specifying a partial with expect_render with object" do
- controller.expect_render(:partial => "controller_spec/partial", :object => "something")
- get 'action_with_partial_with_object', :thing => "something"
- end
-
- it "should allow specifying a partial with expect_render with locals" do
- controller.expect_render(:partial => "controller_spec/partial", :locals => {:thing => "something"})
- get 'action_with_partial_with_locals', :thing => "something"
- 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'
- flash[:flash_key].should == "flash value"
- end
-
- it "should provide access to flash values set after a session reset" do
- get 'action_setting_flash_after_session_reset'
- flash[:after_reset].should == "available"
- end
-
- it "should not provide access to flash values set before a session reset" do
- get 'action_setting_flash_before_session_reset'
- flash[:before_reset].should_not == "available"
- end
-
- it "should provide access to session" do
- get 'action_with_template'
- session[:session_key].should == "session value"
- end
-
- it "should support custom routes" do
- route_for(:controller => "custom_route_spec", :action => "custom_route").should == "/custom_route"
- end
-
- it "should support existing routes" do
- route_for(:controller => "controller_spec", :action => "some_action").should == "/controller_spec/some_action"
- end
-
- it "should expose the assigns hash directly" do
- get 'action_setting_the_assigns_hash'
- assigns[:direct_assigns_key].should == :direct_assigns_key_value
- end
-
- it "should complain when calling should_receive(:render) on the controller" do
- lambda {
- controller.should_receive(:render)
- }.should raise_error(RuntimeError, /should_receive\(:render\) has been disabled/)
- end
-
- it "should complain when calling stub!(:render) on the controller" do
- lambda {
- controller.stub!(:render)
- }.should raise_error(RuntimeError, /stub!\(:render\) has been disabled/)
- end
-
- it "should NOT complain when calling should_receive with arguments other than :render" do
- controller.should_receive(:anything_besides_render)
- lambda {
- controller.rspec_verify
- }.should raise_error(Exception, /expected :anything_besides_render/)
- end
- end
-
- describe "Given a controller spec for RedirectSpecController running in #{mode} mode", :behaviour_type => :controller do
- controller_name :redirect_spec
- integrate_views if mode == 'integration'
-
- it "a redirect should ignore the absence of a template" do
- get 'action_with_redirect_to_somewhere'
- response.should be_redirect
- response.redirect_url.should == "http://test.host/redirect_spec/somewhere"
- response.should redirect_to("http://test.host/redirect_spec/somewhere")
- end
-
- it "a call to response.should redirect_to should fail if no redirect" do
- get 'action_with_no_redirect'
- lambda {
- response.redirect?.should be_true
- }.should fail
- lambda {
- response.should redirect_to("http://test.host/redirect_spec/somewhere")
- }.should fail_with("expected redirect to \"http://test.host/redirect_spec/somewhere\", got no redirect")
- end
- end
-
- describe "Given a controller spec running in #{mode} mode", :behaviour_type => :controller do
- integrate_views if mode == 'integration'
- it "a spec in a context without controller_name set should fail with a useful warning",
- :should_raise => [
- Spec::Expectations::ExpectationNotMetError,
- /You have to declare the controller name in controller specs/
- ] do
- end
- end
-
-end
-
-describe ControllerSpecController, :behaviour_type => :controller do
- it "should not require naming the controller if describe is passed a type" do
- end
-end
-
-module Spec
- module Rails
- module DSL
- describe ControllerBehaviour do
- it "should tell you its behaviour_type is :controller" do
- behaviour = ControllerBehaviour.new("") {}
- behaviour.behaviour_type.should == :controller
- end
- end
- end
- end
-end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/dsl/helper_spec_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/dsl/helper_spec_spec.rb
deleted file mode 100755
index 102e06097..000000000
--- a/vendor/plugins/rspec_on_rails/spec/rails/dsl/helper_spec_spec.rb
+++ /dev/null
@@ -1,92 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-Spec::Runner.configuration.global_fixtures = :people
-
-describe "HelperBehaviour", :behaviour_type => :helper do
- helper_name :explicit
-
- it "should have direct access to methods defined in helpers" do
- method_in_explicit_helper.should =~ /text from a method/
- end
-end
-
-
-describe "HelperBehaviour#eval_erb", :behaviour_type => :helper do
- helper_name :explicit
-
- it "should support methods that accept blocks" do
- eval_erb("<% prepend 'foo' do %>bar<% end %>").should == "foobar"
- end
-end
-
-describe "HelperBehaviour.fixtures", :behaviour_type => :helper do
- helper_name :explicit
- fixtures :animals
-
- it "loads fixtures" do
- pig = animals(:pig)
- pig.class.should == Animal
- end
-
- it "loads global fixtures" do
- lachie = people(:lachie)
- lachie.class.should == Person
- end
-end
-
-describe "HelperBehaviour included modules", :behaviour_type => :helper do
- helpers = [
- ActionView::Helpers::ActiveRecordHelper,
- ActionView::Helpers::AssetTagHelper,
- ActionView::Helpers::BenchmarkHelper,
- ActionView::Helpers::CacheHelper,
- ActionView::Helpers::CaptureHelper,
- ActionView::Helpers::DateHelper,
- ActionView::Helpers::DebugHelper,
- ActionView::Helpers::FormHelper,
- ActionView::Helpers::FormOptionsHelper,
- ActionView::Helpers::FormTagHelper,
- ActionView::Helpers::JavaScriptHelper,
- ActionView::Helpers::JavaScriptMacrosHelper,
- ActionView::Helpers::NumberHelper,
- ActionView::Helpers::PrototypeHelper,
- ActionView::Helpers::PrototypeHelper::JavaScriptGenerator::GeneratorMethods,
- ActionView::Helpers::ScriptaculousHelper,
- ActionView::Helpers::TagHelper,
- ActionView::Helpers::TextHelper,
- ActionView::Helpers::UrlHelper
- ]
- helpers << ActionView::Helpers::PaginationHelper unless ENV['RSPEC_RAILS_VERSION'] == 'edge'
- helpers.each do |helper_module|
- it "should include #{helper_module}" do
- self.class.ancestors.should include(helper_module)
- end
- end
-end
-
-describe ExplicitHelper, :behaviour_type => :helper do
- it "should not require naming the helper if describe is passed a type" do
- method_in_explicit_helper.should match(/text from a method/)
- end
-end
-
-module Spec
- module Rails
- module DSL
- describe HelperBehaviour do
- it "should tell you its behaviour_type is :helper" do
- behaviour = HelperBehaviour.new("") {}
- behaviour.behaviour_type.should == :helper
- end
- end
- end
- end
-end
-
-module Bug11223
- # see http://rubyforge.org/tracker/index.php?func=detail&aid=11223&group_id=797&atid=3149
- describe 'Accessing flash from helper spec', :behaviour_type => :helper do
- it 'should not raise an error' do
- lambda { flash['test'] }.should_not raise_error
- end
- end
-end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/dsl/ivar_proxy_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/dsl/ivar_proxy_spec.rb
deleted file mode 100644
index c2558d78d..000000000
--- a/vendor/plugins/rspec_on_rails/spec/rails/dsl/ivar_proxy_spec.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-
-describe "IvarProxy setup", :shared => true do
- before do
- @object = Object.new
- @proxy = Spec::Rails::DSL::IvarProxy.new(@object)
- end
-end
-
-describe "IvarProxy" do
- it_should_behave_like "IvarProxy setup"
-
- it "has [] accessor" do
- @proxy['foo'] = 'bar'
- @object.instance_variable_get(:@foo).should == 'bar'
- @proxy['foo'].should == 'bar'
- end
-
- it "iterates through each element like a Hash" do
- values = {
- 'foo' => 1,
- 'bar' => 2,
- 'baz' => 3
- }
- @proxy['foo'] = values['foo']
- @proxy['bar'] = values['bar']
- @proxy['baz'] = values['baz']
-
- @proxy.each do |key, value|
- key.should == key
- value.should == values[key]
- end
- end
-
- it "detects the presence of a key" do
- @proxy['foo'] = 'bar'
- @proxy.has_key?('foo').should == true
- @proxy.has_key?('bar').should == false
- end
-end
-
-describe "IvarProxy", "#delete" do
- it_should_behave_like "IvarProxy setup"
-
- it "deletes the element with key" do
- @proxy['foo'] = 'bar'
- @proxy.delete('foo').should == 'bar'
- @proxy['foo'].should be_nil
- end
-
- it "deletes nil instance variables" do
- @proxy['foo'] = nil
- @object.instance_variables.should include("@foo")
- @proxy.delete('foo').should == nil
- @proxy['foo'].should be_nil
- @object.instance_variables.should_not include("@foo")
- end
-
- it "returns nil when key does not exist" do
- @proxy['foo'].should be_nil
- @proxy.delete('foo').should == nil
- @proxy['foo'].should be_nil
- end
-end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/dsl/model_spec_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/dsl/model_spec_spec.rb
deleted file mode 100644
index 789b50d82..000000000
--- a/vendor/plugins/rspec_on_rails/spec/rails/dsl/model_spec_spec.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-
-module Spec
- module Rails
- module DSL
- describe ModelBehaviour do
- it "should tell you its behaviour_type is :model" do
- behaviour = ModelBehaviour.new("") {}
- behaviour.behaviour_type.should == :model
- end
- end
- end
- end
-end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/dsl/shared_behaviour_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/dsl/shared_behaviour_spec.rb
deleted file mode 100755
index 20461f02e..000000000
--- a/vendor/plugins/rspec_on_rails/spec/rails/dsl/shared_behaviour_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-
-describe "A shared view behaviour", :shared => true do
- it "should have some tag with some text" do
- response.should have_tag('div', 'This is text from a method in the ViewSpecHelper')
- end
-end
-
-describe "A view behaviour", :behaviour_type => :view do
- it_should_behave_like "A shared view behaviour"
-
- before(:each) do
- render "view_spec/implicit_helper"
- end
-end
-
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/dsl/test_unit_assertion_accessibility_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/dsl/test_unit_assertion_accessibility_spec.rb
deleted file mode 100644
index 18eb50593..000000000
--- a/vendor/plugins/rspec_on_rails/spec/rails/dsl/test_unit_assertion_accessibility_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-
-['model','view','helper'].each do |context|
- describe "A #{context} spec should be able to access 'test/unit' assertions", :behaviour_type => context.to_sym do
-
- it "like assert_equal" do
- assert_equal 1, 1
- lambda {
- assert_equal 1, 2
- }.should raise_error(Test::Unit::AssertionFailedError)
- end
-
- end
-end
-
-['integration', 'isolation'].each do |mode|
- describe "A controller spec in #{mode} mode should be able to access 'test/unit' assertions", :behaviour_type => :controller do
- controller_name :controller_spec
- integrate_views if mode == 'integration'
-
- it "like assert_equal" do
- assert_equal 1, 1
- lambda {
- assert_equal 1, 2
- }.should raise_error(Test::Unit::AssertionFailedError)
- end
- end
-end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/dsl/view_spec_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/dsl/view_spec_spec.rb
deleted file mode 100644
index 65aa6b8bd..000000000
--- a/vendor/plugins/rspec_on_rails/spec/rails/dsl/view_spec_spec.rb
+++ /dev/null
@@ -1,240 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-
-describe "A template with an implicit helper", :behaviour_type => :view do
- before(:each) do
- render "view_spec/implicit_helper"
- end
-
- it "should include the helper" do
- response.should have_tag('div', :content => "This is text from a method in the ViewSpecHelper")
- end
-
- it "should include the application helper" do
- response.should have_tag('div', :content => "This is text from a method in the ApplicationHelper")
- end
-end
-
-describe "A template requiring an explicit helper", :behaviour_type => :view do
- before(:each) do
- render "view_spec/explicit_helper", :helper => 'explicit'
- end
-
- it "should include the helper if specified" do
- response.should have_tag('div', :content => "This is text from a method in the ExplicitHelper")
- end
-
- it "should include the application helper" do
- response.should have_tag('div', :content => "This is text from a method in the ApplicationHelper")
- end
-end
-
-describe "A template requiring multiple explicit helpers", :behaviour_type => :view do
- before(:each) do
- render "view_spec/multiple_helpers", :helpers => ['explicit', 'more_explicit']
- end
-
- it "should include all specified helpers" do
- response.should have_tag('div', :content => "This is text from a method in the ExplicitHelper")
- response.should have_tag('div', :content => "This is text from a method in the MoreExplicitHelper")
- end
-
- it "should include the application helper" do
- response.should have_tag('div', :content => "This is text from a method in the ApplicationHelper")
- end
-end
-
-describe "Message Expectations on helper methods", :behaviour_type => :view do
- it "should work" do
- template.should_receive(:method_in_plugin_application_helper).and_return('alternate message 1')
- render "view_spec/implicit_helper"
- response.body.should =~ /alternate message 1/
- end
-
- it "should work twice" do
- template.should_receive(:method_in_plugin_application_helper).and_return('alternate message 2')
- render "view_spec/implicit_helper"
- response.body.should =~ /alternate message 2/
- end
-end
-
-describe "A template that includes a partial", :behaviour_type => :view do
- def render!
- render "view_spec/template_with_partial"
- end
-
- it "should render the enclosing template" do
- render!
- response.should have_tag('div', "method_in_partial in ViewSpecHelper")
- end
-
- it "should render the partial" do
- render!
- response.should have_tag('div', "method_in_template_with_partial in ViewSpecHelper")
- end
-
- it "should include the application helper" do
- render!
- response.should have_tag('div', "This is text from a method in the ApplicationHelper")
- end
-
- it "should pass expect_render with the right partial" do
- template.expect_render(:partial => 'partial')
- render!
- template.verify_rendered
- end
-
- it "should fail expect_render with the wrong partial" do
- template.expect_render(:partial => 'non_existent')
- render!
- begin
- template.verify_rendered
- rescue Spec::Mocks::MockExpectationError => e
- ensure
- e.backtrace.find{|line| line =~ /view_spec_spec\.rb\:87/}.should_not be_nil
- end
- end
-
- it "should pass expect_render when a partial is expected twice and happens twice" do
- template.expect_render(:partial => 'partial_used_twice').twice
- render!
- template.verify_rendered
- end
-
- it "should pass expect_render when a partial is expected once and happens twice" do
- template.expect_render(:partial => 'partial_used_twice')
- render!
- begin
- template.verify_rendered
- rescue Spec::Mocks::MockExpectationError => e
- ensure
- e.backtrace.find{|line| line =~ /view_spec_spec\.rb\:104/}.should_not be_nil
- end
- end
-
- it "should fail expect_render with the right partial but wrong options" do
- template.expect_render(:partial => 'partial', :locals => {:thing => Object.new})
- render!
- lambda {template.verify_rendered}.should raise_error(Spec::Mocks::MockExpectationError)
- end
-end
-
-describe "A partial that includes a partial", :behaviour_type => :view do
- it "should support expect_render with nested partial" do
- obj = Object.new
- template.expect_render(:partial => 'partial', :object => obj)
- render :partial => "view_spec/partial_with_sub_partial", :locals => { :partial => obj }
- end
-end
-
-describe "A view that includes a partial using :collection and :spacer_template", :behaviour_type => :view do
- it "should render the partial w/ spacer_tamplate" do
- render "view_spec/template_with_partial_using_collection"
- response.should have_tag('div',/method_in_partial/)
- response.should have_tag('div',/ApplicationHelper/)
- response.should have_tag('div',/ViewSpecHelper/)
- response.should have_tag('hr#spacer')
- end
-
- it "should render the partial w/ spacer_tamplate" do
- template.expect_render(:partial => 'partial',
- :collection => ['Alice', 'Bob'],
- :spacer_template => 'spacer')
- render "view_spec/template_with_partial_using_collection"
- end
-
-end
-
-describe "A view that includes a partial using an array as partial_path", :behaviour_type => :view do
- before(:each) do
- module ActionView::Partials
- def render_template_with_partial_with_array_support(partial_path, local_assigns = nil, deprecated_local_assigns = nil)
- if partial_path.is_a?(Array)
- "Array Partial"
- else
- render_partial_without_array_support(partial_path, local_assigns, deprecated_local_assigns)
- end
- end
-
- alias :render_partial_without_array_support :render_partial
- alias :render_partial :render_template_with_partial_with_array_support
- end
-
- @array = ['Alice', 'Bob']
- assigns[:array] = @array
- end
-
- after(:each) do
- module ActionView::Partials
- alias :render_template_with_partial_with_array_support :render_partial
- alias :render_partial :render_partial_without_array_support
- undef render_template_with_partial_with_array_support
- end
- end
-
- it "should render have the array passed through to render_partial without modification" do
- render "view_spec/template_with_partial_with_array"
- response.body.should match(/^Array Partial$/)
- end
-end
-
-describe "Different types of renders (not :template)", :behaviour_type => :view do
- it "should render partial with local" do
- render :partial => "view_spec/partial_with_local_variable", :locals => {:x => "Ender"}
- response.should have_tag('div', :content => "Ender")
- end
-end
-
-describe "A view", :behaviour_type => :view do
- before(:each) do
- session[:key] = "session"
- params[:key] = "params"
- flash[:key] = "flash"
- render "view_spec/accessor"
- end
-
- it "should have access to session data" do
- response.should have_tag("div#session", "session")
- end
-
- specify "should have access to params data" do
- response.should have_tag("div#params", "params")
- end
-
- it "should have access to flash data" do
- response.should have_tag("div#flash", "flash")
- end
-end
-
-describe "A view with a form_tag", :behaviour_type => :view do
- it "should render the right action" do
- render "view_spec/entry_form"
- response.should have_tag("form[action=?]","/view_spec/entry_form")
- end
-end
-
-describe "An instantiated ViewExampleController", :behaviour_type => :view do
- before do
- render "view_spec/foo/show"
- end
-
- it "should return the name of the real controller that it replaces" do
- @controller.controller_name.should == 'foo'
- end
-
- it "should return the path of the real controller that it replaces" do
- @controller.controller_path.should == 'view_spec/foo'
- end
-end
-
-module Spec
- module Rails
- module DSL
- describe ViewBehaviour do
- it "should tell you its behaviour_type is :view" do
- behaviour = ViewBehaviour.new("") {}
- behaviour.behaviour_type.should == :view
- end
- end
- end
- end
-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 60fb153da..9d3e759b2 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,14 +1,17 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require 'spec/mocks/errors'
-describe ActionView::Base, "with RSpec extensions", :behaviour_type => :view do
+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
- it "should raise when render has NOT been received", :should_raise => [Spec::Mocks::MockExpectationError] do
+ 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 not raise when stubbing and render has been received" do
@@ -21,6 +24,14 @@ describe ActionView::Base, "with RSpec extensions", :behaviour_type => :view do
end
it "should not raise when stubbing and render has been received with different options" do
- template.stub_render(:partial => "different_name")
+ 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")
end
+
end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/extensions/active_record_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/extensions/active_record_spec.rb
index cc4bb90e8..95d43b25b 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/extensions/active_record_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/extensions/active_record_spec.rb
@@ -1,10 +1,7 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-class Thing < ActiveRecord::Base
- validates_presence_of :name
-end
-
describe "A model" do
+ fixtures :things
it "should tell you its required fields" do
Thing.new.should have(1).error_on(:name)
end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/matchers/assert_select_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/matchers/assert_select_spec.rb
index dd9604c08..bdc8cf0b8 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/matchers/assert_select_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/matchers/assert_select_spec.rb
@@ -69,6 +69,13 @@ module AssertSelectSpecHelpers
get :xml
end
+ def first_non_rspec_line_in_backtrace_of(error)
+ rspec_path = File.join('rspec', 'lib', 'spec')
+ error.backtrace.reject { |line|
+ line =~ /#{rspec_path}/
+ }.first
+ end
+
private
# necessary for 1.2.1
def clear_response
@@ -80,7 +87,7 @@ unless defined?(SpecFailed)
SpecFailed = Spec::Expectations::ExpectationNotMetError
end
-describe "should have_tag", :behaviour_type => :controller do
+describe "should have_tag", :type => :controller do
include AssertSelectSpecHelpers
controller_name :assert_select
integrate_views
@@ -226,8 +233,44 @@ describe "should have_tag", :behaviour_type => :controller do
}.should raise_error(SpecFailed)
end
- it "should should report the correct line number for a nested failure" do
- pending("bug report: http://rubyforge.org/tracker/index.php?func=detail&aid=11602&group_id=797&atid=3149") do
+ it "should report the correct line number for a nested failed expectation" do
+ render_html %Q{
+ <form action="test">
+ <input type="text" name="email">
+ </form>
+ }
+ begin
+ response.should have_tag("form[action=test]") {
+ @expected_error_line = __LINE__; should have_tag("input[type=text][name=other_input]")
+ }
+ rescue => e
+ first_non_rspec_line_in_backtrace_of(e).should =~
+ /#{File.basename(__FILE__)}:#{@expected_error_line}/
+ else
+ fail
+ end
+ end
+
+ it "should report the correct line number for a nested raised exception" do
+ render_html %Q{
+ <form action="test">
+ <input type="text" name="email">
+ </form>
+ }
+ begin
+ response.should have_tag("form[action=test]") {
+ @expected_error_line = __LINE__; raise "Failed!"
+ }
+ rescue => e
+ first_non_rspec_line_in_backtrace_of(e).should =~
+ /#{File.basename(__FILE__)}:#{@expected_error_line}/
+ else
+ fail
+ end
+ end
+
+ it "should report the correct line number for a nested failed test/unit assertion" do
+ pending "Doesn't work at the moment. Do we want to support this?" do
render_html %Q{
<form action="test">
<input type="text" name="email">
@@ -235,13 +278,17 @@ describe "should have_tag", :behaviour_type => :controller do
}
begin
response.should have_tag("form[action=test]") {
- with_tag("input[type=text][name=other_input]")
+ @expected_error_line = __LINE__; assert false
}
rescue => e
- e.backtrace[3].to_s.should =~ /assert_select_spec.rb:238/
+ first_non_rspec_line_in_backtrace_of(e).should =~
+ /#{File.basename(__FILE__)}:#{@expected_error_line}/
+ else
+ fail
end
end
end
+
it "beatles" do
unless defined?(BEATLES)
@@ -358,7 +405,7 @@ describe "should have_tag", :behaviour_type => :controller do
end
end
-describe "css_select", :behaviour_type => :controller do
+describe "css_select", :type => :controller do
include AssertSelectSpecHelpers
controller_name :assert_select
integrate_views
@@ -409,7 +456,7 @@ describe "css_select", :behaviour_type => :controller do
end
-describe "have_rjs behaviour", :behaviour_type => :controller do
+describe "have_rjs behaviour_type", :type => :controller do
include AssertSelectSpecHelpers
controller_name :assert_select
integrate_views
@@ -584,7 +631,7 @@ describe "have_rjs behaviour", :behaviour_type => :controller do
end
end
-describe "send_email behaviour", :behaviour_type => :controller do
+describe "send_email behaviour_type", :type => :controller do
include AssertSelectSpecHelpers
controller_name :assert_select
integrate_views
@@ -628,7 +675,7 @@ describe "send_email behaviour", :behaviour_type => :controller do
end
# describe "An rjs call to :visual_effect, a 'should have_rjs' spec with",
-# :behaviour_type => :view do
+# :type => :view do
#
# before do
# render 'rjs_spec/visual_effect'
@@ -653,7 +700,7 @@ end
# end
#
# describe "An rjs call to :visual_effect for a toggle, a 'should have_rjs' spec with",
-# :behaviour_type => :view do
+# :type => :view do
#
# before do
# render 'rjs_spec/visual_toggle_effect'
@@ -677,7 +724,7 @@ end
#
# end
-describe "string.should have_tag", :behaviour_type => :helper do
+describe "string.should have_tag", :type => :helper do
include AssertSelectSpecHelpers
it "should find root element" do
@@ -709,7 +756,7 @@ describe "string.should have_tag", :behaviour_type => :helper do
end
end
-describe "have_tag", :behaviour_type => :controller do
+describe "have_tag", :type => :controller do
include AssertSelectSpecHelpers
controller_name :assert_select
integrate_views
@@ -733,3 +780,4 @@ describe "have_tag", :behaviour_type => :controller do
response.should have_tag("#wrapper .piece h3", :text => "Another")
end
end
+
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/matchers/description_generation_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/matchers/description_generation_spec.rb
index 1a83da680..4fd2bcd1c 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/matchers/description_generation_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/matchers/description_generation_spec.rb
@@ -3,40 +3,35 @@ require File.dirname(__FILE__) + '/../../spec_helper'
class DescriptionGenerationSpecController < ActionController::Base
def render_action
end
-
+
def redirect_action
redirect_to :action => :render_action
end
end
-describe "Description generation", :behaviour_type => :controller do
+describe "Description generation", :type => :controller do
controller_name :description_generation_spec
- before(:each) do
- @desc = nil
- @callback = lambda { |desc| @desc = desc }
- Spec::Matchers.description_generated(@callback)
- end
after(:each) do
- Spec::Matchers.unregister_description_generated(@callback)
+ Spec::Matchers.clear_generated_description
end
-
+
it "should generate description for render_template" do
get 'render_action'
response.should render_template("render_action")
- @desc.should == "should render template \"render_action\""
+ Spec::Matchers.generated_description.should == "should render template \"render_action\""
end
-
+
it "should generate description for render_template with full path" do
get 'render_action'
response.should render_template("description_generation_spec/render_action")
- @desc.should == "should render template \"description_generation_spec/render_action\""
+ Spec::Matchers.generated_description.should == "should render template \"description_generation_spec/render_action\""
end
-
+
it "should generate description for redirect_to" do
get 'redirect_action'
response.should redirect_to("http://test.host/description_generation_spec/render_action")
- @desc.should == "should redirect to \"http://test.host/description_generation_spec/render_action\""
+ Spec::Matchers.generated_description.should == "should redirect to \"http://test.host/description_generation_spec/render_action\""
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 fdf6ea0ca..b3c7d7a86 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
@@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../../spec_helper'
['isolation','integration'].each do |mode|
- describe "redirect_to behaviour", :behaviour_type => :controller do
+ describe "redirect_to behaviour", :type => :controller do
if mode == 'integration'
integrate_views
end
@@ -84,7 +84,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
end
- describe "redirect_to with a controller spec in #{mode} mode and a custom request.host", :behaviour_type => :controller do
+ describe "redirect_to with a controller spec in #{mode} mode and a custom request.host", :type => :controller do
if mode == 'integration'
integrate_views
end
@@ -99,7 +99,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
end
end
- describe "Given a controller spec in #{mode} mode", :behaviour_type => :controller do
+ describe "Given a controller spec in #{mode} mode", :type => :controller do
if mode == 'integration'
integrate_views
end
@@ -129,7 +129,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
end
- describe "Given a controller spec in #{mode} mode, should redirect_to should fail when", :behaviour_type => :controller do
+ describe "Given a controller spec in #{mode} mode, should redirect_to should fail when", :type => :controller do
if mode == 'integration'
integrate_views
end
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 029297c9a..5dbf576f1 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
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
['isolation','integration'].each do |mode|
describe "response.should render_template (in #{mode} mode)",
- :behaviour_type => :controller do
+ :type => :controller do
controller_name :render_spec
if mode == 'integration'
integrate_views
@@ -30,7 +30,8 @@ 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')
+ 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
response.should render_template('render_spec/some_action.rjs')
@@ -82,50 +83,4 @@ require File.dirname(__FILE__) + '/../../spec_helper'
end.should fail_with("expected \"some_action\", got nil")
end
end
-
- describe "response.should have_text (in #{mode} mode)",
- :behaviour_type => :controller do
- controller_name :render_spec
- if mode == 'integration'
- integrate_views
- end
-
- it "should pass with exactly matching text" do
- post 'text_action'
- response.should have_text("this is the text for this action")
- end
-
- it "should pass with matching text (using Regexp)" do
- post 'text_action'
- response.should have_text(/is the text/)
- end
-
- it "should fail with matching text" do
- post 'text_action'
- lambda {
- response.should have_text("this is NOT the text for this action")
- }.should fail_with("expected \"this is NOT the text for this action\", got \"this is the text for this action\"")
- end
-
- it "should fail when a template is rendered" do
- post 'some_action'
- lambda {
- response.should have_text("this is the text for this action")
- }.should fail_with(/expected \"this is the text for this action\", got .*/)
- end
- end
-
- describe "response.should_not have_text (in #{mode} mode)",
- :behaviour_type => :controller do
- controller_name :render_spec
- if mode == 'integration'
- integrate_views
- end
-
- it "should pass with exactly matching text" do
- post 'text_action'
- response.should_not have_text("the accordian guy")
- end
- end
-
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 87981dbcf..76793f0a1 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,12 +1,17 @@
require File.dirname(__FILE__) + '/../../spec_helper'
class MockableModel < ActiveRecord::Base
+ has_one :associated_model
end
class SubMockableModel < MockableModel
end
-describe "mock_model", :behaviour_type => :view do
+class AssociatedModel < ActiveRecord::Base
+ belongs_to :mockable_model
+end
+
+describe "mock_model", :type => :view do
before(:each) do
@model = mock_model(SubMockableModel)
end
@@ -29,3 +34,32 @@ describe "mock_model", :behaviour_type => :view do
@model.instance_of?(MockableModel).should be(false)
end
end
+
+describe "mock_model with null_object", :type => :view do
+ before(:each) do
+ @model = mock_model(MockableModel, :null_object => true, :mocked_method => "mocked")
+ end
+
+ it "should be able to mock methods" do
+ @model.mocked_method.should == "mocked"
+ end
+ it "should return itself to unmocked methods" do
+ @model.unmocked_method.should equal(@model)
+ end
+end
+
+describe "mock_model as association", :type => :view do
+ before(:each) do
+ @real = AssociatedModel.create!
+ @mock_model = mock_model(MockableModel)
+ @real.mockable_model = @mock_model
+ end
+
+ it "should pass associated_model == mock" do
+ @mock_model.should == @real.mockable_model
+ end
+
+ it "should pass mock == associated_model" do
+ @real.mockable_model.should == @mock_model
+ end
+end
diff --git a/vendor/plugins/rspec_on_rails/spec/spec_helper.rb b/vendor/plugins/rspec_on_rails/spec/spec_helper.rb
index dc45b5ca7..2d2c7279f 100644
--- a/vendor/plugins/rspec_on_rails/spec/spec_helper.rb
+++ b/vendor/plugins/rspec_on_rails/spec/spec_helper.rb
@@ -1,25 +1,23 @@
dir = File.dirname(__FILE__)
-$LOAD_PATH.unshift("#{dir}/../../../../../rspec/lib")
-$LOAD_PATH.unshift("#{dir}/../spec_resources/controllers")
-$LOAD_PATH.unshift("#{dir}/../spec_resources/helpers")
-require "#{dir}/../../../../spec/spec_helper"
-require "#{dir}/../spec_resources/controllers/render_spec_controller"
-require "#{dir}/../spec_resources/controllers/rjs_spec_controller"
-require "#{dir}/../spec_resources/controllers/redirect_spec_controller"
-require "#{dir}/../spec_resources/controllers/action_view_base_spec_controller"
-require "#{dir}/../spec_resources/helpers/explicit_helper"
-require "#{dir}/../spec_resources/helpers/more_explicit_helper"
-require "#{dir}/../spec_resources/helpers/view_spec_helper"
-require "#{dir}/../spec_resources/helpers/plugin_application_helper"
+$LOAD_PATH.unshift(File.expand_path("#{dir}/../rspec/lib"))
+$LOAD_PATH.unshift(File.expand_path("#{dir}/../spec_resources/controllers"))
+$LOAD_PATH.unshift(File.expand_path("#{dir}/../spec_resources/helpers"))
+require File.expand_path("#{dir}/../../../../spec/spec_helper")
+require File.expand_path("#{dir}/../spec_resources/controllers/render_spec_controller")
+require File.expand_path("#{dir}/../spec_resources/controllers/rjs_spec_controller")
+require File.expand_path("#{dir}/../spec_resources/controllers/redirect_spec_controller")
+require File.expand_path("#{dir}/../spec_resources/controllers/action_view_base_spec_controller")
+require File.expand_path("#{dir}/../spec_resources/helpers/explicit_helper")
+require File.expand_path("#{dir}/../spec_resources/helpers/more_explicit_helper")
+require File.expand_path("#{dir}/../spec_resources/helpers/view_spec_helper")
+require File.expand_path("#{dir}/../spec_resources/helpers/plugin_application_helper")
-if Rails::VERSION::MINOR >= 2
- ActionController::Routing.controller_paths << "#{dir}/../spec_resources/controllers"
-end
+ActionController::Routing.controller_paths << "#{dir}/../spec_resources/controllers"
module Spec
module Rails
- module DSL
- class ViewExampleController
+ module Example
+ class ViewExampleGroupController
set_view_path File.join(File.dirname(__FILE__), "..", "spec_resources", "views")
end
end
@@ -39,3 +37,10 @@ class Proc
lambda { self.call }.should_not raise_error
end
end
+
+ActionController::Routing::Routes.draw do |map|
+ map.resources :rspec_on_rails_specs
+ map.connect 'custom_route', :controller => 'custom_route_spec', :action => 'custom_route'
+ map.connect ":controller/:action/:id"
+end
+