diff options
Diffstat (limited to 'vendor/gems/rspec-rails-1.3.3/spec')
91 files changed, 4269 insertions, 0 deletions
diff --git a/vendor/gems/rspec-rails-1.3.3/spec/autotest/mappings_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/autotest/mappings_spec.rb new file mode 100644 index 000000000..1e0ec738d --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/autotest/mappings_spec.rb @@ -0,0 +1,86 @@ +require 'spec_helper' +require File.dirname(__FILE__) + '/../../lib/autotest/rails_rspec' +require File.dirname(__FILE__) + '/../../../rspec/spec/autotest/autotest_matchers' + +describe Autotest::RailsRspec, "file mapping" do + before(:each) do + @autotest = Autotest::RailsRspec.new + @autotest.hook :initialize + end + + it "should map model example to model" do + @autotest.should map_specs(['spec/models/thing_spec.rb']). + to('app/models/thing.rb') + end + + it "should map controller example to controller" do + @autotest.should map_specs(['spec/controllers/things_controller_spec.rb']). + to('app/controllers/things_controller.rb') + end + + it "should map view.rhtml" do + @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 + @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 + @autotest.should map_specs(['spec/views/things/index.html.erb_spec.rb']). + to('app/views/things/index.html.erb') + end + + describe "between routes.rb and things which depend on routes" do + it "should map routes.rb to controllers" do + @autotest.should map_specs(['spec/controllers/things_controller_spec.rb']). + to('config/routes.rb') + end + + it "should map routes.rb to views" do + @autotest.should map_specs(['spec/views/things/action.html.erb_spec.rb']). + to('config/routes.rb') + end + + it "should map routes.rb to helpers" do + @autotest.should map_specs(['spec/helpers/things_helper_spec.rb']). + to('config/routes.rb') + end + + it "should map routing example to routes" do + @autotest.should map_specs(['spec/routing/thing_spec.rb']). + to('config/routes.rb') + end + end + + describe "between the config and specs" do + ['spec/controllers/things_controller_spec.rb', + 'spec/views/things/action.html.erb_spec.rb', + 'spec/helpers/things_helper_spec.rb', + 'spec/routing/thing_spec.rb', + 'spec/models/thing_spec.rb'].each do |file_path| + + it "should map environment.rb to #{file_path}" do + @autotest.should map_specs([file_path]). + to('config/environment.rb') + end + + it "should map environments/test.rb to #{file_path}" do + @autotest.should map_specs([file_path]). + to('config/environments/test.rb') + end + + it "should map boot.rb to #{file_path}" do + @autotest.should map_specs([file_path]). + to('config/boot.rb') + end + + it "should map spec_helper.rb to #{file_path}" do + @autotest.should map_specs([file_path]). + to('spec/spec_helper.rb') + end + end + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/rails_suite.rb b/vendor/gems/rspec-rails-1.3.3/spec/rails_suite.rb new file mode 100644 index 000000000..15effae1c --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/rails_suite.rb @@ -0,0 +1,7 @@ +dir = File.dirname(__FILE__) +Dir["#{dir}/**/*_example.rb"].each do |file| + require file +end +Dir["#{dir}/**/*_spec.rb"].each do |file| + require file +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/action_view_base_spec_controller.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/action_view_base_spec_controller.rb new file mode 100644 index 000000000..924022178 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/action_view_base_spec_controller.rb @@ -0,0 +1,2 @@ +class ActionViewBaseSpecController < ActionController::Base +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/application.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/application.rb new file mode 100644 index 000000000..343fdd7bc --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/application.rb @@ -0,0 +1,9 @@ +class ApplicationController < ActionController::Base + before_filter :i_should_only_be_run_once, + :only => 'action_with_inherited_before_filter' + + def i_should_only_be_run_once + true + end + private :i_should_only_be_run_once +end
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/controller_spec_controller.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/controller_spec_controller.rb new file mode 100644 index 000000000..d5b5627d1 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/controller_spec_controller.rb @@ -0,0 +1,127 @@ +class ControllerSpecController < ActionController::Base + before_filter :raise_error, :only => :action_with_skipped_before_filter + + def raise_error + raise "from a before filter" + end + + skip_before_filter :raise_error + + prepend_view_path File.join(File.dirname(__FILE__), "..", "views") + + def some_action + render :template => "template/that/does/not/actually/exist" + end + + def some_action_with_implied_template + end + + def action_with_template + 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_which_gets_cookie + raise "expected #{params[:expected].inspect}, got #{cookies[:cookie_key].inspect}" unless (cookies[:cookie_key] == params[:expected]) + render :text => "" + end + + def action_which_sets_cookie + cookies['cookie_key'] = params[:value] + render :text => "" + end + + def action_with_partial + render :partial => "controller_spec/partial" + end + + def action_with_partial_with_object + render :partial => "controller_spec/partial", :object => params[:thing] + end + + def action_with_partial_with_locals + render :partial => "controller_spec/partial", :locals => {:thing => params[:thing]} + end + + def action_with_errors_in_template + render :template => "controller_spec/action_with_errors_in_template" + end + + def action_setting_the_assigns_hash + @indirect_assigns_key = :indirect_assigns_key_value + end + + def action_setting_flash_after_session_reset + reset_session + flash[:after_reset] = "available" + end + + def action_setting_flash_before_session_reset + 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 + + def action_with_skipped_before_filter + render :text => "" + end + + def action_that_renders_inline + render :inline => "<%= 'inline code' %>" + end + + def action_that_assigns_false_to_a_variable + @a_variable = false + render :text => "" + end + + def action_with_two_arg_render + render :update, :status => 404 do |page| + page.visual_effect :highlight, 'user_list' + end + end + + class RescuedError < Exception; end + class UnRescuedError < Exception; end + + rescue_from RescuedError do |e| + render :text => 'Rescued!' + end + + def rescued_error_action + raise ControllerSpecController::RescuedError + end + + def un_rescued_error_action + raise ControllerSpecController::UnRescuedError + end + + def action_that_returns_headers + render :text => request.headers[params[:header]] + end +end + +class ControllerInheritingFromApplicationControllerController < ApplicationController + def action_with_inherited_before_filter + render :text => "" + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/example.txt b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/example.txt new file mode 100644 index 000000000..380965314 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/example.txt @@ -0,0 +1 @@ +This is an example file to download.
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/redirect_spec_controller.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/redirect_spec_controller.rb new file mode 100644 index 000000000..7b63c99f2 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/redirect_spec_controller.rb @@ -0,0 +1,70 @@ +class RedirectSpecController < ApplicationController + + def action_with_no_redirect + render :text => "this is just here to keep this from causing a MissingTemplate error" + end + + def action_with_redirect_to_somewhere + redirect_to :action => 'somewhere' + end + + def action_with_redirect_to_other_somewhere + redirect_to :controller => 'render_spec', :action => 'text_action' + end + + def action_with_redirect_to_somewhere_and_return + redirect_to :action => 'somewhere' and return + render :text => "this is after the return" + end + + def somewhere + render :text => "this is just here to keep this from causing a MissingTemplate error" + end + + def action_with_redirect_to_rspec_site + redirect_to "http://rspec.rubyforge.org" + end + + def action_with_redirect_back + redirect_to :back + end + + def action_with_redirect_in_respond_to + respond_to do |wants| + wants.html { redirect_to :action => 'somewhere' } + end + end + + def action_with_redirect_which_creates_query_string + redirect_to :action => "somewhere", :id => 1111, :param1 => "value1", :param2 => "value2" + end + + # note: sometimes this is the URL which rails will generate from the hash in + # action_with_redirect_which_creates_query_string + def action_with_redirect_with_query_string_order1 + redirect_to "http://test.host/redirect_spec/somewhere/1111?param1=value1¶m2=value2" + end + + # note: sometimes this is the URL which rails will generate from the hash in + # action_with_redirect_which_creates_query_string + def action_with_redirect_with_query_string_order2 + redirect_to "http://test.host/redirect_spec/somewhere/1111?param2=value2¶m1=value1" + end + + def action_with_redirect_to_unroutable_url_inside_app + redirect_to :controller => "nonexistant", :action => "none" + end + + def action_with_method_restriction + render :text => '' + end + + def action_to_redirect_to_action_with_method_restriction + redirect_to :action => 'action_with_method_restriction' + end + + def action_with_redirect_to_somewhere_with_status + redirect_to :action => 'somewhere', :status => 301 + end +end + diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/render_spec_controller.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/render_spec_controller.rb new file mode 100644 index 000000000..1efe61ff8 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/render_spec_controller.rb @@ -0,0 +1,34 @@ +class RenderSpecController < ApplicationController + prepend_view_path File.join(File.dirname(__FILE__), "..", "views") + + def some_action + respond_to do |format| + format.html + format.js + end + end + + def action_which_renders_template_from_other_controller + render :template => 'controller_spec/action_with_template' + end + + def text_action + render :text => "this is the text for this action" + end + + def action_with_redirect + redirect_to :action => :some_action + end + + def action_with_partial + render :partial => "a_partial" + end + + def action_that_renders_nothing + render :nothing => true + end + + def action_with_alternate_layout + render :layout => 'simple' + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/rjs_spec_controller.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/rjs_spec_controller.rb new file mode 100644 index 000000000..4fd9a41c0 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/rjs_spec_controller.rb @@ -0,0 +1,58 @@ +class RjsSpecController < ApplicationController + prepend_view_path File.join(File.dirname(__FILE__), "..", "views") + + def replace_html + end + + def insert_html + end + + def replace + end + + def hide_div + end + + def hide_page_element + end + + def replace_html_with_partial + end + + def render_replace_html + render :update do |page| + page.replace_html 'mydiv', 'replacement text' + page.replace_html 'myotherdiv', 'other replacement text' + end + end + + def render_replace_html_with_partial + render :update do |page| + page.replace_html 'mydiv', :partial => 'rjs_spec/replacement_partial' + end + end + + def render_insert_html + render :update do |page| + page.insert_html 'mydiv', 'replacement text' + end + end + + def render_replace + render :update do |page| + page.replace 'mydiv', 'replacement text' + end + end + + def render_hide_div + render :update do |page| + page.hide 'mydiv' + end + end + + def render_hide_page_element + render :update do |page| + page['mydiv'].hide + end + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/helpers/addition_helper.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/helpers/addition_helper.rb new file mode 100644 index 000000000..14ad70c3e --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/helpers/addition_helper.rb @@ -0,0 +1,5 @@ +module AdditionHelper + def plus(addend) + @addend + addend + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/helpers/explicit_helper.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/helpers/explicit_helper.rb new file mode 100644 index 000000000..f75d1ddcb --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/helpers/explicit_helper.rb @@ -0,0 +1,46 @@ +module ExplicitHelper + def method_in_explicit_helper + "<div>This is text from a method in the ExplicitHelper</div>" + end + + # this is an example of a method spec'able with eval_erb in helper specs + def prepend(arg, &block) + begin # rails edge after 2.1.0 eliminated need for block.binding + concat(arg) + block.call + rescue + concat(arg, block.binding) + block.call + end + end + + def named_url + rspec_on_rails_specs_url + end + + def named_path + rspec_on_rails_specs_path + end + + def params_foo + params[:foo] + end + + def session_foo + session[:foo] + end + + def request_thing + request.thing + end + + def flash_thing + flash[:thing] + end + + def method_using_output_buffer + concat("the_text_from_concat") + end + + def method_using_template + update_page { |p| p["#some_id"].replace_html "" } + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/helpers/more_explicit_helper.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/helpers/more_explicit_helper.rb new file mode 100644 index 000000000..7468741b2 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/helpers/more_explicit_helper.rb @@ -0,0 +1,5 @@ +module MoreExplicitHelper + def method_in_more_explicit_helper + "<div>This is text from a method in the MoreExplicitHelper</div>" + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/helpers/plugin_application_helper.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/helpers/plugin_application_helper.rb new file mode 100644 index 000000000..2107d2218 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/helpers/plugin_application_helper.rb @@ -0,0 +1,6 @@ +# Methods added to this helper will be available to all templates in the application. +module ApplicationHelper + def method_in_plugin_application_helper + "<div>This is text from a method in the ApplicationHelper</div>" + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/helpers/view_spec_helper.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/helpers/view_spec_helper.rb new file mode 100644 index 000000000..b05fc53f7 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/helpers/view_spec_helper.rb @@ -0,0 +1,13 @@ +module ViewSpecHelper + def method_in_helper + "<div>This is text from a method in the ViewSpecHelper</div>" + end + + def method_in_template_with_partial + "<div>method_in_template_with_partial in ViewSpecHelper</div>" + end + + def method_in_partial + "<div>method_in_partial in ViewSpecHelper</div>" + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/models/animal.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/models/animal.rb new file mode 100644 index 000000000..3ce078ad4 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/models/animal.rb @@ -0,0 +1,4 @@ +class Animal < ActiveRecord::Base + belongs_to :person + validates_uniqueness_of :name +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/models/person.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/models/person.rb new file mode 100644 index 000000000..7f9607e57 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/models/person.rb @@ -0,0 +1,18 @@ +class Person < ActiveRecord::Base + has_many :animals do + def pups + find(:all, :conditions => 'age < 1') + end + def adults + find(:all, :conditions => 'age >= 1') + end + end + validates_presence_of :name + + def add_animal animal + animal.person = self + animals << animal + animal.save + end + +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/models/thing.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/models/thing.rb new file mode 100644 index 000000000..c674804ac --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/models/thing.rb @@ -0,0 +1,3 @@ +class Thing < ActiveRecord::Base + validates_presence_of :name +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/_partial.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/_partial.html.erb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/_partial.html.erb diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/action_setting_flash_after_session_reset.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/action_setting_flash_after_session_reset.html.erb new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/action_setting_flash_after_session_reset.html.erb @@ -0,0 +1 @@ + diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/action_setting_flash_before_session_reset.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/action_setting_flash_before_session_reset.html.erb new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/action_setting_flash_before_session_reset.html.erb @@ -0,0 +1 @@ + diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/action_setting_the_assigns_hash.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/action_setting_the_assigns_hash.html.erb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/action_setting_the_assigns_hash.html.erb diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/action_with_errors_in_template.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/action_with_errors_in_template.html.erb new file mode 100644 index 000000000..0f957b2c8 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/action_with_errors_in_template.html.erb @@ -0,0 +1 @@ +<% raise %>
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/action_with_template.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/action_with_template.html.erb new file mode 100644 index 000000000..6e1f05847 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/controller_spec/action_with_template.html.erb @@ -0,0 +1 @@ +<div>This is action_with_template.rhtml</div> diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/layouts/application.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/layouts/application.html.erb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/layouts/application.html.erb diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/layouts/simple.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/layouts/simple.html.erb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/layouts/simple.html.erb diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/objects/_object.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/objects/_object.html.erb new file mode 100644 index 000000000..b751f09c4 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/objects/_object.html.erb @@ -0,0 +1 @@ +<%= object.name %>
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/render_spec/_a_partial.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/render_spec/_a_partial.html.erb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/render_spec/_a_partial.html.erb diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/render_spec/action_with_alternate_layout.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/render_spec/action_with_alternate_layout.html.erb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/render_spec/action_with_alternate_layout.html.erb diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/render_spec/some_action.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/render_spec/some_action.html.erb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/render_spec/some_action.html.erb diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/render_spec/some_action.js.rjs b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/render_spec/some_action.js.rjs new file mode 100644 index 000000000..4472f4b4c --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/render_spec/some_action.js.rjs @@ -0,0 +1 @@ +# This is used for rails > 1.2.3
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/_replacement_partial.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/_replacement_partial.html.erb new file mode 100644 index 000000000..d2820659c --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/_replacement_partial.html.erb @@ -0,0 +1 @@ +This is the text in the replacement partial.
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/hide_div.js.rjs b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/hide_div.js.rjs new file mode 100644 index 000000000..1fe2139be --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/hide_div.js.rjs @@ -0,0 +1 @@ +page.hide 'mydiv' diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/hide_page_element.js.rjs b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/hide_page_element.js.rjs new file mode 100644 index 000000000..de1ebc9d0 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/hide_page_element.js.rjs @@ -0,0 +1 @@ +page['mydiv'].hide diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/insert_html.js.rjs b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/insert_html.js.rjs new file mode 100644 index 000000000..f8a59e0ca --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/insert_html.js.rjs @@ -0,0 +1 @@ +page.insert_html 'mydiv', 'replacement text' diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/replace.js.rjs b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/replace.js.rjs new file mode 100644 index 000000000..aca59a97a --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/replace.js.rjs @@ -0,0 +1 @@ +page.replace 'mydiv', 'replacement text' diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/replace_html.js.rjs b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/replace_html.js.rjs new file mode 100644 index 000000000..717c598e6 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/replace_html.js.rjs @@ -0,0 +1 @@ +page.replace_html 'mydiv', 'replacement text'
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/replace_html_with_partial.js.rjs b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/replace_html_with_partial.js.rjs new file mode 100644 index 000000000..0531804dd --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/replace_html_with_partial.js.rjs @@ -0,0 +1 @@ +page.replace_html 'mydiv', :partial => 'rjs_spec/replacement_partial'
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/visual_effect.js.rjs b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/visual_effect.js.rjs new file mode 100644 index 000000000..1c37b32ad --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/visual_effect.js.rjs @@ -0,0 +1 @@ +page.visual_effect :fade, 'mydiv' diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/visual_toggle_effect.js.rjs b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/visual_toggle_effect.js.rjs new file mode 100644 index 000000000..97cf6bbeb --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/rjs_spec/visual_toggle_effect.js.rjs @@ -0,0 +1 @@ +page.visual_effect :toggle_blind, 'mydiv' diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/tag_spec/no_tags.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/tag_spec/no_tags.html.erb new file mode 100644 index 000000000..877b90815 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/tag_spec/no_tags.html.erb @@ -0,0 +1 @@ +<!-THIS FILE HAS NO TAGS->
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/tag_spec/single_div_with_no_attributes.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/tag_spec/single_div_with_no_attributes.html.erb new file mode 100644 index 000000000..281c6866c --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/tag_spec/single_div_with_no_attributes.html.erb @@ -0,0 +1 @@ +<div></div>
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/tag_spec/single_div_with_one_attribute.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/tag_spec/single_div_with_one_attribute.html.erb new file mode 100644 index 000000000..c664e76e7 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/tag_spec/single_div_with_one_attribute.html.erb @@ -0,0 +1 @@ +<div key="value"></div>
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/_partial.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/_partial.html.erb new file mode 100644 index 000000000..39505da3d --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/_partial.html.erb @@ -0,0 +1,2 @@ +<%= method_in_plugin_application_helper %> +<%= method_in_partial %>
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/_partial_used_twice.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/_partial_used_twice.html.erb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/_partial_used_twice.html.erb diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/_partial_with_local_variable.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/_partial_with_local_variable.html.erb new file mode 100644 index 000000000..47274481b --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/_partial_with_local_variable.html.erb @@ -0,0 +1 @@ +<div><%= x %></div>
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/_partial_with_sub_partial.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/_partial_with_sub_partial.html.erb new file mode 100644 index 000000000..90207a30d --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/_partial_with_sub_partial.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'partial', :object => partial %>
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/_spacer.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/_spacer.html.erb new file mode 100644 index 000000000..c952f6e9a --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/_spacer.html.erb @@ -0,0 +1 @@ +<hr id="spacer" /> diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/accessor.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/accessor.html.erb new file mode 100644 index 000000000..807a3ca37 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/accessor.html.erb @@ -0,0 +1,6 @@ +<div id="session"><%= session[:key] %></div> +<div id="params"><%= params[:key] %></div> +<div id="flash"><%= flash[:key] %></div> +<div id="flash_now"><%= flash[:now_key] %></div> +<div id="controller"><%= params[:controller] %></div> +<div id="action"><%= params[:action] %></div> diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/block_helper.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/block_helper.html.erb new file mode 100644 index 000000000..3a1dcd5de --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/block_helper.html.erb @@ -0,0 +1,3 @@ +<% if_allowed do %> + <div>block helper was rendered</div> +<% end %>
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/entry_form.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/entry_form.html.erb new file mode 100755 index 000000000..7b11d9723 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/entry_form.html.erb @@ -0,0 +1,2 @@ +<% form_tag do %> +<% end %>
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/explicit_helper.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/explicit_helper.html.erb new file mode 100644 index 000000000..49aa081cd --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/explicit_helper.html.erb @@ -0,0 +1,2 @@ +<%= method_in_plugin_application_helper %> +<%= method_in_explicit_helper %> diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/foo/show.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/foo/show.html.erb new file mode 100644 index 000000000..2cc5fd98e --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/foo/show.html.erb @@ -0,0 +1 @@ +<%= method_in_plugin_application_helper %> diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/implicit_helper.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/implicit_helper.html.erb new file mode 100644 index 000000000..816c66744 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/implicit_helper.html.erb @@ -0,0 +1,2 @@ +<%= method_in_plugin_application_helper %> +<%= method_in_helper %> diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/multiple_helpers.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/multiple_helpers.html.erb new file mode 100644 index 000000000..ae5a72b65 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/multiple_helpers.html.erb @@ -0,0 +1,3 @@ +<%= method_in_plugin_application_helper %> +<%= method_in_explicit_helper %> +<%= method_in_more_explicit_helper %>
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/path_params.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/path_params.html.erb new file mode 100644 index 000000000..a31e98f83 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/path_params.html.erb @@ -0,0 +1 @@ +<%= params[:controller] %>
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/should_not_receive.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/should_not_receive.html.erb new file mode 100644 index 000000000..d3e5f441e --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/should_not_receive.html.erb @@ -0,0 +1,3 @@ +<% if @obj.render_partial? %> + <%= render :partial => 'some_partial' %> +<% end %> diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/template_with_partial.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/template_with_partial.html.erb new file mode 100644 index 000000000..0e13ba3b2 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/template_with_partial.html.erb @@ -0,0 +1,5 @@ +<%= method_in_template_with_partial %> +<%= render :partial => 'partial' %> + +<%= render :partial => 'partial_used_twice' %> +<%= render :partial => 'partial_used_twice' %> diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/template_with_partial_using_collection.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/template_with_partial_using_collection.html.erb new file mode 100644 index 000000000..79d82156e --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/template_with_partial_using_collection.html.erb @@ -0,0 +1,3 @@ +<%= render :partial => 'partial', + :collection => ['Alice', 'Bob'], + :spacer_template => 'spacer' %> diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/template_with_partial_with_array.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/template_with_partial_with_array.html.erb new file mode 100644 index 000000000..7d53476d6 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/template_with_partial_with_array.html.erb @@ -0,0 +1 @@ +<%= render :partial => @array %> diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/view_helpers.html.erb b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/view_helpers.html.erb new file mode 100644 index 000000000..7e4f3df15 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/views/view_spec/view_helpers.html.erb @@ -0,0 +1 @@ +<span><%= link_to "edit", "this_is_the_link" %></span> diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/assigns_hash_proxy_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/assigns_hash_proxy_spec.rb new file mode 100644 index 000000000..5b572133c --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/assigns_hash_proxy_spec.rb @@ -0,0 +1,109 @@ +require 'spec_helper' + +describe "AssignsHashProxy" do + def orig_assigns + @object.assigns + end + + class Foo + def initialize(bar) + @bar = bar + end + attr_reader :bar + + def ==(other) + self.bar == other.bar + end + end + + before(:each) do + @object = Class.new do + def assigns; @assigns ||= Hash.new; end + end.new + @proxy = Spec::Rails::Example::AssignsHashProxy.new(self) {@object} + end + + it "doesn't wig out on objects that define their own == method" do + @object.assigns['foo'] = Foo.new(1) + @proxy['foo'].should == Foo.new(1) + end + + it "should set ivars on object using string" do + @proxy['foo'] = 'bar' + @object.instance_eval{@foo}.should == 'bar' + end + + it "should set ivars on object using symbol" do + @proxy[:foo] = 'bar' + @object.instance_eval{@foo}.should == 'bar' + end + + it "should access object's assigns with a string" do + @object.assigns['foo'] = 'bar' + @proxy['foo'].should == 'bar' + end + + it "should access object's assigns with a symbol" do + @object.assigns['foo'] = 'bar' + @proxy[:foo].should == 'bar' + end + + it "should access object's ivars with a string" do + @object.instance_variable_set('@foo', 'bar') + @proxy['foo'].should == 'bar' + end + + it "should access object's ivars with a symbol" do + @object.instance_variable_set('@foo', 'bar') + @proxy[:foo].should == 'bar' + end + + it "should iterate 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 "should delete the ivar of passed in key" do + @object.instance_variable_set('@foo', 'bar') + @proxy.delete('foo') + @proxy['foo'].should be_nil + end + + it "should delete the assigned element of passed in key" do + @object.assigns['foo'] = 'bar' + @proxy.delete('foo') + @proxy['foo'].should be_nil + end + + it "should detect the presence of a key in assigns" do + @object.assigns['foo'] = 'bar' + @proxy.has_key?('foo').should == true + @proxy.has_key?('bar').should == false + end + + it "should expose values set in example back to the example" do + @proxy[:foo] = 'bar' + @proxy[:foo].should == 'bar' + end + + it "should allow assignment of false via proxy" do + @proxy['foo'] = false + @proxy['foo'].should be_false + end + + it "should allow assignment of false" do + @object.instance_variable_set('@foo',false) + @proxy['foo'].should be_false + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/configuration_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/configuration_spec.rb new file mode 100644 index 000000000..391dbb2fe --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/configuration_spec.rb @@ -0,0 +1,67 @@ +require 'spec_helper' + +module Spec + module Runner + describe Configuration do + + def config + @config ||= Configuration.new + end + + describe "#use_transactional_fixtures" do + it "should return ActiveSupport::TestCase.use_transactional_fixtures" do + config.use_transactional_fixtures.should == ActiveSupport::TestCase.use_transactional_fixtures + end + + it "should set ActiveSupport::TestCase.use_transactional_fixtures to false" do + ActiveSupport::TestCase.should_receive(:use_transactional_fixtures=).with(false) + config.use_transactional_fixtures = false + end + + it "should set ActiveSupport::TestCase.use_transactional_fixtures to true" do + ActiveSupport::TestCase.should_receive(:use_transactional_fixtures=).with(true) + config.use_transactional_fixtures = true + end + end + + describe "#use_instantiated_fixtures" do + it "should return ActiveSupport::TestCase.use_transactional_fixtures" do + config.use_instantiated_fixtures.should == ActiveSupport::TestCase.use_instantiated_fixtures + end + + it "should set ActiveSupport::TestCase.use_instantiated_fixtures to false" do + ActiveSupport::TestCase.should_receive(:use_instantiated_fixtures=).with(false) + config.use_instantiated_fixtures = false + end + + it "should set ActiveSupport::TestCase.use_instantiated_fixtures to true" do + ActiveSupport::TestCase.should_receive(:use_instantiated_fixtures=).with(true) + config.use_instantiated_fixtures = true + end + end + + describe "#fixture_path" do + it "should default to RAILS_ROOT + '/spec/fixtures'" do + config.fixture_path.should == RAILS_ROOT + '/spec/fixtures' + ActiveSupport::TestCase.fixture_path.should == RAILS_ROOT + '/spec/fixtures' + ActionController::IntegrationTest.fixture_path.should == RAILS_ROOT + '/spec/fixtures' + end + + it "should set fixture_path" do + config.fixture_path = "/new/path" + config.fixture_path.should == "/new/path" + ActiveSupport::TestCase.fixture_path.should == "/new/path" + ActionController::IntegrationTest.fixture_path.should == "/new/path" + end + end + + describe "#global_fixtures" do + it "should set fixtures on TestCase" do + ActiveSupport::TestCase.should_receive(:fixtures).with(:blah) + config.global_fixtures = [:blah] + end + end + + end + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/controller_example_group_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/controller_example_group_spec.rb new file mode 100644 index 000000000..3a03206ec --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/controller_example_group_spec.rb @@ -0,0 +1,307 @@ +require 'spec_helper' +require 'controller_spec_controller' +require File.join(File.dirname(__FILE__), "/shared_routing_example_group_examples.rb") + +['integration', 'isolation'].each do |mode| + describe "A controller example running in #{mode} mode", :type => :controller do + controller_name :controller_spec + integrate_views if mode == 'integration' + + accesses_configured_helper_methods + it_should_behave_like "a routing example" + + describe "with an implicit subject" do + it "uses the controller" do + subject.should == controller + end + end + + describe "with a specified subject" do + subject { 'specified' } + + it "uses the specified subject" do + subject.should == 'specified' + end + end + + 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 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' + 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 should_receive(:render)" do + controller.should_receive(:render).with(:partial => "controller_spec/partial") + get 'action_with_partial' + end + + it "should allow specifying a partial with should_receive(:render) with object" do + controller.should_receive(:render).with(:partial => "controller_spec/partial", :object => "something") + get 'action_with_partial_with_object', :thing => "something" + end + + it "should allow specifying a partial with should_receive(:render) with locals" do + controller.should_receive(:render).with(:partial => "controller_spec/partial", :locals => {:thing => "something"}) + get 'action_with_partial_with_locals', :thing => "something" + end + + it "should yield to render :update" do + template = stub("template") + controller.should_receive(:render).with(: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_which_sets_flash' + 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 + session[:session_key] = "session value" + lambda do + get 'action_which_gets_session', :expected => "session value" + end.should_not raise_error + end + + it "allows inline rendering" do + get 'action_that_renders_inline' + response.body.should == "inline code" + end + + describe "handling should_receive(:render)" do + it "should warn" do + controller.should_receive(:render).with(:template => "controller_spec/action_with_template") + get :action_with_template + end + end + + describe "handling should_not_receive(:render)" do + it "should warn" do + controller.should_not_receive(:render).with(:template => "the/wrong/template") + get :action_with_template + end + end + + describe "setting cookies in the request" do + + it "should support a String key" do + cookies['cookie_key'] = 'cookie value' + get 'action_which_gets_cookie', :expected => "cookie value" + end + + it "should support a Symbol key" do + cookies[:cookie_key] = 'cookie value' + get 'action_which_gets_cookie', :expected => "cookie value" + end + + it "should support a Hash value" do + cookies[:cookie_key] = {'value' => 'cookie value', 'path' => '/not/default'} + get 'action_which_gets_cookie', :expected => {'value' => 'cookie value', 'path' => '/not/default'} + end + + end + + describe "reading cookies from the response" do + + it "should support a Symbol key" do + get 'action_which_sets_cookie', :value => "cookie value" + if ::Rails::VERSION::STRING >= "2.3" + cookies[:cookie_key].should match("cookie[\+ ]value") + else + cookies[:cookie_key].should == ["cookie value"] + end + end + + it "should support a String key" do + get 'action_which_sets_cookie', :value => "cookie value" + if ::Rails::VERSION::STRING >= "2.3" + cookies['cookie_key'].should match("cookie[\+ ]value") + else + cookies['cookie_key'].should == ["cookie value"] + end + end + + end + + it "should expose instance vars through the assigns hash" do + get 'action_setting_the_assigns_hash' + assigns[:indirect_assigns_key].should == :indirect_assigns_key_value + end + + it "should expose instance vars through the assigns hash that are set to false" do + get 'action_that_assigns_false_to_a_variable' + assigns[:a_variable].should be_false + 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 + + it "should not run a skipped before_filter" do + lambda { + get 'action_with_skipped_before_filter' + }.should_not raise_error + end + + if ::Rails::VERSION::STRING > '2.1' + describe "extending #render on a controller" do + it "supports two arguments (as with rails 2.1)" do + get 'action_with_two_arg_render' + response.body.should =~ /new Effect\.Highlight/ + end + end + end + + it "should access headers" do + request.env['ACCEPT'] = "application/json" + get 'action_that_returns_headers', :header => 'ACCEPT' + response.body.should == "application/json" + end + end + + describe "Given a controller spec for RedirectSpecController running in #{mode} mode", :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" do + example_group = describe "A controller spec" + # , :type => :controller do + # integrate_views if mode == 'integration' + it "a spec in a context without controller_name set should fail with a useful warning" do + pending("need a new way to deal with examples that should_raise") + # , + # :should_raise => [ + # Spec::Expectations::ExpectationNotMetError, + # /You have to declare the controller name in controller specs/ + # ] do + end + end + +end + +['integration', 'isolation'].each do |mode| + describe "A controller example running in #{mode} mode", :type => :controller do + controller_name :controller_inheriting_from_application_controller + integrate_views if mode == 'integration' + + it "should only have a before filter inherited from ApplicationController run once..." do + controller.should_receive(:i_should_only_be_run_once).once + get :action_with_inherited_before_filter + end + end +end + +describe ControllerSpecController, :type => :controller do + it "should use the controller passed to #describe" 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 + describe ApplicationController, :type => :controller do + describe "controller_name" do + controller_name :controller_spec + it "overrides the controller class submitted to the outermost group" do + subject.should be_an_instance_of(ControllerSpecController) + end + describe "in a nested group" do + it "overrides the controller class submitted to the outermost group" do + subject.should be_an_instance_of(ControllerSpecController) + end + describe "(doubly nested)" do + it "overrides the controller class submitted to the outermost group" do + subject.should be_an_instance_of(ControllerSpecController) + end + end + end + end + end + + describe ControllerExampleGroup do + it "should clear its name from the description" do + group = describe("foo", :type => :controller) do + $nested_group = describe("bar") do + end + end + group.description.to_s.should == "foo" + $nested_group.description.to_s.should == "foo bar" + end + end + end + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/controller_isolation_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/controller_isolation_spec.rb new file mode 100644 index 000000000..8a5541871 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/controller_isolation_spec.rb @@ -0,0 +1,75 @@ +require 'spec_helper' +require 'controller_spec_controller' + +describe "a controller spec running in isolation mode", :type => :controller do + controller_name :controller_spec + + it "does not care if the specified template doesn't exist" do + get 'some_action' + response.should be_success + response.should render_template("template/that/does/not/actually/exist") + end + + it "does not care if the implied template doesn't exist" do + get 'some_action_with_implied_template' + response.should be_success + response.should render_template("some_action_with_implied_template") + end + + it "does 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 + + it "does not care if the template exists but the action doesn't" do + get 'non_existent_action_with_existent_template' + response.should be_success + end + + it "fails if the neither the action nor the template exist" do + expect {get 'non_existent_action'}.to raise_error(ActionController::UnknownAction) + end +end + +describe "a controller spec running in integration mode", :type => :controller do + controller_name :controller_spec + integrate_views + + it "renders a template" do + get 'action_with_template' + response.should be_success + response.should have_tag('div', 'This is action_with_template.rhtml') + end + + it "fails if the template doesn't exist" do + error = defined?(ActionController::MissingTemplate) ? ActionController::MissingTemplate : ActionView::MissingTemplate + lambda { get 'some_action' }.should raise_error(error) + end + + it "fails if the template has errors" do + lambda { get 'action_with_errors_in_template' }.should raise_error(ActionView::TemplateError) + end + + it "fails if the action doesn't exist" do + expect {get 'non_existent_action'}.to raise_error(ActionController::UnknownAction) + 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/gems/rspec-rails-1.3.3/spec/spec/rails/example/cookies_proxy_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/cookies_proxy_spec.rb new file mode 100644 index 000000000..141763801 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/cookies_proxy_spec.rb @@ -0,0 +1,87 @@ +require 'spec_helper' + +class CookiesProxyExamplesController < ActionController::Base + def index + cookies[:key] = cookies[:key] + render :text => "" + end +end + +module Spec + module Rails + module Example + describe CookiesProxy, :type => :controller do + controller_name :cookies_proxy_examples + + describe "with a String key" do + + it "should accept a String value" do + proxy = CookiesProxy.new(self) + proxy['key'] = 'value' + get :index + if ::Rails::VERSION::STRING >= "2.3" + proxy['key'].should == 'value' + else + proxy['key'].should == ['value'] + end + end + + it "should accept a Hash value" do + proxy = CookiesProxy.new(self) + proxy['key'] = { :value => 'value', :expires => expiration = 1.hour.from_now, :path => path = '/path' } + get :index + if ::Rails::VERSION::STRING >= "2.3" + proxy['key'].should == 'value' + else + proxy['key'].should == ['value'] + proxy['key'].value.should == ['value'] + proxy['key'].expires.should == expiration + proxy['key'].path.should == path + end + end + + end + + describe "with a Symbol key" do + + it "should accept a String value" do + proxy = CookiesProxy.new(self) + proxy[:key] = 'value' + get :index + if ::Rails::VERSION::STRING >= "2.3" + proxy[:key].should == 'value' + else + proxy[:key].should == ['value'] + end + end + + it "should accept a Hash value" do + proxy = CookiesProxy.new(self) + proxy[:key] = { :value => 'value', :expires => expiration = 1.hour.from_now, :path => path = '/path' } + get :index + if ::Rails::VERSION::STRING >= "2.3" + proxy[:key].should == 'value' + else + proxy[:key].should == ['value'] + proxy[:key].value.should == ['value'] + proxy[:key].expires.should == expiration + proxy[:key].path.should == path + end + end + + end + + describe "#delete" do + it "should delete from the response cookies" do + proxy = CookiesProxy.new(self) + response_cookies = mock('cookies') + response.should_receive(:cookies).and_return(response_cookies) + response_cookies.should_receive(:delete).with('key') + proxy.delete :key + end + end + end + + end + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/error_handling_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/error_handling_spec.rb new file mode 100644 index 000000000..71385eed1 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/error_handling_spec.rb @@ -0,0 +1,90 @@ +require 'spec_helper' +require 'controller_spec_controller' + +['integration', 'isolation'].each do |mode| + describe "A controller example running in #{mode} mode", :type => :controller do + controller_name :controller_spec + integrate_views if mode == 'integration' + + describe "without use_rails_error_handling!" do + describe "with an error that is *not* rescued" do + it "raises the error" do + lambda do + get 'un_rescued_error_action' + end.should raise_error(ControllerSpecController::UnRescuedError) + end + end + describe "with an error that *is* rescued" do + it "returns a 200" do + get 'rescued_error_action' + response.response_code.should == 200 + end + end + end + + describe "with deprecated use_rails_error_handling!" do + before(:each) do + Kernel.stub!(:warn) + end + + it "warns of deprecation" do + Kernel.should_receive(:warn).with(/DEPRECATION NOTICE/) + controller.use_rails_error_handling! + end + + describe "with an error that is *not* rescued" do + it "returns the error code" do + controller.use_rails_error_handling! + get 'un_rescued_error_action' + response.response_code.should == 500 + end + end + + describe "with an error that *is* rescued" do + it "returns a 200" do + controller.use_rails_error_handling! + get 'rescued_error_action' + response.response_code.should == 200 + end + end + end + + describe "with rescue_action_in_public!" do + describe "with an error that is *not* rescued" do + it "returns the error code" do + rescue_action_in_public! + get 'un_rescued_error_action' + response.response_code.should == 500 + end + end + + describe "with an error that *is* rescued" do + it "returns a 200" do + rescue_action_in_public! + get 'rescued_error_action' + response.response_code.should == 200 + end + end + end + + describe "with bypass_rescue" do + describe "with an error that is *not* rescued" do + it "raises the error" do + bypass_rescue + lambda do + get 'un_rescued_error_action' + end.should raise_error(ControllerSpecController::UnRescuedError) + end + end + + describe "with an error that *is* rescued" do + it "raises the error" do + bypass_rescue + lambda do + get 'rescued_error_action' + end.should raise_error(ControllerSpecController::RescuedError) + end + end + end + end +end
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/example_group_factory_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/example_group_factory_spec.rb new file mode 100644 index 000000000..792346f7e --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/example_group_factory_spec.rb @@ -0,0 +1,112 @@ +require 'spec_helper' + +module Spec + module Example + describe ExampleGroupFactory do + it "should return a ModelExampleGroup when given :type => :model" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :type => :model + ) {} + example_group.superclass.should == Spec::Rails::Example::ModelExampleGroup + end + + it "should return a ModelExampleGroup when given :location => '/blah/spec/models/'" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :location => '/blah/spec/models/blah.rb' + ) {} + example_group.superclass.should == Spec::Rails::Example::ModelExampleGroup + end + + it "should return a ModelExampleGroup when given :location => '\\blah\\spec\\models\\' (windows format)" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :location => '\\blah\\spec\\models\\blah.rb' + ) {} + example_group.superclass.should == Spec::Rails::Example::ModelExampleGroup + end + + it "should return an ActiveSupport::TestCase when given :location => '/blah/spec/foo/' (anything other than controllers, views and helpers)" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :location => '/blah/spec/foo/blah.rb' + ) {} + example_group.superclass.should == ActiveSupport::TestCase + end + + it "should return an ActiveSupport::TestCase when given :location => '\\blah\\spec\\foo\\' (windows format) (anything other than controllers, views and helpers)" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :location => '\\blah\\spec\\foo\\blah.rb' + ) {} + example_group.superclass.should == ActiveSupport::TestCase + end + + it "should return a ViewExampleGroup when given :type => :view" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :type => :view + ) {} + example_group.superclass.should == Spec::Rails::Example::ViewExampleGroup + end + + it "should return a ViewExampleGroup when given :location => '/blah/spec/views/'" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :location => '/blah/spec/views/blah.rb' + ) {} + example_group.superclass.should == Spec::Rails::Example::ViewExampleGroup + end + + it "should return a ModelExampleGroup when given :location => '\\blah\\spec\\views\\' (windows format)" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :location => '\\blah\\spec\\views\\blah.rb' + ) {} + example_group.superclass.should == Spec::Rails::Example::ViewExampleGroup + end + + it "should return a HelperExampleGroup when given :type => :helper" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :type => :helper + ) {} + example_group.superclass.should == Spec::Rails::Example::HelperExampleGroup + end + + it "should return a HelperExampleGroup when given :location => '/blah/spec/helpers/'" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :location => '/blah/spec/helpers/blah.rb' + ) {} + example_group.superclass.should == Spec::Rails::Example::HelperExampleGroup + end + + it "should return a ModelExampleGroup when given :location => '\\blah\\spec\\helpers\\' (windows format)" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :location => '\\blah\\spec\\helpers\\blah.rb' + ) {} + example_group.superclass.should == Spec::Rails::Example::HelperExampleGroup + end + + it "should return a ControllerExampleGroup when given :type => :controller" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :type => :controller + ) {} + example_group.superclass.should == Spec::Rails::Example::ControllerExampleGroup + end + + it "should return a ControllerExampleGroup when given :location => '/blah/spec/controllers/'" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :location => '/blah/spec/controllers/blah.rb' + ) {} + example_group.superclass.should == Spec::Rails::Example::ControllerExampleGroup + end + + it "should return a ModelExampleGroup when given :location => '\\blah\\spec\\controllers\\' (windows format)" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :location => '\\blah\\spec\\controllers\\blah.rb' + ) {} + example_group.superclass.should == Spec::Rails::Example::ControllerExampleGroup + end + + it "should favor the :type over the :location" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :location => '/blah/spec/models/blah.rb', :type => :controller + ) {} + example_group.superclass.should == Spec::Rails::Example::ControllerExampleGroup + end + end + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/helper_example_group_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/helper_example_group_spec.rb new file mode 100755 index 000000000..09ad52927 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/helper_example_group_spec.rb @@ -0,0 +1,247 @@ +require '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 + +module Spec + module Rails + module Example + describe HelperExampleGroup, :type => :helper do + helper_name :explicit + + accesses_configured_helper_methods + + 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" + + helper.named_url.should == "http://test.host/rspec_on_rails_specs" + helper.named_path.should == "/rspec_on_rails_specs" + end + + it "should fail if the helper method deson't exist" do + lambda { non_existent_helper_method }.should raise_error(NameError) + lambda { helper.non_existent_helper_method }.should raise_error(NameError) + end + + it "should have access to session" do + session[:foo] = 'bar' + session_foo.should == 'bar' + helper.session_foo.should == 'bar' + end + + it "should have access to params" do + params[:foo] = 'bar' + params_foo.should == 'bar' + helper.params_foo.should == 'bar' + end + + it "should have access to request" do + request.stub!(:thing).and_return('bar') + request_thing.should == 'bar' + helper.request_thing.should == 'bar' + end + + it "should have access to flash" do + flash[:thing] = 'camera' + flash_thing.should == 'camera' + helper.flash_thing.should == 'camera' + end + end + + describe HelperExampleGroup, "#eval_erb", :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 HelperExampleGroup, ".fixtures", :type => :helper do + helper_name :explicit + fixtures :animals + + it "should load fixtures" do + pig = animals(:pig) + pig.class.should == Animal + end + + it "should load global fixtures" do + lachie = people(:lachie) + 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 = [ + 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::NumberHelper, + ActionView::Helpers::PrototypeHelper, + ActionView::Helpers::ScriptaculousHelper, + ActionView::Helpers::TagHelper, + ActionView::Helpers::TextHelper, + ActionView::Helpers::UrlHelper + ] + helpers.each do |helper_module| + it "should include #{helper_module}" do + self.class.ancestors.should include(helper_module) + helper.class.ancestors.should include(helper_module) + end + end + end + + # TODO: BT - Helper Examples should proxy method_missing to a Rails View instance. + # When that is done, remove this method + 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 + + describe HelperExampleGroup, "#assigns", :type => :helper do + helper_name :addition + it "should expose variables to helper" do + assigns[:addend] = 3 + helper.plus(4).should == 7 + end + + it "should make helper ivars available in example" do + assigns[:addend] = 3 + assigns[:addend].should == 3 + end + end + + describe HelperExampleGroup, "using a helper that uses output_buffer inside helper", :type => :helper do + helper_name :explicit + + before(:each) do + if ::Rails::VERSION::STRING < "2.2" + pending("need to get this new feature working against pre 2.2 versions of rails") + end + end + + it "should not raise an error" do + lambda { method_using_output_buffer }.should_not raise_error + end + + it "should put the output in the output_buffer" do + method_using_output_buffer + output_buffer.should == "the_text_from_concat" + end + end + + describe HelperExampleGroup, "using a helper that tries to access @template", :type => :helper do + helper_name :explicit + + it "should not raise an error" do + lambda { method_using_template }.should_not raise_error + end + + it "should have the correct output" do + method_using_template.should have_text(/#some_id/) + end + end + + # both specs the same as textmate invokes first-then-second but rake spec:plugins:rspec_on_rails invokes second-then-first + describe HelperExampleGroup, "new helper for each spec - instance variables side effects are isolated", :type=> :helper do + it 'should be able to set an instance variable on the helper on a new instance of the helper' do + helper.instance_variable_get(:@test_instance_var).should be_nil + helper.instance_variable_set(:@test_instance_var, :first_value) + helper.instance_variable_get(:@test_instance_var).should == :first_value + end + + it 'should get a clean copy of the helper with no saved instance variables from the last run' do + helper.instance_variable_get(:@test_instance_var).should be_nil + helper.instance_variable_set(:@test_instance_var, :second_value) + helper.instance_variable_get(:@test_instance_var).should == :second_value + 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', :type => :helper do + it 'should not raise an error' do + lambda { flash['test'] }.should_not raise_error + end + end +end + +module Spec + module Rails + module Example + describe HelperExampleGroup do + it "should clear its name from the description" do + group = describe("foo", :type => :helper) do + $nested_group = describe("bar") do + end + end + group.description.to_s.should == "foo" + $nested_group.description.to_s.should == "foo bar" + end + end + end + end +end + +module Bug719 + # see http://rspec.lighthouseapp.com/projects/5645/tickets/719 + # FIXME - helper and example provided in ticket. The example did + # fail initially, so running it now shows that the bug is fixed, + # but this doesn't serve as a good internal example. + module ImagesHelper + def hide_images_button + content_tag :div, :class => :hide_images_button do + button_to_function "Hide Images", :id => :hide_images_button do |page| + page[:more_images_button].toggle + page[:image_browser].toggle + end + end + end + end + + describe ImagesHelper, :type => :helper do + it "should render a hide_images_button" do + helper.hide_images_button.should have_tag('div[class=?]','hide_images_button') do + with_tag('input[id=?][type=?][value=?][onclick^=?]', + 'hide_images_button', 'button', 'Hide Images', + "$("more_images_button").toggle();\n$("image_browser").toggle();;") + end + end + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/model_example_group_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/model_example_group_spec.rb new file mode 100644 index 000000000..55138a9aa --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/model_example_group_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +module Spec + module Rails + module Example + describe ModelExampleGroup do + accesses_configured_helper_methods + + if defined?(ActiveRecord::TestCase) + it "derives from ActiveRecord::TestCase" do + group = describe("foo", :type => :model) do; end + group.ancestors.should include(ActiveRecord::TestCase) + end + else + it "derives from ActiveSupport::TestCase" do + group = describe("foo", :type => :model) do; end + group.ancestors.should include(ActiveSupport::TestCase) + end + end + + it "clears its name from the description" do + group = describe("foo", :type => :model) do + $nested_group = describe("bar") do + end + end + group.description.to_s.should == "foo" + $nested_group.description.to_s.should == "foo bar" + end + end + end + end +end
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/routing_example_group_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/routing_example_group_spec.rb new file mode 100644 index 000000000..9da50c0cc --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/routing_example_group_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' +require 'controller_spec_controller' +require File.join(File.dirname(__FILE__), "/shared_routing_example_group_examples.rb") + +describe "Routing Examples", :type => :routing do + it_should_behave_like "a routing example" + it_should_behave_like "a be routable spec" + it_should_behave_like "a route to spec" +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/shared_routing_example_group_examples.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/shared_routing_example_group_examples.rb new file mode 100644 index 000000000..6276f453c --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/shared_routing_example_group_examples.rb @@ -0,0 +1,237 @@ +class CustomRouteSpecController < ActionController::Base; end +class RspecOnRailsSpecsController < ActionController::Base; end + +shared_examples_for "a routing example" do + describe "using backward compatible route_for()" do + it "translates GET-only paths to be explicit" do + self.should_receive(:assert_routing).with(hash_including(:method => :get), anything, {}, anything) + route_for(:controller => "controller_spec", :action => "some_action"). + should == "/controller_spec/some_action" + end + + it "uses assert_routing to specify that the :controller and :action are involved" do + @route = { :controller => "controller_spec", :action => "some_action" } + self.should_receive(:assert_routing).with(anything, @route, {}, anything) + route_for(@route). + should == "/controller_spec/some_action" + end + + it "passes extra args through to assert_routing" do + @route = { :controller => "controller_spec", :action => "some_action" } + self.should_receive(:assert_routing).with(anything, anything, {}, { :a => "1", :b => "2" } ) + route_for(@route). + should == "/controller_spec/some_action?a=1&b=2" + end + + it "passes with an existing route" do + route_for(:controller => "controller_spec", :action => "some_action"). + should == "/controller_spec/some_action" + end + + it "passes with an existing route with additional parameters" do + route_for(:controller => "controller_spec", :action => "some_action", :param => '1'). + should == "/controller_spec/some_action?param=1" + end + + it "recognizes routes with methods besides :get" do + should_receive(:assert_routing).with(hash_including(:method => :put), anything, {}, anything) + + route_for(:controller => "rspec_on_rails_specs", :action => "update", :id => "37"). + should == {:path => "/rspec_on_rails_specs/37", :method => :put} + end + + describe "failing due to bad path:" do + it "raises routing error and suggests should_not be_routeable()" do + lambda { + route_for(:controller => "rspec_on_rails_specs", :action => "nonexistent", :id => "37") == + {:path => "/rspec_on_rails_specs/bad_route/37", :method => :put} + }.should raise_error( ActionController::RoutingError, /suggest.*should_not be_routable/ ) + end + end + + describe "failing due to params mismatch:" do + it "re-raises assertion and suggests should_not be_routeable()" do + lambda { + route_for(:controller => "rspec_on_rails_specs", :action => "nonexistent", :id => "37") == + {:path => "/rspec_on_rails_specs/37", :method => :put} + }.should raise_error( ::Test::Unit::AssertionFailedError, /suggest.*should_not be_routable/ ) + end + end + + describe "failing due to wrong HTTP method" do + it "raises method error and suggest should_not be_routable()" do + lambda { + route_for(:controller => "rspec_on_rails_specs", :action => "update", :id => "37"). + should == {:path => "/rspec_on_rails_specs/37", :method => :post} + }.should raise_error(ActionController::MethodNotAllowed) { |error| error.should_not =~ /should_not be_routable/ } + end + end + + it "generates params for custom routes" do + # redundant, deprecated + params_from(:get, '/custom_route'). + should == {:controller => "custom_route_spec", :action => "custom_route"} + end + + it "generates params for existing routes" do + # redundant, deprecated + params_from(:get, '/controller_spec/some_action'). + should == {:controller => "controller_spec", :action => "some_action"} + end + + it "generates params for existing routes with a query parameters" do + # redundant, deprecated + params_from(:get, '/controller_spec/some_action?param=1'). + should == {:controller => "controller_spec", :action => "some_action", :param => '1'} + end + + it "generates params for existing routes with multiple query parameters" do + # redundant, deprecated + params_from(:get, '/controller_spec/some_action?param1=1¶m2=2'). + should == {:controller => "controller_spec", :action => "some_action", :param1 => '1', :param2 => '2' } + end + end +end + +shared_examples_for "a be routable spec" do + describe "using should_not be_routable()" do + it "passes for a bad route" do + { :put => "/rspec_on_rails_specs/bad_route/37" }. + should_not be_routable + end + it "passes for a bad route having an arg" do + { :put => "/rspec_on_rails_specs/bad_route/37?some_arg=1" }. + should_not be_routable + end + describe "when assert_recognizes throws exceptions:" do + [ ActionController::RoutingError, ActionController::MethodNotAllowed ].each do |e| + it "passes on #{e}" do + self.stub!( :assert_recognizes ).and_return { raise e, "stubbed exception" } + { :get => "/rspec_on_rails_spec/bad_route/37" }.should_not be_routable + end + it "should be_routable on usual Test::Unit::AssertionFailedError" do + # <{}> is predictable because of the way we call assert_recognizes during be_routable(). + self.stub!( :assert_recognizes ).and_return { raise ::Test::Unit::AssertionFailedError, "<{a}> did not match <{}>" } + { :get => "/rspec_on_rails_spec/arguably_bad_route" }.should be_routable + end + it "should re-raise on unusual Test::Unit::AssertionFailedError" do + self.stub!( :assert_recognizes ).and_return { raise ::Test::Unit::AssertionFailedError, "some other message" } + expect { { :get => "/rspec_on_rails_spec/weird_case_route/" }.should be_routable }. + to raise_error + end + end + end + it "test should be_routable" do + { :get => "/custom_route" }. + should be_routable + end + + it "recommends route_to() on failure with should()" do + lambda { + { :get => "/nonexisting_route" }. + should be_routable + }.should raise_error( /route_to\(/) + end + + it "shows actual route that was generated on failure with should_not()" do + begin + { :get => "/custom_route" }.should_not be_routable + rescue Exception => e + ensure + # Different versions of ruby order these differently + e.message.should =~ /"action"=>"custom_route"/ + e.message.should =~ /"controller"=>"custom_route_spec"/ + end + end + + it "works with routeable (alternate spelling)" do + { :put => "/nonexisting_route" }. + should_not be_routeable + end + end +end + +shared_examples_for "a route to spec" do + describe "using should[_not] route_to()" do + it "supports existing routes" do + { :get => "/controller_spec/some_action" }. + should route_to( :controller => "controller_spec", :action => "some_action" ) + end + + it "translates GET-only paths to be explicit, when matching against a string (for parity with route_for().should == '/path')" do + self.should_receive(:assert_routing).with(hash_including(:method => :get), anything, {}, anything) + "/controller_spec/some_action". + should route_to({}) + end + + it "asserts, using assert_routing, that the :controller and :action are involved" do + @route = { :controller => "controller_spec", :action => "some_action" } + self.should_receive(:assert_routing).with(anything, @route, {}, anything) + "/controller_spec/some_action". + should route_to(@route) + end + + it "sends extra args through" do + @route = { :controller => "controller_spec", :action => "some_action" } + self.should_receive(:assert_routing).with(anything, anything, {}, { :a => "1", :b => "2" } ) + "/controller_spec/some_action?a=1&b=2". + should route_to( @route ) + end + + it "supports routes with additional parameters" do + { :get => "/controller_spec/some_action?param=1" }. + should route_to( :controller => "controller_spec", :action => "some_action", :param => '1' ) + end + + it "recognizes routes with methods besides :get" do + self.should_receive(:assert_routing).with(hash_including(:method => :put), anything, {}, anything) + { :put => "/rspec_on_rails_specs/37" }. + should route_to(:controller => "rspec_on_rails_specs", :action => "update", :id => "37") + end + + it "allows only one key/value in the path - :method => path" do + lambda { + { :a => "b" ,:c => "d" }. + should route_to("anything") + }.should raise_error( ArgumentError, /usage/ ) + end + + describe "failing due to bad path" do + it "raises routing error, and suggests should_not be_routeable()" do + lambda { + { :put => "/rspec_on_rails_specs/nonexistent/37" }. + should route_to(:controller => "rspec_on_rails_specs", :action => "nonexistent", :id => "37") + }.should raise_error( ActionController::RoutingError, /suggest.*nonexistent.*should_not be_routable/ ) + end + end + + describe "failing due to params mismatch" do + it "raises assertion, and suggests should_not be_routeable()" do + lambda { + { :put => "/rspec_on_rails_specs/37" }. + should route_to(:controller => "rspec_on_rails_specs", :action => "nonexistent", :id => "37") + }.should raise_error( ::Test::Unit::AssertionFailedError, /suggest.*rspec_on_rails_specs\/37.*should_not be_routable/ ) + end + end + + describe "passing when expected failure" do + it "suggests should_not be_routable()" do + self.stub!(:assert_routing).and_return true + lambda { + { :put => "/rspec_on_rails_specs/37" }. + should_not route_to(:controller => "rspec_on_rails_specs", :action => "update", :id => "37") + }.should raise_error( /expected a routing error.*be_routable/im ) + end + end + + describe "failing due to wrong HTTP method" do + it "raises method error and suggests should_not be_routable()" do + self.stub!(:assert_routing) { raise ActionController::MethodNotAllowed } + lambda { + { :post => "/rspec_on_rails_specs/37" }. + should route_to(:controller => "rspec_on_rails_specs", :action => "update", :id => "37" ) + }.should raise_error(ActionController::MethodNotAllowed, /rspec_on_rails_specs\/37.*should_not be_routable/ ) + end + end + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb new file mode 100644 index 000000000..ae720a4d8 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe "assert_equal", :shared => true do + it "like assert_equal" do + assert_equal 1, 1 + lambda { + assert_equal 1, 2 + }.should raise_error(::Test::Unit::AssertionFailedError) + end +end + +describe "A model spec should be able to access 'test/unit' assertions", :type => :model do + it_should_behave_like "assert_equal" +end + +describe "A view spec should be able to access 'test/unit' assertions", :type => :view do + it_should_behave_like "assert_equal" +end + +describe "A helper spec should be able to access 'test/unit' assertions", :type => :helper do + it_should_behave_like "assert_equal" +end + +describe "A controller spec with integrated views should be able to access 'test/unit' assertions", :type => :controller do + controller_name :controller_spec + integrate_views + it_should_behave_like "assert_equal" +end + +describe "A controller spec should be able to access 'test/unit' assertions", :type => :controller do + controller_name :controller_spec + it_should_behave_like "assert_equal" +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/view_example_group_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/view_example_group_spec.rb new file mode 100644 index 000000000..f4827a7fc --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/example/view_example_group_spec.rb @@ -0,0 +1,346 @@ +require 'spec_helper' + +describe "A template with an implicit helper", :type => :view do + before(:each) do + render "view_spec/implicit_helper" + end + + accesses_configured_helper_methods + + 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 + + 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 +end + +describe "A template requiring an explicit helper", :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", :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", :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", :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 should_receive(:render) with the right partial" do + template.should_receive(:render).with(:partial => 'partial') + render! + template.verify_rendered + end + + it "should fail should_receive(:render) with the wrong partial" do + template.should_receive(:render).with(:partial => 'non_existent') + render! + begin + template.verify_rendered + rescue Spec::Mocks::MockExpectationError => e + ensure + e.backtrace.find{|line| line =~ /#{__FILE__}\:#{__LINE__ - 6}/}.should_not be_nil + end + end + + it "should pass should_receive(:render) when a partial is expected twice and happens twice" do + template.should_receive(:render).with(:partial => 'partial_used_twice').twice + render! + template.verify_rendered + end + + it "should pass should_receive(:render) when a partial is expected once and happens twice" do + template.should_receive(:render).with(:partial => 'partial_used_twice') + render! + begin + template.verify_rendered + rescue Spec::Mocks::MockExpectationError => e + ensure + e.backtrace.find{|line| line =~ /#{__FILE__}\:#{__LINE__ - 6}/}.should_not be_nil + end + end + + it "should fail should_receive(:render) with the right partial but wrong options" do + template.should_receive(:render).with(: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", :type => :view do + it "should support should_receive(:render) with nested partial" do + obj = Object.new + template.should_receive(:render).with(: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", :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" do + template.should_receive(:render).with(: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", :type => :view do + before(:each) do + renderable_object = Object.new + renderable_object.stub!(:name).and_return("Renderable Object") + assigns[:array] = [renderable_object] + end + + it "should render the array passed through to render_partial without modification" do + render "view_spec/template_with_partial_with_array" + response.body.should match(/^Renderable Object$/) + end +end + +describe "Different types of renders (not :template)", :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", :type => :view do + before(:each) do + session[:key] = "session" + params[:key] = "params" + flash[:key] = "flash" + flash.now[:now_key] = "flash.now" + render "view_spec/accessor" + end + + it "uses the template as the implicit subject" do + subject.should == template + end + + it "has access to session data" do + response.should have_tag("div#session", "session") + end + + it "has access to params data" do + response.should have_tag("div#params", "params") + end + + it "has access to flash" do + response.should have_tag("div#flash", "flash") + end + + it "has access to flash.now" do + response.should have_tag("div#flash_now", "flash.now") + end + + it "has a controller param" do + response.should have_tag("div#controller", "view_spec") + end + + it "has an action param" do + response.should have_tag("div#action", "accessor") + end +end + +describe "A view with a form_tag", :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 ViewExampleGroupController", :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 + +describe "a block helper", :type => :view do + it "should not yield when not told to in the example" do + template.should_receive(:if_allowed) + render "view_spec/block_helper" + response.should_not have_tag("div","block helper was rendered") + end + + it "should yield when told to in the example" do + template.should_receive(:if_allowed).and_yield + render "view_spec/block_helper" + response.should have_tag("div","block helper was rendered") + 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 + +describe "render 'view_spec/foo/show'", :type => :view do + it "should derive action name using the first part of the template name" do + render 'view_spec/foo/show' + request.path_parameters[:action].should == 'show' + end +end + +describe "view_spec/foo/show", :type => :view do + context "rendered with no args" do + it "renders just fine" do + render + request.path_parameters[:action].should == 'show' + end + end +end + +describe "setting path parameters", :type => :view do + describe "(controller)" do + it "should supercede the default path parameters" do + render "view_spec/entry_form", :path_parameters => {:controller => 'foo'} + request.path_parameters[:controller].should == 'foo' + end + end + describe "(action)" do + it "should supercede the default path parameters" do + render "view_spec/entry_form", :path_parameters => {:action => 'foo'} + request.path_parameters[:action].should == 'foo' + end + end + describe "(something arbitrary)" do + it "should supercede the default path parameters" do + render "view_spec/entry_form", :path_parameters => {:foo => 'bar'} + request.path_parameters[:foo].should == 'bar' + end + end +end + +describe "route helpers", :type => :view do + it "should be available before render is called" do + custom_route_path.should == '/custom_route' + end +end + +module Spec + module Rails + module Example + describe ViewExampleGroup do + it "should clear its name from the description" do + group = describe("foo", :type => :view) do + $nested_group = describe("bar") do + end + end + 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.new(Spec::Example::ExampleProxy.new) {} + + ActionView::Base.should_receive(:base_view_path=).with(nil) + example.run_after_each + end + end + end + end +end + +describe "bug http://rspec.lighthouseapp.com/projects/5645/tickets/510", :type => :view do + describe "a view example with should_not_receive" do + it "should render the view" do + obj = mock('model') + obj.should_receive(:render_partial?).and_return false + assigns[:obj] = obj + template.should_not_receive(:render).with(:partial => 'some_partial') + render "view_spec/should_not_receive" + end + end +end + +describe "bug https://rspec.lighthouseapp.com/projects/5645/tickets/787", :type => :view do + describe "a view example checking a link" do + it "should have access to link_to" do + render "view_spec/view_helpers" + response.body.should include(link_to("edit", "this_is_the_link")) + end + + it "should use link_to within have_tag" do + render "view_spec/view_helpers" + response.body.should have_tag("span", :html => link_to("edit", "this_is_the_link")) + end + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/extensions/action_view_base_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/extensions/action_view_base_spec.rb new file mode 100644 index 000000000..ff309a17c --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/extensions/action_view_base_spec.rb @@ -0,0 +1,79 @@ +require 'spec_helper' +require 'spec/mocks/errors' + +describe ActionView::Base, "with RSpec extensions:", :type => :view do + + describe "should_receive(:render)" do + it "should not raise when render has been received" do + template.should_receive(:render).with(:partial => "name") + template.render :partial => "name" + end + + it "should not raise when render with local assignments has been received" do + template.should_receive(:render).with('name', :param => 1) + template.render 'name', :param => 1 + end + + it "should raise when render has NOT been received" do + template.should_receive(:render).with(:partial => "name") + lambda { + template.verify_rendered + }.should raise_error + end + + it "should return something (like a normal mock)" do + template.should_receive(:render).with(:partial => "name").and_return("Little Johnny") + result = template.render :partial => "name" + result.should == "Little Johnny" + end + end + + [:stub!, :stub].each do |method| + describe "#{method}(:render)" do + it "should not raise when stubbing and render has been received" do + template.send(method, :render).with(:partial => "name") + template.render :partial => "name" + end + + it "should not raise when stubbing and render has NOT been received" do + template.send(method, :render).with(:partial => "name") + end + + it "should not raise when stubbing and render has been received with different options" do + template.send(method, :render).with(:partial => "name") + template.render :partial => "view_spec/spacer" + end + + it "should not raise when stubbing and expecting and render has been received" do + template.send(method, :render).with(:partial => "name") + template.should_receive(:render).with(:partial => "name") + template.render(:partial => "name") + end + end + + describe "#{method}(:helper_method)" do + it "should not raise when stubbing and helper_method has been received" do + template.send(method, :helper_method).with(:arg => "value") + template.helper_method :arg => "value" + end + + it "should not raise when stubbing and helper_method has NOT been received" do + template.send(method, :helper_method).with(:arg => "value") + end + + it "SHOULD raise when stubbing and helper_method has been received with different options" do + template.send(method, :helper_method).with(:arg => "value") + expect { template.helper_method :arg => "other_value" }. + to raise_error(/undefined .* `helper_method'/) + end + + it "should not raise when stubbing and expecting and helper_method has been received" do + template.send(method, :helper_method).with(:arg => "value") + template.should_receive(:helper_method).with(:arg => "value") + template.helper_method(:arg => "value") + end + end + + end + +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/extensions/active_record_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/extensions/active_record_spec.rb new file mode 100644 index 000000000..f616973cf --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/extensions/active_record_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe "A model" do + fixtures :things + it "should tell you its required fields" do + Thing.new.should have(1).error_on(:name) + end + + it "should tell you how many records it has" do + Thing.should have(:no).records + Thing.create(:name => "THE THING") + Thing.should have(1).record + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/interop/testcase_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/interop/testcase_spec.rb new file mode 100644 index 000000000..bde8b6c31 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/interop/testcase_spec.rb @@ -0,0 +1,70 @@ +require 'spec_helper' + + +if ActiveSupport.const_defined?(:Callbacks) && Test::Unit::TestCase.include?(ActiveSupport::Callbacks) + + class TestUnitTesting < Test::Unit::TestCase + @@setup_callback_count = 0 + @@setup_method_count = 0 + @@teardown_callback_count = 0 + @@teardown_method_count = 0 + cattr_accessor :setup_callback_count, :setup_method_count, :teardown_callback_count, :teardown_method_count + + setup :do_some_setup + teardown :do_some_teardown + + @@has_been_run = false + def self.run? + @@has_been_run + end + + def self.run(options=Spec::Runner.options) + super options + end + + def do_some_setup + @@setup_callback_count += 1 + end + + def setup + @@setup_method_count += 1 + end + + def test_something + assert_equal true, true + @@has_been_run = true + end + + def teardown + @@teardown_method_count += 1 + end + + def do_some_teardown + @@teardown_callback_count += 1 + end + end + + module Test + module Unit + describe "Running TestCase tests" do + before(:all) do + TestUnitTesting.run unless TestUnitTesting.run? + end + + it "should call the setup callbacks" do + TestUnitTesting.setup_callback_count.should == 1 + end + it "should still only call the normal setup method once" do + TestUnitTesting.setup_method_count.should == 1 + end + it "should call the teardown callbacks" do + TestUnitTesting.teardown_callback_count.should == 1 + end + it "should still only call the normal teardown method once" do + TestUnitTesting.teardown_method_count.should == 1 + end + end + end + end + +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/ar_be_valid_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/ar_be_valid_spec.rb new file mode 100644 index 000000000..0f752e9cb --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/ar_be_valid_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe "be_valid" do + context "with valid attributes" do + it "returns true" do + be_valid.matches?(Thing.new(:name => 'thing')).should == true + end + end + + context "with invalid attributes" do + it "returns false" do + be_valid.matches?(Thing.new).should == false + end + + it "adds errors to the errors " do + expect { Thing.new.should be_valid }.to raise_error(/can't be blank/) + end + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/assert_select_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/assert_select_spec.rb new file mode 100644 index 000000000..f8da8e3b8 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/assert_select_spec.rb @@ -0,0 +1,835 @@ +require 'spec_helper' + +# assert_select plugins for Rails +# +# Copyright (c) 2006 Assaf Arkin, under Creative Commons Attribution and/or MIT License +# Developed for http://co.mments.com +# Code and documention: http://labnotes.org + +class AssertSelectController < ActionController::Base + + def response=(content) + @content = content + end + + def html() + render :text=>@content, :layout=>false, :content_type=>Mime::HTML + @content = nil + end + + def rjs() + update = @update + render :update do |page| + update.call page + end + @update = nil + end + + def xml() + render :text=>@content, :layout=>false, :content_type=>Mime::XML + @content = nil + end + +end + +class AssertSelectMailer < ActionMailer::Base + + def test(html) + recipients "test <test@test.host>" + from "test@test.host" + subject "Test e-mail" + part :content_type=>"text/html", :body=>html + end + +end + +module AssertSelectSpecHelpers + def render_html(html) + @controller.response = html + get :html + end + + def render_rjs(&block) + clear_response + @controller.response &block + get :rjs + end + + def render_xml(xml) + @controller.response = xml + get :xml + end + + def first_non_rspec_line_in_backtrace_of(error) + rlocation = File.join('rspec', 'lib', 'spec') + error.backtrace.reject { |line| + line =~ /#{rlocation}/ + }.first + end + + private + # necessary for 1.2.1 + def clear_response + render_html("") + end +end + +unless defined?(SpecFailed) + SpecFailed = Spec::Expectations::ExpectationNotMetError +end + +describe "should have_tag", :type => :controller do + include AssertSelectSpecHelpers + controller_name :assert_select + integrate_views + + it "should not care about the XML setting on HTML with unclosed singletons when using a response" do + render_html %Q{<table id="1"><tr><td><img src="image.png" alt="image">Hello</td></tr><tr><td></td></tr><tr><td>World</td></tr></table>} + response.should have_tag("tr", 3) + response.should have_tag("tr", 3, :xml => true) + end + + it "should find specific numbers of elements" do + render_html %Q{<div id="1"></div><div id="2"></div>} + response.should have_tag( "div" ) + response.should have_tag("div", 2) + lambda { response.should_not have_tag("div") }.should raise_error(SpecFailed, "should not have tag(\"div\"), but did") + + lambda { response.should have_tag("div", 3) }.should raise_error(SpecFailed) + lambda { response.should have_tag("p") }.should raise_error(SpecFailed) + end + + it "should expect to find elements when using true" do + render_html %Q{<div id="1"></div><div id="2"></div>} + response.should have_tag( "div", true ) + lambda { response.should have_tag( "p", true )}.should raise_error(SpecFailed) + end + + it "should expect to not find elements when using false" do + render_html %Q{<div id="1"></div><div id="2"></div>} + response.should have_tag( "p", false ) + lambda { response.should have_tag( "div", false )}.should raise_error(SpecFailed) + end + + + it "should match submitted text using text or regexp" do + render_html %Q{<div id="1">foo</div><div id="2">foo</div>} + response.should have_tag("div", "foo") + response.should have_tag("div", /(foo|bar)/) + response.should have_tag("div", :text=>"foo") + response.should have_tag("div", :text=>/(foo|bar)/) + + lambda { response.should have_tag("div", "bar") }.should raise_error(SpecFailed) + lambda { response.should have_tag("div", :text=>"bar") }.should raise_error(SpecFailed) + lambda { response.should have_tag("p", :text=>"foo") }.should raise_error(SpecFailed) + + lambda { response.should have_tag("div", /foobar/) }.should raise_error(SpecFailed) + lambda { response.should have_tag("div", :text=>/foobar/) }.should raise_error(SpecFailed) + lambda { response.should have_tag("p", :text=>/foo/) }.should raise_error(SpecFailed) + end + + it "should use submitted message" do + render_html %Q{nothing here} + lambda { + response.should have_tag("div", {}, "custom message") + }.should raise_error(SpecFailed, /custom message/) + end + + it "should match submitted html" do + render_html %Q{<p>\n<em>"This is <strong>not</strong> a big problem,"</em> he said.\n</p>} + text = "\"This is not a big problem,\" he said." + html = "<em>\"This is <strong>not</strong> a big problem,\"</em> he said." + response.should have_tag("p", text) + lambda { response.should have_tag("p", html) }.should raise_error(SpecFailed) + response.should have_tag("p", :html=>html) + lambda { response.should have_tag("p", :html=>text) }.should raise_error(SpecFailed) + + # # No stripping for pre. + render_html %Q{<pre>\n<em>"This is <strong>not</strong> a big problem,"</em> he said.\n</pre>} + text = "\n\"This is not a big problem,\" he said.\n" + html = "\n<em>\"This is <strong>not</strong> a big problem,\"</em> he said.\n" + response.should have_tag("pre", text) + lambda { response.should have_tag("pre", html) }.should raise_error(SpecFailed) + response.should have_tag("pre", :html=>html) + lambda { response.should have_tag("pre", :html=>text) }.should raise_error(SpecFailed) + end + + it "should match number of instances" do + render_html %Q{<div id="1">foo</div><div id="2">foo</div>} + response.should have_tag("div", 2) + lambda { response.should have_tag("div", 3) }.should raise_error(SpecFailed) + response.should have_tag("div", 1..2) + lambda { response.should have_tag("div", 3..4) }.should raise_error(SpecFailed) + response.should have_tag("div", :count=>2) + lambda { response.should have_tag("div", :count=>3) }.should raise_error(SpecFailed) + response.should have_tag("div", :minimum=>1) + response.should have_tag("div", :minimum=>2) + lambda { response.should have_tag("div", :minimum=>3) }.should raise_error(SpecFailed) + response.should have_tag("div", :maximum=>2) + response.should have_tag("div", :maximum=>3) + lambda { response.should have_tag("div", :maximum=>1) }.should raise_error(SpecFailed) + response.should have_tag("div", :minimum=>1, :maximum=>2) + lambda { response.should have_tag("div", :minimum=>3, :maximum=>4) }.should raise_error(SpecFailed) + end + + it "substitution values" do + render_html %Q{<div id="1">foo</div><div id="2">foo</div><span id="3"></span>} + response.should have_tag("div#?", /\d+/) do |elements| #using do/end + elements.size.should == 2 + end + response.should have_tag("div#?", /\d+/) { |elements| #using {} + elements.size.should == 2 + } + lambda { + response.should have_tag("div#?", /\d+/) do |elements| + elements.size.should == 3 + end + }.should raise_error(SpecFailed, "expected: 3,\n got: 2 (using ==)") + + lambda { + response.should have_tag("div#?", /\d+/) { |elements| + elements.size.should == 3 + } + }.should raise_error(SpecFailed, "expected: 3,\n got: 2 (using ==)") + + response.should have_tag("div#?", /\d+/) do |elements| + elements.size.should == 2 + with_tag("#1") + with_tag("#2") + without_tag("#3") + end + end + + #added for RSpec + it "nested tags in form" do + render_html %Q{ + <form action="test"> + <input type="text" name="email"> + </form> + <form action="other"> + <input type="text" name="other_input"> + </form> + } + response.should have_tag("form[action=test]") { |form| + with_tag("input[type=text][name=email]") + } + response.should have_tag("form[action=other]") { |form| + with_tag("input[type=text][name=other_input]") + } + + lambda { + response.should have_tag("form[action=test]") { |form| + with_tag("input[type=text][name=other_input]") + } + }.should raise_error(SpecFailed) + + lambda { + response.should have_tag("form[action=test]") { + with_tag("input[type=text][name=other_input]") + } + }.should raise_error(SpecFailed) + end + + 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"> + </form> + } + begin + response.should have_tag("form[action=test]") { + @expected_error_line = __LINE__; assert false + } + rescue => e + 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) + BEATLES = [ + ["John", "Guitar"], + ["George", "Guitar"], + ["Paul", "Bass"], + ["Ringo", "Drums"] + ] + end + + render_html %Q{ + <div id="beatles"> + <div class="beatle"> + <h2>John</h2><p>Guitar</p> + </div> + <div class="beatle"> + <h2>George</h2><p>Guitar</p> + </div> + <div class="beatle"> + <h2>Paul</h2><p>Bass</p> + </div> + <div class="beatle"> + <h2>Ringo</h2><p>Drums</p> + </div> + </div> + } + response.should have_tag("div#beatles>div[class=\"beatle\"]", 4) + + response.should have_tag("div#beatles>div.beatle") { + BEATLES.each { |name, instrument| + with_tag("div.beatle>h2", name) + with_tag("div.beatle>p", instrument) + without_tag("div.beatle>span") + } + } + end + + it "assert_select_text_match" do + render_html %Q{<div id="1"><span>foo</span></div><div id="2"><span>bar</span></div>} + response.should have_tag("div") do |divs| + with_tag("div", "foo") + with_tag("div", "bar") + with_tag("div", /\w*/) + with_tag("div", /\w*/, :count=>2) + without_tag("div", :text=>"foo", :count=>2) + with_tag("div", :html=>"<span>bar</span>") + with_tag("div", :html=>"<span>bar</span>") + with_tag("div", :html=>/\w*/) + with_tag("div", :html=>/\w*/, :count=>2) + without_tag("div", :html=>"<span>foo</span>", :count=>2) + end + end + + + it "assert_select_from_rjs with one item" do + render_rjs do |page| + page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>" + end + response.should have_tag("div") { |elements| + elements.size.should == 2 + with_tag("#1") + with_tag("#2") + } + + lambda { + response.should have_tag("div") { |elements| + elements.size.should == 2 + with_tag("#1") + with_tag("#3") + } + }.should raise_error(SpecFailed) + + lambda { + response.should have_tag("div") { |elements| + elements.size.should == 2 + with_tag("#1") + without_tag("#2") + } + }.should raise_error(SpecFailed, "should not have tag(\"#2\"), but did") + + lambda { + response.should have_tag("div") { |elements| + elements.size.should == 3 + with_tag("#1") + with_tag("#2") + } + }.should raise_error(SpecFailed) + + + response.should have_tag("div#?", /\d+/) { |elements| + with_tag("#1") + with_tag("#2") + } + end + + it "assert_select_from_rjs with multiple items" do + render_rjs do |page| + page.replace_html "test", "<div id=\"1\">foo</div>" + page.replace_html "test2", "<div id=\"2\">foo</div>" + end + response.should have_tag("div") + response.should have_tag("div") { |elements| + elements.size.should == 2 + with_tag("#1") + with_tag("#2") + } + + lambda { + response.should have_tag("div") { |elements| + with_tag("#3") + } + }.should raise_error(SpecFailed) + end +end + +describe "css_select", :type => :controller do + include AssertSelectSpecHelpers + controller_name :assert_select + integrate_views + + it "can select tags from html" do + render_html %Q{<div id="1"></div><div id="2"></div>} + css_select("div").size.should == 2 + css_select("p").size.should == 0 + end + + + it "can select nested tags from html" do + render_html %Q{<div id="1">foo</div><div id="2">foo</div>} + response.should have_tag("div#?", /\d+/) { |elements| + css_select(elements[0], "div").should have(1).element + css_select(elements[1], "div").should have(1).element + } + response.should have_tag("div") { + css_select("div").should have(2).elements + css_select("div").each { |element| + # Testing as a group is one thing + css_select("#1,#2").should have(2).elements + # Testing individually is another + css_select("#1").should have(1).element + css_select("#2").should have(1).element + } + } + end + + it "can select nested tags from rjs (one result)" do + render_rjs do |page| + page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>" + end + css_select("div").should have(2).elements + css_select("#1").should have(1).element + css_select("#2").should have(1).element + end + + it "can select nested tags from rjs (two results)" do + render_rjs do |page| + page.replace_html "test", "<div id=\"1\">foo</div>" + page.replace_html "test2", "<div id=\"2\">foo</div>" + end + css_select("div").should have(2).elements + css_select("#1").should have(1).element + css_select("#2").should have(1).element + end + +end + +describe "have_rjs behaviour_type", :type => :controller do + include AssertSelectSpecHelpers + controller_name :assert_select + integrate_views + + before(:each) do + render_rjs do |page| + page.replace "test1", "<div id=\"1\">foo</div>" + page.replace_html "test2", "<div id=\"2\">bar</div><div id=\"3\">none</div>" + page.insert_html :top, "test3", "<div id=\"4\">loopy</div>" + page.hide "test4" + page["test5"].hide + end + end + + it "should pass if any rjs exists" do + response.should have_rjs + end + + it "should fail if no rjs exists" do + render_rjs do |page| + end + lambda do + response.should have_rjs + end.should raise_error(SpecFailed) + end + + it "should find all rjs from multiple statements" do + response.should have_rjs do + with_tag("#1") + with_tag("#2") + with_tag("#3") + with_tag("#4") + end + end + + it "should find by id" do + response.should have_rjs("test1") { |rjs| + rjs.size.should == 1 + with_tag("div", 1) + with_tag("div#1", "foo") + } + + lambda do + response.should have_rjs("test1") { |rjs| + rjs.size.should == 1 + without_tag("div#1", "foo") + } + end.should raise_error(SpecFailed, "should not have tag(\"div#1\", \"foo\"), but did") + + response.should have_rjs("test2") { |rjs| + rjs.size.should == 2 + with_tag("div", 2) + with_tag("div#2", "bar") + with_tag("div#3", "none") + } + # response.should have_rjs("test4") + # response.should have_rjs("test5") + end + + # specify "should find rjs using :hide" do + # response.should have_rjs(:hide) + # response.should have_rjs(:hide, "test4") + # response.should have_rjs(:hide, "test5") + # lambda do + # response.should have_rjs(:hide, "test3") + # end.should raise_error(SpecFailed) + # end + + it "should find rjs using :replace" do + response.should have_rjs(:replace) { |rjs| + with_tag("div", 1) + with_tag("div#1", "foo") + } + response.should have_rjs(:replace, "test1") { |rjs| + with_tag("div", 1) + with_tag("div#1", "foo") + } + lambda { + response.should have_rjs(:replace, "test2") + }.should raise_error(SpecFailed) + + lambda { + response.should have_rjs(:replace, "test3") + }.should raise_error(SpecFailed) + end + + it "should find rjs using :replace_html" do + response.should have_rjs(:replace_html) { |rjs| + with_tag("div", 2) + with_tag("div#2", "bar") + with_tag("div#3", "none") + } + + response.should have_rjs(:replace_html, "test2") { |rjs| + with_tag("div", 2) + with_tag("div#2", "bar") + with_tag("div#3", "none") + } + + lambda { + response.should have_rjs(:replace_html, "test1") + }.should raise_error(SpecFailed) + + lambda { + response.should have_rjs(:replace_html, "test3") + }.should raise_error(SpecFailed) + end + + it "should find rjs using :insert_html (non-positioned)" do + response.should have_rjs(:insert_html) { |rjs| + with_tag("div", 1) + with_tag("div#4", "loopy") + } + + response.should have_rjs(:insert_html, "test3") { |rjs| + with_tag("div", 1) + with_tag("div#4", "loopy") + } + + lambda { + response.should have_rjs(:insert_html, "test1") + }.should raise_error(SpecFailed) + + lambda { + response.should have_rjs(:insert_html, "test2") + }.should raise_error(SpecFailed) + end + + it "should find rjs using :insert (positioned)" do + render_rjs do |page| + page.insert_html :top, "test1", "<div id=\"1\">foo</div>" + page.insert_html :bottom, "test2", "<div id=\"2\">bar</div>" + page.insert_html :before, "test3", "<div id=\"3\">none</div>" + page.insert_html :after, "test4", "<div id=\"4\">loopy</div>" + end + response.should have_rjs(:insert, :top) do + with_tag("div", 1) + with_tag("#1") + end + response.should have_rjs(:insert, :top, "test1") do + with_tag("div", 1) + with_tag("#1") + end + response.should have_rjs(:insert, :bottom) {|rjs| + with_tag("div", 1) + with_tag("#2") + } + response.should have_rjs(:insert, :bottom, "test2") {|rjs| + with_tag("div", 1) + with_tag("#2") + } + response.should have_rjs(:insert, :before) {|rjs| + with_tag("div", 1) + with_tag("#3") + } + response.should have_rjs(:insert, :before, "test3") {|rjs| + with_tag("div", 1) + with_tag("#3") + } + response.should have_rjs(:insert, :after) {|rjs| + with_tag("div", 1) + with_tag("#4") + } + response.should have_rjs(:insert, :after, "test4") {|rjs| + with_tag("div", 1) + with_tag("#4") + } + end + + it "should find rjs using :insert (positioned)" do + pending("await fix for http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/982") + render_rjs do |page| + page.insert_html :top, "test1", "<div id=\"1\">foo</div>" + page.insert_html :bottom, "test2", "<div id=\"2\">bar</div>" + end + lambda { + response.should have_rjs(:insert, :top, "test2") + }.should raise_error(SpecFailed) + end +end + +describe "send_email behaviour_type", :type => :controller do + include AssertSelectSpecHelpers + controller_name :assert_select + integrate_views + + before(:each) do + ActionMailer::Base.delivery_method = :test + ActionMailer::Base.perform_deliveries = true + ActionMailer::Base.deliveries = [] + end + + after(:each) do + ActionMailer::Base.deliveries.clear + end + + it "should fail with nothing sent" do + response.should_not send_email + lambda { + response.should send_email{} + }.should raise_error(SpecFailed, /No e-mail in delivery list./) + end + + it "should pass otherwise" do + AssertSelectMailer.deliver_test "<div><p>foo</p><p>bar</p></div>" + response.should send_email + lambda { + response.should_not send_email + }.should raise_error(SpecFailed) + response.should send_email{} + response.should send_email { + with_tag("div:root") { + with_tag("p:first-child", "foo") + with_tag("p:last-child", "bar") + } + } + + lambda { + response.should_not send_email + }.should raise_error(SpecFailed, "should not send email, but did") + end + +end + +describe "string.should have_tag", :type => :helper do + include AssertSelectSpecHelpers + + it "should find root element" do + "<p>a paragraph</p>".should have_tag("p", "a paragraph") + end + + it "should not find non-existent element" do + lambda do + "<p>a paragraph</p>".should have_tag("p", "wrong text") + end.should raise_error(SpecFailed) + end + + it "should find child element" do + "<div><p>a paragraph</p></div>".should have_tag("p", "a paragraph") + end + + it "should find nested element in one line" do + "<div><p>a paragraph</p></div>".should have_tag("div p","a paragraph") + end + + it "should find nested element" do + "<div><p>a paragraph</p></div>".should have_tag("div") do + with_tag("p", "a paragraph") + end + end + + it "should not find wrong nested element" do + lambda do + "<div><p>a paragraph</p></div>".should have_tag("div") do + with_tag("p", "wrong text") + end + end.should raise_error(SpecFailed) + end + + it "should raise when using an HTML string with unclosed singleton tags when using the XML parsing setting" do + lambda do + %Q{<table id="1"><tr><td><img src="image.png" alt="image">Hello</td></tr><tr><td></td></tr><tr><td>World</td></tr></table>}. + should have_tag("tr", 3, :xml => true) + end.should raise_error + end + + it "should find the specific number of elements regardless of unclosed singletons in a HTML string" do + %Q{<table id="1"><tr><td><img src="image.png" alt="image">Hello</td></tr><tr><td></td></tr><tr><td>World</td></tr></table>}. + should have_tag("tr", 3) + end + + it "should find nested tags in an HTML string regardless unclosed singletons" do + %Q{<table id="1"><tr><td><img src="image.png" alt="image">Hello</td></tr><tr><td></td></tr><tr><td>World</td></tr></table>}. + should have_tag("table") do + with_tag('tr',3) + end + end + +end + +describe "have_tag", :type => :controller do + include AssertSelectSpecHelpers + controller_name :assert_select + integrate_views + + it "should work exactly the same as assert_select" do + render_html %Q{ + <div id="wrapper">foo + <div class="piece"> + <h3>Text</h3> + </div> + <div class="piece"> + <h3>Another</h3> + </div> + </div> + } + + assert_select "#wrapper .piece h3", :text => "Text" + assert_select "#wrapper .piece h3", :text => "Another" + + response.should have_tag("#wrapper .piece h3", :text => "Text") + response.should have_tag("#wrapper .piece h3", :text => "Another") + end +end + +describe 'selecting in HTML that contains a mock with null_object' do + include ActionController::Assertions::SelectorAssertions + module HTML + class Document + def initialize_with_strict_error_checking(text, strict=false, xml=false) + initialize_without_strict_error_checking(text, true, xml) + end + alias_method :initialize_without_strict_error_checking, :initialize + alias_method :initialize, :initialize_with_strict_error_checking + end + end + + describe 'modified HTML::Document' do + it 'should raise error on valid HTML even though false is specified' do + lambda {HTML::Document.new("<b>#<Spec::Mocks::Mock:0x267b4f0></b>", false, false)}.should raise_error + end + end + + it 'should not print errors from assert_select' do + mock = mock("Dog", :null_object => true) + html = "<b>#{mock.colour}</b>" + lambda {html.should have_tag('b')}.should_not raise_error + end +end + +# describe "An rjs call to :visual_effect, a 'should have_rjs' spec with", +# :type => :view do +# +# before do +# render 'rjs_spec/visual_effect' +# end +# +# it "should pass with the correct element name" do +# response.should have_rjs(:effect, :fade, 'mydiv') +# end +# +# it "should fail the wrong element name" do +# lambda { +# response.should have_rjs(:effect, :fade, 'wrongname') +# }.should raise_error(SpecFailed) +# end +# +# it "should fail with the correct element but the wrong command" do +# lambda { +# response.should have_rjs(:effect, :puff, 'mydiv') +# }.should raise_error(SpecFailed) +# end +# +# end +# +# describe "An rjs call to :visual_effect for a toggle, a 'should have_rjs' spec with", +# :type => :view do +# +# before do +# render 'rjs_spec/visual_toggle_effect' +# end +# +# it "should pass with the correct element name" do +# response.should have_rjs(:effect, :toggle_blind, 'mydiv') +# end +# +# it "should fail with the wrong element name" do +# lambda { +# response.should have_rjs(:effect, :toggle_blind, 'wrongname') +# }.should raise_error(SpecFailed) +# end +# +# it "should fail the correct element but the wrong command" do +# lambda { +# response.should have_rjs(:effect, :puff, 'mydiv') +# }.should raise_error(SpecFailed) +# end +# +# end
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/errors_on_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/errors_on_spec.rb new file mode 100644 index 000000000..bcb702aaf --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/errors_on_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe "error_on" do + it "should provide a description including the name of what the error is on" do + have(1).error_on(:whatever).description.should == "have 1 error on :whatever" + end + + it "should provide a failure message including the number actually given" do + lambda { + [].should have(1).error_on(:whatever) + }.should fail_with("expected 1 error on :whatever, got 0") + end +end + +describe "errors_on" do + it "should provide a description including the name of what the error is on" do + have(2).errors_on(:whatever).description.should == "have 2 errors on :whatever" + end + + it "should provide a failure message including the number actually given" do + lambda { + [1].should have(3).errors_on(:whatever) + }.should fail_with("expected 3 errors on :whatever, got 1") + end +end + +describe "have something other than error_on or errors_on" do + it "has a standard rspec failure message" do + lambda { + [1,2,3].should have(2).elements + }.should fail_with("expected 2 elements, got 3") + end + + it "has a standard rspec description" do + have(2).elements.description.should == "have 2 elements" + end +end
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/have_text_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/have_text_spec.rb new file mode 100644 index 000000000..c6de80613 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/have_text_spec.rb @@ -0,0 +1,69 @@ +require 'spec_helper' + +describe "have_text" do + + it "should have a helpful description" do + matcher = have_text("foo bar") + matcher.description.should == 'have text "foo bar"' + end + + describe "where target is a Regexp" do + it 'should should match submitted text using a regexp' do + matcher = have_text(/fo*/) + matcher.matches?('foo').should be_true + matcher.matches?('bar').should be_nil + end + end + + describe "where target is a String" do + it 'should match submitted text using a string' do + matcher = have_text('foo') + matcher.matches?('foo').should be_true + matcher.matches?('foo bar').should be_false + end + end + +end + +describe "have_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 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 + + it "should pass using should_not with incorrect text" do + post 'text_action' + response.should_not have_text("the accordian guy") + end + end + end +end + diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/include_text_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/include_text_spec.rb new file mode 100644 index 000000000..1df4b3833 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/include_text_spec.rb @@ -0,0 +1,62 @@ +require 'spec_helper' + +describe "include_text" do + + it "should have a helpful description" do + matcher = include_text("foo bar") + matcher.description.should == 'include text "foo bar"' + end + + it 'should match if the text is contained' do + matcher = include_text('big piece') + matcher.matches?('I am a big piece of text').should be_true + end + + it 'should not match if text is not contained' do + matcher = include_text('foo bar') + matcher.matches?('hello world').should be_false + 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 incorrect text" do + post 'text_action' + lambda { + response.should include_text("the accordian guy") + }.should fail_with("expected to find \"the accordian guy\" in \"this is the text for this action\"") + end + + it "should pass using should_not with incorrect text" do + post 'text_action' + response.should_not include_text("the accordian guy") + end + + it "should fail when a template is rendered" do + get 'some_action' + lambda { + response.should include_text("this is the text for this action") + }.should fail_with(/expected to find \"this is the text for this action\"/) + end + end + end +end + diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/redirect_to_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/redirect_to_spec.rb new file mode 100644 index 000000000..6588cd8b5 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/redirect_to_spec.rb @@ -0,0 +1,253 @@ +require 'spec_helper' + +[:response, :controller].each do |subject_method| + ['isolation','integration'].each do |mode| + describe "redirect_to behaviour", :type => :controller do + if mode == 'integration' + integrate_views + end + controller_name :redirect_spec + + subject { send(subject_method) } + + it "redirected to another action" do + get 'action_with_redirect_to_somewhere' + should redirect_to(:action => 'somewhere') + end + + it "redirected to another controller and action" do + get 'action_with_redirect_to_other_somewhere' + should redirect_to(:controller => 'render_spec', :action => 'text_action') + end + + it "redirected to another action (with 'and return')" do + get 'action_with_redirect_to_somewhere_and_return' + 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' + should redirect_to(:action => 'somewhere') + end + + it "redirected to correct path with leading /" do + get 'action_with_redirect_to_somewhere' + should redirect_to('/redirect_spec/somewhere') + end + + it "redirected to correct path without leading /" do + get 'action_with_redirect_to_somewhere' + should redirect_to('redirect_spec/somewhere') + end + + it "redirected to correct internal URL" do + get 'action_with_redirect_to_somewhere' + should redirect_to("http://test.host/redirect_spec/somewhere") + end + + it "redirected to correct external URL" do + get 'action_with_redirect_to_rspec_site' + should redirect_to("http://rspec.rubyforge.org") + end + + it "redirected :back" do + request.env['HTTP_REFERER'] = "http://test.host/previous/page" + get 'action_with_redirect_back' + should redirect_to(:back) + end + + it "redirected :back and should redirect_to URL matches" do + request.env['HTTP_REFERER'] = "http://test.host/previous/page" + get 'action_with_redirect_back' + should redirect_to("http://test.host/previous/page") + end + + it "redirected from within a respond_to block" do + get 'action_with_redirect_in_respond_to' + should redirect_to('redirect_spec/somewhere') + end + + params_as_hash = {:action => "somewhere", :id => 1111, :param1 => "value1", :param2 => "value2"} + + it "redirected to an internal URL containing a query string" do + get "action_with_redirect_which_creates_query_string" + should redirect_to(params_as_hash) + end + + it "redirected to an internal URL containing a query string, one way it might be generated" do + get "action_with_redirect_with_query_string_order1" + should redirect_to(params_as_hash) + end + + it "redirected to an internal URL containing a query string, another way it might be generated" do + get "action_with_redirect_with_query_string_order2" + should redirect_to(params_as_hash) + end + + it "redirected to an internal URL which is unroutable but matched via a string" do + get "action_with_redirect_to_unroutable_url_inside_app" + should redirect_to("http://test.host/nonexistant/none") + end + + it "redirected to a URL with a specific status code" do + get "action_with_redirect_to_somewhere_with_status" + should redirect_to(:action => 'somewhere').with(:status => 301) + end + + it "redirected to a URL with a specific status code (using names)" do + get "action_with_redirect_to_somewhere_with_status" + should redirect_to(:action => 'somewhere').with(:status => :moved_permanently) + end + + end + + + describe "redirect_to with a controller spec in #{mode} mode and a custom request.host", :type => :controller do + if mode == 'integration' + integrate_views + end + controller_name :redirect_spec + + subject { send(subject_method) } + + before do + request.host = "some.custom.host" + end + + it "should pass when redirected to another action" do + get 'action_with_redirect_to_somewhere' + should redirect_to(:action => 'somewhere') + end + end + + describe "Given a controller spec in #{mode} mode", :type => :controller do + if mode == 'integration' + integrate_views + end + controller_name :redirect_spec + + subject { send(subject_method) } + + it "an action that redirects should not result in an error if no should redirect_to expectation is called" do + get 'action_with_redirect_to_somewhere' + end + + it "an action that redirects should not result in an error if should_not redirect_to expectation was called, but not to that action" do + get 'action_with_redirect_to_somewhere' + should_not redirect_to(:action => 'another_destination') + end + + it "an action that redirects should result in an error if should_not redirect_to expectation was called to that action" do + get 'action_with_redirect_to_somewhere' + lambda { + should_not redirect_to(:action => 'somewhere') + }.should fail_with("expected not to be redirected to {:action=>\"somewhere\"}, but was") + end + + it "an action that does not redirects should not result in an error if should_not redirect_to expectation was called" do + get 'action_with_no_redirect' + should_not redirect_to(:action => 'any_destination') + end + + + end + + describe "Given a controller spec in #{mode} mode, should redirect_to should fail when", :type => :controller do + if mode == 'integration' + integrate_views + end + controller_name :redirect_spec + + subject { send(subject_method) } + + it "redirected to wrong action" do + get 'action_with_redirect_to_somewhere' + lambda { + should redirect_to(:action => 'somewhere_else') + }.should fail_with("expected redirect to {:action=>\"somewhere_else\"}, got redirect to \"http://test.host/redirect_spec/somewhere\"") + end + + it "redirected with wrong status code" do + get 'action_with_redirect_to_somewhere_with_status' + lambda { + should redirect_to(:action => 'somewhere').with(:status => 302) + }.should fail_with("expected redirect to {:action=>\"somewhere\"} with status 302 Found, got 301 Moved Permanently") + end + + it "redirected with wrong status code (using names)" do + get 'action_with_redirect_to_somewhere_with_status' + lambda { + should redirect_to(:action => 'somewhere').with(:status => :found) + }.should fail_with("expected redirect to {:action=>\"somewhere\"} with status 302 Found, got 301 Moved Permanently") + end + + it "redirected to incorrect path with leading /" do + get 'action_with_redirect_to_somewhere' + lambda { + should redirect_to('/redirect_spec/somewhere_else') + }.should fail_with('expected redirect to "/redirect_spec/somewhere_else", got redirect to "http://test.host/redirect_spec/somewhere"') + end + + it "redirected to incorrect path without leading /" do + get 'action_with_redirect_to_somewhere' + lambda { + should redirect_to('redirect_spec/somewhere_else') + }.should fail_with('expected redirect to "redirect_spec/somewhere_else", got redirect to "http://test.host/redirect_spec/somewhere"') + end + + it "redirected to incorrect internal URL (based on the action)" do + get 'action_with_redirect_to_somewhere' + lambda { + should redirect_to("http://test.host/redirect_spec/somewhere_else") + }.should fail_with('expected redirect to "http://test.host/redirect_spec/somewhere_else", got redirect to "http://test.host/redirect_spec/somewhere"') + end + + it "redirected to wrong external URL" do + get 'action_with_redirect_to_rspec_site' + lambda { + should redirect_to("http://test.unit.rubyforge.org") + }.should fail_with('expected redirect to "http://test.unit.rubyforge.org", got redirect to "http://rspec.rubyforge.org"') + end + + it "redirected to incorrect internal URL (based on the directory path)" do + get 'action_with_redirect_to_somewhere' + lambda { + should redirect_to("http://test.host/non_existent_controller/somewhere") + }.should fail_with('expected redirect to "http://test.host/non_existent_controller/somewhere", got redirect to "http://test.host/redirect_spec/somewhere"') + end + + it "expected redirect :back, but redirected to a new URL" do + get 'action_with_no_redirect' + lambda { + should redirect_to(:back) + }.should fail_with('expected redirect to :back, got no redirect') + end + + it "no redirect at all" do + get 'action_with_no_redirect' + lambda { + should redirect_to(:action => 'nowhere') + }.should fail_with("expected redirect to {:action=>\"nowhere\"}, got no redirect") + end + + it "redirected to an internal URL which is unroutable and matched via a hash" do + get "action_with_redirect_to_unroutable_url_inside_app" + route = {:controller => "nonexistant", :action => "none"} + lambda { + should redirect_to(route) + }.should raise_error(ActionController::RoutingError, /(no route found to match|No route matches) \"\/nonexistant\/none\" with \{.*\}/) + end + + it "provides a description" do + redirect_to("foo/bar").description.should == %q|redirect to "foo/bar"| + end + + it "redirects to action with http method restriction" do + post 'action_to_redirect_to_action_with_method_restriction' + should redirect_to(:action => 'action_with_method_restriction') + end + + end + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/render_template_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/render_template_spec.rb new file mode 100644 index 000000000..68c995574 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/render_template_spec.rb @@ -0,0 +1,208 @@ +require 'spec_helper' + +[:response, :controller].each do |subject_method| + ['isolation','integration'].each do |mode| + describe "#{subject_method}.should render_template (in #{mode} mode)", + :type => :controller do + controller_name :render_spec + if mode == 'integration' + integrate_views + end + + subject { send(subject_method) } + + it "matches an action (using a string)" do + post 'some_action' + should render_template('some_action') + end + + it "does not match an action that is a truncated version of the actual action" do + post 'some_action' + should_not render_template('some_actio') + end + + if ::Rails::VERSION::STRING >= '2.3' + it "matches an action with specified extenstions (implicit format)" do + post 'some_action' + should render_template('some_action.html.erb') + end + + it "matches an action with specified extenstions (explicit format)" do + post 'some_action', :format => 'js' + should render_template('some_action.js.rjs') + end + end + + it "matches an action (using a symbol)" do + post 'some_action' + should render_template(:some_action) + end + + it "matches an action on a specific controller" do + post 'some_action' + should render_template('render_spec/some_action') + end + + it "matches an action on a non-default specific controller" do + post 'action_which_renders_template_from_other_controller' + should render_template('controller_spec/action_with_template') + end + + it "matches an rjs template" do + xhr :post, 'some_action' + should render_template('render_spec/some_action') + end + + it "matches a partial template (simple path)" do + get 'action_with_partial' + should render_template("_a_partial") + end + + it "matches a partial template (complex path)" do + get 'action_with_partial' + should render_template("render_spec/_a_partial") + end + + it "fails when the wrong template is rendered" do + post 'some_action' + lambda do + should render_template('non_existent_template') + end.should fail_with(/expected \"non_existent_template\", got \"render_spec\/some_action(\.html\.erb)?\"/) + end + + it "fails when redirected" do + post :action_with_redirect + lambda do + should render_template(:some_action) + end.should fail_with(/expected \"some_action\", got redirected to \"http:\/\/test.host\/render_spec\/some_action\"/) + end + + it "fails when template is associated with a different controller but controller is not specified" do + post 'action_which_renders_template_from_other_controller' + lambda do + should render_template('action_with_template') + end.should fail_with(/expected \"action_with_template\", got \"controller_spec\/action_with_template(\.html\.erb)?\"/) + end + + it "fails with incorrect full path when template is associated with a different controller" do + post 'action_which_renders_template_from_other_controller' + lambda do + should render_template('render_spec/action_with_template') + end.should fail_with(/expected \"render_spec\/action_with_template\", got \"controller_spec\/action_with_template(\.html\.erb)?\"/) + end + + it "fails on the wrong extension" do + get 'some_action' + lambda { + should render_template('render_spec/some_action.js.rjs') + }.should fail_with(/expected \"render_spec\/some_action\.js\.rjs\", got \"render_spec\/some_action(\.html\.erb)?\"/) + end + + it "faild when TEXT is rendered" do + post 'text_action' + lambda do + should render_template('some_action') + end.should fail_with(/expected \"some_action\", got (nil|\"\")/) + end + + describe "with an alternate layout" do + it "says it rendered the action's layout" do + pending("record rendering of layouts") do + get 'action_with_alternate_layout' + should render_template('layouts/simple') + end + end + end + + it "provides a description" do + render_template("foo/bar").description.should == %q|render template "foo/bar"| + end + end + + describe "#{subject_method}.should_not render_template (in #{mode} mode)", + :type => :controller do + controller_name :render_spec + if mode == 'integration' + integrate_views + end + + subject { send(subject_method) } + + it "passes when the action renders nothing" do + post 'action_that_renders_nothing' + should_not render_template('action_that_renders_nothing') + end + + it "passes when the action renders nothing (symbol)" do + post 'action_that_renders_nothing' + should_not render_template(:action_that_renders_nothing) + end + + it "passes when the action does not render the template" do + post 'some_action' + should_not render_template('some_other_template') + end + + it "passes when the action does not render the template (symbol)" do + post 'some_action' + should_not render_template(:some_other_template) + end + + it "passes when the action does not render the template (named with controller)" do + post 'some_action' + should_not render_template('render_spec/some_other_template') + end + + it "passes when the action renders the template with a different controller" do + post 'action_which_renders_template_from_other_controller' + should_not render_template('action_with_template') + end + + it "passes when the action renders the template (named with controller) with a different controller" do + post 'action_which_renders_template_from_other_controller' + should_not render_template('render_spec/action_with_template') + end + + it "passes when TEXT is rendered" do + post 'text_action' + should_not render_template('some_action') + end + + it "fails when the action renders the template" do + post 'some_action' + lambda do + should_not render_template('some_action') + end.should fail_with("expected not to render \"some_action\", but did") + end + + it "fails when the action renders the template (symbol)" do + post 'some_action' + lambda do + should_not render_template(:some_action) + end.should fail_with("expected not to render \"some_action\", but did") + end + + it "fails when the action renders the template (named with controller)" do + post 'some_action' + lambda do + should_not render_template('render_spec/some_action') + end.should fail_with("expected not to render \"render_spec/some_action\", but did") + end + + it "fails when the action renders the partial" do + post 'action_with_partial' + lambda do + should_not render_template('_a_partial') + end.should fail_with("expected not to render \"_a_partial\", but did") + end + + it "fails when the action renders the partial (named with controller)" do + post 'action_with_partial' + lambda do + 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 +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/should_change_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/should_change_spec.rb new file mode 100644 index 000000000..304335270 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/matchers/should_change_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "should change" do + describe "handling association proxies" do + it "should match expected collection with proxied collection" do + person = Person.create!(:name => 'David') + koala = person.animals.create!(:name => 'Koala') + zebra = person.animals.create!(:name => 'Zebra') + + lambda { + person.animals.delete(koala) + }.should change{person.animals}.to([zebra]) + end + end +end
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/mocks/ar_classes.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/mocks/ar_classes.rb new file mode 100644 index 000000000..05213029a --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/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/gems/rspec-rails-1.3.3/spec/spec/rails/mocks/mock_model_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/mocks/mock_model_spec.rb new file mode 100644 index 000000000..0abcd08c1 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/mocks/mock_model_spec.rb @@ -0,0 +1,112 @@ +require 'spec_helper' +require File.dirname(__FILE__) + '/ar_classes' + +describe "mock_model" do + describe "responding to interrogation" do + before(:each) do + @model = mock_model(SubMockableModel) + end + it "should say it is_a? if it is" do + @model.is_a?(SubMockableModel).should be(true) + end + it "should say it is_a? if it's ancestor is" do + @model.is_a?(MockableModel).should be(true) + end + it "should say it is kind_of? if it is" do + @model.kind_of?(SubMockableModel).should be(true) + end + it "should say it is kind_of? if it's ancestor is" do + @model.kind_of?(MockableModel).should be(true) + end + it "should say it is instance_of? if it is" do + @model.instance_of?(SubMockableModel).should be(true) + end + it "should not say it instance_of? if it isn't, even if it's ancestor is" do + @model.instance_of?(MockableModel).should be(false) + end + it "should say it is not destroyed" do + @model.destroyed?(SubMockableModel).should be(false) + end + it "should say it is not marked_for_destruction" do + @model.marked_for_destruction?.should be(false) + end + end + + describe "with params" do + it "should not mutate its parameters" do + params = {:a => 'b'} + model = mock_model(MockableModel, params) + params.should == {:a => 'b'} + end + end + + describe "with #id stubbed", :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 + it "should return string of id value for to_param" do + @model.to_param.should == "1" + end + end + + describe "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 + + describe "with :null_object => true", :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 "#as_null_object", :type => :view do + before(:each) do + @model = mock_model(MockableModel, :mocked_method => "mocked").as_null_object + 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 "#as_new_record" do + it "should say it is a new record" do + mock_model(MockableModel).as_new_record.should be_new_record + end + + it "should have a nil id" do + mock_model(MockableModel).as_new_record.id.should be(nil) + end + + it "should return nil for #to_param" do + mock_model(MockableModel).as_new_record.to_param.should be(nil) + end + end +end + + diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/mocks/stub_model_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/mocks/stub_model_spec.rb new file mode 100644 index 000000000..09b5a21ec --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/mocks/stub_model_spec.rb @@ -0,0 +1,80 @@ +require '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 + model = stub_model(MockableModel, :changed => true, :attributes_with_quotes => {'this' => 'that'}) + model.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 + + describe "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 "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 +end + + diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/sample_modified_fixture.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/sample_modified_fixture.rb new file mode 100644 index 000000000..55269248c --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/sample_modified_fixture.rb @@ -0,0 +1,8 @@ +require '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/gems/rspec-rails-1.3.3/spec/spec/rails/sample_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/sample_spec.rb new file mode 100644 index 000000000..a749cb74e --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/sample_spec.rb @@ -0,0 +1,8 @@ +require 'spec_helper' + +describe "A sample spec", :type => :model do + fixtures :animals + it "should pass" do + animals(:pig).name.should == "Pig" + end +end
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/spec_spec.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/spec_spec.rb new file mode 100644 index 000000000..1776bac3a --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec/rails/spec_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe "script/spec file" do + it "should run a spec" do + dir = File.dirname(__FILE__) + output = `#{RAILS_ROOT}/script/spec #{dir}/sample_spec.rb` + unless $?.exitstatus == 0 + flunk "command 'script/spec spec/sample_spec' failed\n#{output}" + end + end +end
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/spec_helper.rb b/vendor/gems/rspec-rails-1.3.3/spec/spec_helper.rb new file mode 100644 index 000000000..b450d8a7d --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/spec_helper.rb @@ -0,0 +1,78 @@ +$LOAD_PATH.unshift '../rspec/lib' +$LOAD_PATH.unshift '../../../' +$LOAD_PATH.unshift 'spec/resources/controllers' +$LOAD_PATH.unshift 'spec/resources/helpers' + +require '../../../spec/spec_helper' + +require 'spec/resources/controllers/application' +require 'spec/resources/controllers/render_spec_controller' +require 'spec/resources/controllers/controller_spec_controller' +require 'spec/resources/controllers/rjs_spec_controller' +require 'spec/resources/controllers/redirect_spec_controller' +require 'spec/resources/controllers/action_view_base_spec_controller' +require 'spec/resources/helpers/addition_helper' +require 'spec/resources/helpers/explicit_helper' +require 'spec/resources/helpers/more_explicit_helper' +require 'spec/resources/helpers/view_spec_helper' +require 'spec/resources/helpers/plugin_application_helper' +require 'spec/resources/models/animal' +require 'spec/resources/models/person' +require 'spec/resources/models/thing' + +unless ActionController::Routing.controller_paths.include?('spec/resources/controllers') + ActionController::Routing.instance_eval {@possible_controllers = nil} + ActionController::Routing.controller_paths << 'spec/resources/controllers' +end + +module Spec + module Rails + module Example + class ViewExampleGroupController + prepend_view_path 'spec/resources/views' + end + end + end +end + +def fail() + raise_error(Spec::Expectations::ExpectationNotMetError) +end + +def fail_with(message) + raise_error(Spec::Expectations::ExpectationNotMetError,message) +end + +class Proc + def should_pass + lambda { self.call }.should_not raise_error + end +end + +ActionController::Routing::Routes.draw do |map| + map.connect 'action_with_method_restriction', :controller => 'redirect_spec', :action => 'action_with_method_restriction', :conditions => { :method => :get } + map.connect 'action_to_redirect_to_action_with_method_restriction', :controller => 'redirect_spec', :action => 'action_to_redirect_to_action_with_method_restriction' + + map.resources :rspec_on_rails_specs + map.custom_route 'custom_route', :controller => 'custom_route_spec', :action => 'custom_route' + map.connect ':controller/:action/:id' +end + +module HelperMethods + def method_in_module_included_in_configuration + end +end + +module HelperMacros + def accesses_configured_helper_methods + it "has access to methods in modules included in configuration" do + method_in_module_included_in_configuration + end + end +end + +Spec::Runner.configure do |config| + config.include HelperMethods + config.extend HelperMacros +end + |