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,54 @@
require File.dirname(__FILE__) + '/../../spec_helper'
module ActionController
describe "Rescue", "#rescue_action in default mode" do
before(:each) do
@fixture = Object.new
@fixture.extend ActionController::Rescue
class << @fixture
public :rescue_action
end
end
it "should raise the passed in exception so examples fail fast" do
proc {@fixture.rescue_action(RuntimeError.new("Foobar"))}.should raise_error(RuntimeError, "Foobar")
end
end
class RescueOverriddenController < ActionController::Base
def rescue_action(error)
"successfully overridden"
end
end
describe "Rescue", "#rescue_action, when overridden" do
before(:each) do
@fixture = RescueOverriddenController.new
end
it "should do whatever the overridden method does" do
@fixture.rescue_action(RuntimeError.new("Foobar")).should == "successfully overridden"
end
end
class SearchController < ActionController::Base
end
describe "Rescue", "#rescue_action when told to use rails error handling" do
before(:each) do
@controller = SearchController.new
@controller.use_rails_error_handling!
class << @controller
public :rescue_action
end
end
it "should use Rails exception handling" do
exception = RuntimeError.new("The Error")
exception.stub!(:backtrace).and_return(caller)
@controller.should_receive(:rescue_action_locally).with(exception)
@controller.rescue_action(exception)
end
end
end

View file

@ -0,0 +1,48 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require 'spec/mocks/errors'
describe ActionView::Base, "with RSpec extensions:", :type => :view do
describe "expect_render" do
it "should not raise when render has been received" do
template.expect_render(:partial => "name")
template.render :partial => "name"
end
it "should raise when render has NOT been received" do
template.expect_render(:partial => "name")
lambda {
template.verify_rendered
}.should raise_error
end
it "should return something (like a normal mock)" do
template.expect_render(:partial => "name").and_return("Little Johnny")
result = template.render :partial => "name"
result.should == "Little Johnny"
end
end
describe "stub_render" do
it "should not raise when stubbing and render has been received" do
template.stub_render(:partial => "name")
template.render :partial => "name"
end
it "should not raise when stubbing and render has NOT been received" do
template.stub_render(:partial => "name")
end
it "should not raise when stubbing and render has been received with different options" do
template.stub_render(:partial => "name")
template.render :partial => "view_spec/spacer"
end
it "should not raise when stubbing and expecting and render has been received" do
template.stub_render(:partial => "name")
template.expect_render(:partial => "name")
template.render(:partial => "name")
end
end
end

View file

@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../../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