Added Rspec and Webrat plugins and started porting Selenium on Rails tests to Rspec Plain Text Stories driving Webrat driving Selenium.

This commit is contained in:
Luke Melia 2008-06-18 02:57:57 -04:00
parent 0600756bbf
commit 0f7d6f7a1d
602 changed files with 47788 additions and 29 deletions

View file

@ -0,0 +1,2 @@
class ActionViewBaseSpecController < ActionController::Base
end

View file

@ -0,0 +1,68 @@
class ControllerSpecController < ActionController::Base
if ['edge','2.0.0'].include?(ENV['RSPEC_RAILS_VERSION'])
set_view_path [File.join(File.dirname(__FILE__), "..", "views")]
else
set_view_path File.join(File.dirname(__FILE__), "..", "views")
end
def some_action
render :template => "template/that/does/not/actually/exist"
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_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
assigns['direct_assigns_key'] = :direct_assigns_key_value
@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
end

View file

@ -0,0 +1,59 @@
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&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_order2
redirect_to "http://test.host/redirect_spec/somewhere/1111?param2=value2&param1=value1"
end
def action_with_redirect_to_unroutable_url_inside_app
redirect_to :controller => "nonexistant", :action => "none"
end
end

View file

@ -0,0 +1,26 @@
class RenderSpecController < ApplicationController
set_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_partial
render :partial => "a_partial"
end
def action_that_renders_nothing
render :nothing => true
end
end

View file

@ -0,0 +1,58 @@
class RjsSpecController < ApplicationController
set_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