Organizando plugins e gems.
This commit is contained in:
35
vendor/gems/thoughtbot-shoulda-2.10.1/test/matchers/controller/assign_to_matcher_test.rb
vendored
Normal file
35
vendor/gems/thoughtbot-shoulda-2.10.1/test/matchers/controller/assign_to_matcher_test.rb
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
||||
|
||||
class AssignToMatcherTest < Test::Unit::TestCase # :nodoc:
|
||||
|
||||
context "a controller that assigns to an instance variable" do
|
||||
setup do
|
||||
@controller = build_response { @var = 'value' }
|
||||
end
|
||||
|
||||
should "accept assigning to that variable" do
|
||||
assert_accepts assign_to(:var), @controller
|
||||
end
|
||||
|
||||
should "accept assigning to that variable with the correct class" do
|
||||
assert_accepts assign_to(:var).with_kind_of(String), @controller
|
||||
end
|
||||
|
||||
should "reject assigning to that variable with another class" do
|
||||
assert_rejects assign_to(:var).with_kind_of(Fixnum), @controller
|
||||
end
|
||||
|
||||
should "accept assigning the correct value to that variable" do
|
||||
assert_accepts assign_to(:var).with('value'), @controller
|
||||
end
|
||||
|
||||
should "reject assigning another value to that variable" do
|
||||
assert_rejects assign_to(:var).with('other'), @controller
|
||||
end
|
||||
|
||||
should "reject assigning to another variable" do
|
||||
assert_rejects assign_to(:other), @controller
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
32
vendor/gems/thoughtbot-shoulda-2.10.1/test/matchers/controller/filter_param_matcher_test.rb
vendored
Normal file
32
vendor/gems/thoughtbot-shoulda-2.10.1/test/matchers/controller/filter_param_matcher_test.rb
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
||||
|
||||
class FilterParamMatcherTest < Test::Unit::TestCase # :nodoc:
|
||||
|
||||
context "a controller that filters no parameters" do
|
||||
setup do
|
||||
@controller = define_controller(:examples).new
|
||||
end
|
||||
|
||||
should "reject filtering any parameter" do
|
||||
assert_rejects filter_param(:any), @controller
|
||||
end
|
||||
end
|
||||
|
||||
context "a controller that filters a parameter" do
|
||||
setup do
|
||||
@controller = define_controller :examples do
|
||||
filter_parameter_logging :password
|
||||
end.new
|
||||
end
|
||||
|
||||
should "accept filtering that parameter" do
|
||||
assert_accepts filter_param(:password), @controller
|
||||
end
|
||||
|
||||
should "reject filtering another parameter" do
|
||||
assert_rejects filter_param(:other), @controller
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
||||
|
||||
class RenderWithLayoutMatcherTest < Test::Unit::TestCase # :nodoc:
|
||||
|
||||
context "a controller that renders with a layout" do
|
||||
setup do
|
||||
@controller = build_response { render :layout => 'wide' }
|
||||
end
|
||||
|
||||
should "accept rendering with any layout" do
|
||||
assert_accepts render_with_layout, @controller
|
||||
end
|
||||
|
||||
should "accept rendering with that layout" do
|
||||
assert_accepts render_with_layout(:wide), @controller
|
||||
end
|
||||
|
||||
should "reject rendering with another layout" do
|
||||
assert_rejects render_with_layout(:other), @controller
|
||||
end
|
||||
end
|
||||
|
||||
context "a controller that renders without a layout" do
|
||||
setup do
|
||||
@controller = build_response { render :layout => false }
|
||||
end
|
||||
|
||||
should "reject rendering with a layout" do
|
||||
assert_rejects render_with_layout, @controller
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,27 @@
|
||||
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
||||
|
||||
class RespondWithContentTypeMatcherTest < Test::Unit::TestCase # :nodoc:
|
||||
|
||||
context "a controller responding with content type :xml" do
|
||||
setup do
|
||||
@controller = build_response { render :xml => { :user => "thoughtbot" }.to_xml }
|
||||
end
|
||||
|
||||
should "accept responding with content type :xml" do
|
||||
assert_accepts respond_with_content_type(:xml), @controller
|
||||
end
|
||||
|
||||
should "accept responding with content type 'application/xml'" do
|
||||
assert_accepts respond_with_content_type('application/xml'), @controller
|
||||
end
|
||||
|
||||
should "accept responding with content type /xml/" do
|
||||
assert_accepts respond_with_content_type(/xml/), @controller
|
||||
end
|
||||
|
||||
should "reject responding with another content type" do
|
||||
assert_rejects respond_with_content_type(:json), @controller
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
106
vendor/gems/thoughtbot-shoulda-2.10.1/test/matchers/controller/respond_with_matcher_test.rb
vendored
Normal file
106
vendor/gems/thoughtbot-shoulda-2.10.1/test/matchers/controller/respond_with_matcher_test.rb
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
||||
|
||||
class RespondWithMatcherTest < Test::Unit::TestCase # :nodoc:
|
||||
|
||||
context "a controller responding with success" do
|
||||
setup do
|
||||
@controller = build_response { render :text => "text", :status => 200 }
|
||||
end
|
||||
|
||||
should "accept responding with 200" do
|
||||
assert_accepts respond_with(200), @controller
|
||||
end
|
||||
|
||||
should "accept responding with :success" do
|
||||
assert_accepts respond_with(:success), @controller
|
||||
end
|
||||
|
||||
should "reject responding with another status" do
|
||||
assert_rejects respond_with(:error), @controller
|
||||
end
|
||||
end
|
||||
|
||||
context "a controller responding with redirect" do
|
||||
setup do
|
||||
@controller = build_response { render :text => "text", :status => 301 }
|
||||
end
|
||||
|
||||
should "accept responding with 301" do
|
||||
assert_accepts respond_with(301), @controller
|
||||
end
|
||||
|
||||
should "accept responding with :redirect" do
|
||||
assert_accepts respond_with(:redirect), @controller
|
||||
end
|
||||
|
||||
should "reject responding with another status" do
|
||||
assert_rejects respond_with(:error), @controller
|
||||
end
|
||||
end
|
||||
|
||||
context "a controller responding with missing" do
|
||||
setup do
|
||||
@controller = build_response { render :text => "text", :status => 404 }
|
||||
end
|
||||
|
||||
should "accept responding with 404" do
|
||||
assert_accepts respond_with(404), @controller
|
||||
end
|
||||
|
||||
should "accept responding with :missing" do
|
||||
assert_accepts respond_with(:missing), @controller
|
||||
end
|
||||
|
||||
should "reject responding with another status" do
|
||||
assert_rejects respond_with(:success), @controller
|
||||
end
|
||||
end
|
||||
|
||||
context "a controller responding with error" do
|
||||
setup do
|
||||
@controller = build_response { render :text => "text", :status => 500 }
|
||||
end
|
||||
|
||||
should "accept responding with 500" do
|
||||
assert_accepts respond_with(500), @controller
|
||||
end
|
||||
|
||||
should "accept responding with :error" do
|
||||
assert_accepts respond_with(:error), @controller
|
||||
end
|
||||
|
||||
should "reject responding with another status" do
|
||||
assert_rejects respond_with(:success), @controller
|
||||
end
|
||||
end
|
||||
|
||||
context "a controller responding with not implemented" do
|
||||
setup do
|
||||
@controller = build_response { render :text => "text", :status => 501 }
|
||||
end
|
||||
|
||||
should "accept responding with 501" do
|
||||
assert_accepts respond_with(501), @controller
|
||||
end
|
||||
|
||||
should "accept responding with :not_implemented" do
|
||||
assert_accepts respond_with(:not_implemented), @controller
|
||||
end
|
||||
|
||||
should "reject responding with another status" do
|
||||
assert_rejects respond_with(:success), @controller
|
||||
end
|
||||
end
|
||||
|
||||
context "a controller raising an error" do
|
||||
setup do
|
||||
@controller = build_response { raise RailsError }
|
||||
end
|
||||
|
||||
should "reject responding with any status" do
|
||||
assert_rejects respond_with(:success), @controller
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
58
vendor/gems/thoughtbot-shoulda-2.10.1/test/matchers/controller/route_matcher_test.rb
vendored
Normal file
58
vendor/gems/thoughtbot-shoulda-2.10.1/test/matchers/controller/route_matcher_test.rb
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
||||
|
||||
class RouteToMatcherTest < Test::Unit::TestCase # :nodoc:
|
||||
|
||||
context "given a controller with a defined route" do
|
||||
setup do
|
||||
@controller = define_controller('Examples').new
|
||||
define_routes do |map|
|
||||
map.connect 'examples/:id', :controller => 'examples',
|
||||
:action => 'example'
|
||||
end
|
||||
end
|
||||
|
||||
should "accept routing the correct path to the correct parameters" do
|
||||
assert_accepts route(:get, '/examples/1').
|
||||
to(:action => 'example', :id => '1'),
|
||||
@controller
|
||||
end
|
||||
|
||||
should "accept a symbol controller" do
|
||||
assert_accepts route(:get, '/examples/1').
|
||||
to(:controller => :examples,
|
||||
:action => 'example',
|
||||
:id => '1'),
|
||||
self
|
||||
end
|
||||
|
||||
should "accept a symbol action" do
|
||||
assert_accepts route(:get, '/examples/1').
|
||||
to(:action => :example, :id => '1'),
|
||||
@controller
|
||||
end
|
||||
|
||||
should "accept a non-string parameter" do
|
||||
assert_accepts route(:get, '/examples/1').
|
||||
to(:action => 'example', :id => 1),
|
||||
@controller
|
||||
end
|
||||
|
||||
should "reject an undefined route" do
|
||||
assert_rejects route(:get, '/bad_route').to(:var => 'value'), @controller
|
||||
end
|
||||
|
||||
should "reject a route for another controller" do
|
||||
@other = define_controller('Other').new
|
||||
assert_rejects route(:get, '/examples/1').
|
||||
to(:action => 'example', :id => '1'),
|
||||
@other
|
||||
end
|
||||
|
||||
should "reject a route for different parameters" do
|
||||
assert_rejects route(:get, '/examples/1').
|
||||
to(:action => 'other', :id => '1'),
|
||||
@controller
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
31
vendor/gems/thoughtbot-shoulda-2.10.1/test/matchers/controller/set_session_matcher_test.rb
vendored
Normal file
31
vendor/gems/thoughtbot-shoulda-2.10.1/test/matchers/controller/set_session_matcher_test.rb
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
||||
|
||||
class SetSessionMatcherTest < Test::Unit::TestCase # :nodoc:
|
||||
|
||||
context "a controller that sets a session variable" do
|
||||
setup do
|
||||
@controller = build_response { session[:var] = 'value' }
|
||||
end
|
||||
|
||||
should "accept assigning to that variable" do
|
||||
assert_accepts set_session(:var), @controller
|
||||
end
|
||||
|
||||
should "accept assigning the correct value to that variable" do
|
||||
assert_accepts set_session(:var).to('value'), @controller
|
||||
end
|
||||
|
||||
should "reject assigning another value to that variable" do
|
||||
assert_rejects set_session(:var).to('other'), @controller
|
||||
end
|
||||
|
||||
should "reject assigning to another variable" do
|
||||
assert_rejects set_session(:other), @controller
|
||||
end
|
||||
|
||||
should "accept assigning nil to another variable" do
|
||||
assert_accepts set_session(:other).to(nil), @controller
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
41
vendor/gems/thoughtbot-shoulda-2.10.1/test/matchers/controller/set_the_flash_matcher.rb
vendored
Normal file
41
vendor/gems/thoughtbot-shoulda-2.10.1/test/matchers/controller/set_the_flash_matcher.rb
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
||||
|
||||
class SetTheFlashMatcherTest < Test::Unit::TestCase # :nodoc:
|
||||
|
||||
context "a controller that sets a flash message" do
|
||||
setup do
|
||||
@controller = build_response { flash[:notice] = 'value' }
|
||||
end
|
||||
|
||||
should "accept setting any flash message" do
|
||||
assert_accepts set_the_flash, @controller
|
||||
end
|
||||
|
||||
should "accept setting the exact flash message" do
|
||||
assert_accepts set_the_flash.to('value'), @controller
|
||||
end
|
||||
|
||||
should "accept setting a matched flash message" do
|
||||
assert_accepts set_the_flash.to(/value/), @controller
|
||||
end
|
||||
|
||||
should "reject setting a different flash message" do
|
||||
assert_rejects set_the_flash.to('other'), @controller
|
||||
end
|
||||
|
||||
should "reject setting a different pattern" do
|
||||
assert_rejects set_the_flash.to(/other/), @controller
|
||||
end
|
||||
end
|
||||
|
||||
context "a controller that doesn't set a flash message" do
|
||||
setup do
|
||||
@controller = build_response
|
||||
end
|
||||
|
||||
should "reject setting any flash message" do
|
||||
assert_rejects set_the_flash, @controller
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user