aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/caching_test.rb47
-rw-r--r--actionpack/test/controller/spec_style_test.rb208
-rw-r--r--actionpack/test/controller/spec_type_test.rb37
-rw-r--r--actionpack/test/dispatch/mime_type_test.rb8
-rw-r--r--actionpack/test/dispatch/rack_test.rb12
-rw-r--r--actionpack/test/dispatch/request/json_params_parsing_test.rb4
-rw-r--r--actionpack/test/dispatch/request/xml_params_parsing_test.rb4
-rw-r--r--actionpack/test/dispatch/routing/inspector_test.rb4
-rw-r--r--actionpack/test/dispatch/spec_type_test.rb41
-rw-r--r--actionpack/test/dispatch/uploaded_file_test.rb20
-rw-r--r--actionpack/test/metal/caching_test.rb32
-rw-r--r--actionpack/test/template/asset_tag_helper_test.rb2
-rw-r--r--actionpack/test/template/spec_type_test.rb39
-rw-r--r--actionpack/test/template/test_case_test.rb2
-rw-r--r--actionpack/test/template/test_test.rb56
15 files changed, 462 insertions, 54 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 2c3511f6a0..620479cb0c 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -5,6 +5,43 @@ require 'active_record_unit'
CACHE_DIR = 'test_cache'
# Don't change '/../temp/' cavalierly or you might hose something you don't want hosed
FILE_STORE_PATH = File.join(File.dirname(__FILE__), '/../temp/', CACHE_DIR)
+
+class CachingMetalController < ActionController::Metal
+ abstract!
+
+ include ActionController::Caching
+
+ self.page_cache_directory = FILE_STORE_PATH
+ self.cache_store = :file_store, FILE_STORE_PATH
+end
+
+class PageCachingMetalTestController < CachingMetalController
+ caches_page :ok
+
+ def ok
+ self.response_body = 'ok'
+ end
+end
+
+class PageCachingMetalTest < ActionController::TestCase
+ tests PageCachingMetalTestController
+
+ def setup
+ FileUtils.rm_rf(File.dirname(FILE_STORE_PATH))
+ FileUtils.mkdir_p(FILE_STORE_PATH)
+ end
+
+ def teardown
+ FileUtils.rm_rf(File.dirname(FILE_STORE_PATH))
+ end
+
+ def test_should_cache_get_with_ok_status
+ get :ok
+ assert_response :ok
+ assert File.exist?("#{FILE_STORE_PATH}/page_caching_metal_test/ok.html"), 'get with ok status should have been cached'
+ end
+end
+
ActionController::Base.page_cache_directory = FILE_STORE_PATH
class CachingController < ActionController::Base
@@ -862,7 +899,7 @@ CACHED
get :html_fragment_cached_with_partial
assert_response :success
assert_match(/Old fragment caching in a partial/, @response.body)
-
+
assert_match("Old fragment caching in a partial",
@store.read("views/test.host/functional_caching/html_fragment_cached_with_partial/#{template_digest("functional_caching/_partial", "html")}"))
end
@@ -872,7 +909,7 @@ CACHED
assert_response :success
assert_match(/Some inline content/, @response.body)
assert_match(/Some cached content/, @response.body)
- assert_match("Some cached content",
+ assert_match("Some cached content",
@store.read("views/test.host/functional_caching/inline_fragment_cached/#{template_digest("functional_caching/inline_fragment_cached", "html")}"))
end
@@ -883,7 +920,7 @@ CACHED
assert_equal expected_body, @response.body
- assert_equal "<p>ERB</p>",
+ assert_equal "<p>ERB</p>",
@store.read("views/test.host/functional_caching/formatted_fragment_cached/#{template_digest("functional_caching/formatted_fragment_cached", "html")}")
end
@@ -897,7 +934,7 @@ CACHED
assert_equal " <p>Builder</p>\n",
@store.read("views/test.host/functional_caching/formatted_fragment_cached/#{template_digest("functional_caching/formatted_fragment_cached", "xml")}")
end
-
+
private
def template_digest(name, format)
ActionView::Digestor.digest(name, format, @controller.lookup_context)
@@ -949,5 +986,5 @@ class CacheHelperOutputBufferTest < ActionController::TestCase
cache_helper.send :fragment_for, 'Test fragment name', 'Test fragment', &Proc.new{ nil }
end
end
-
end
+
diff --git a/actionpack/test/controller/spec_style_test.rb b/actionpack/test/controller/spec_style_test.rb
new file mode 100644
index 0000000000..e118c584ca
--- /dev/null
+++ b/actionpack/test/controller/spec_style_test.rb
@@ -0,0 +1,208 @@
+require "abstract_unit"
+
+class ApplicationController < ActionController::Base; end
+class ModelsController < ApplicationController; end
+module Admin
+ class WidgetsController < ApplicationController; end
+end
+
+# ApplicationController
+describe ApplicationController do
+ describe "nested" do
+ describe "even deeper" do
+ it "exists" do
+ assert_kind_of ApplicationController, @controller
+ end
+ end
+ end
+end
+
+describe ApplicationController, :index do
+ describe "nested" do
+ describe "even deeper" do
+ it "exists" do
+ assert_kind_of ApplicationController, @controller
+ end
+ end
+ end
+end
+
+describe ApplicationController, "unauthenticated user" do
+ describe "nested" do
+ describe "even deeper" do
+ it "exists" do
+ assert_kind_of ApplicationController, @controller
+ end
+ end
+ end
+end
+
+describe "ApplicationControllerTest" do
+ describe "nested" do
+ describe "even deeper" do
+ it "exists" do
+ assert_kind_of ApplicationController, @controller
+ end
+ end
+ end
+end
+
+describe "ApplicationControllerTest", :index do
+ describe "nested" do
+ describe "even deeper" do
+ it "exists" do
+ assert_kind_of ApplicationController, @controller
+ end
+ end
+ end
+end
+
+describe "ApplicationControllerTest", "unauthenticated user" do
+ describe "nested" do
+ describe "even deeper" do
+ it "exists" do
+ assert_kind_of ApplicationController, @controller
+ end
+ end
+ end
+end
+
+# ModelsController
+describe ModelsController do
+ describe "nested" do
+ describe "even deeper" do
+ it "exists" do
+ assert_kind_of ModelsController, @controller
+ end
+ end
+ end
+end
+
+describe ModelsController, :index do
+ describe "nested" do
+ describe "even deeper" do
+ it "exists" do
+ assert_kind_of ModelsController, @controller
+ end
+ end
+ end
+end
+
+describe ModelsController, "unauthenticated user" do
+ describe "nested" do
+ describe "even deeper" do
+ it "exists" do
+ assert_kind_of ModelsController, @controller
+ end
+ end
+ end
+end
+
+describe "ModelsControllerTest" do
+ describe "nested" do
+ describe "even deeper" do
+ it "exists" do
+ assert_kind_of ModelsController, @controller
+ end
+ end
+ end
+end
+
+describe "ModelsControllerTest", :index do
+ describe "nested" do
+ describe "even deeper" do
+ it "exists" do
+ assert_kind_of ModelsController, @controller
+ end
+ end
+ end
+end
+
+describe "ModelsControllerTest", "unauthenticated user" do
+ describe "nested" do
+ describe "even deeper" do
+ it "exists" do
+ assert_kind_of ModelsController, @controller
+ end
+ end
+ end
+end
+
+# Nested Admin::WidgetsControllerTest
+module Admin
+ class WidgetsControllerTest < ActionController::TestCase
+ test "exists" do
+ assert_kind_of Admin::WidgetsController, @controller
+ end
+ end
+
+ describe WidgetsController do
+ describe "index" do
+ it "respond successful" do
+ assert_kind_of Admin::WidgetsController, @controller
+ end
+ end
+ end
+
+ describe WidgetsController, "unauthenticated users" do
+ describe "index" do
+ it "respond successful" do
+ assert_kind_of Admin::WidgetsController, @controller
+ end
+ end
+ end
+end
+
+class Admin::WidgetsControllerTest < ActionController::TestCase
+ test "exists here too" do
+ assert_kind_of Admin::WidgetsController, @controller
+ end
+end
+
+describe Admin::WidgetsController do
+ describe "index" do
+ it "respond successful" do
+ assert_kind_of Admin::WidgetsController, @controller
+ end
+ end
+end
+
+describe Admin::WidgetsController, "unauthenticated users" do
+ describe "index" do
+ it "respond successful" do
+ assert_kind_of Admin::WidgetsController, @controller
+ end
+ end
+end
+
+describe "Admin::WidgetsController" do
+ describe "index" do
+ it "respond successful" do
+ assert_kind_of Admin::WidgetsController, @controller
+ end
+ end
+end
+
+describe "Admin::WidgetsControllerTest" do
+ describe "index" do
+ it "respond successful" do
+ assert_kind_of Admin::WidgetsController, @controller
+ end
+ end
+end
+
+describe "Admin::WidgetsController", "unauthenticated users" do
+ describe "index" do
+ it "respond successful" do
+ assert_kind_of Admin::WidgetsController, @controller
+ end
+ end
+end
+
+describe "Admin::WidgetsControllerTest", "unauthenticated users" do
+ describe "index" do
+ it "respond successful" do
+ assert_kind_of Admin::WidgetsController, @controller
+ end
+ end
+end
diff --git a/actionpack/test/controller/spec_type_test.rb b/actionpack/test/controller/spec_type_test.rb
new file mode 100644
index 0000000000..13be8a3405
--- /dev/null
+++ b/actionpack/test/controller/spec_type_test.rb
@@ -0,0 +1,37 @@
+require "abstract_unit"
+
+class ApplicationController < ActionController::Base; end
+class ModelsController < ApplicationController; end
+
+class ActionControllerSpecTypeTest < ActiveSupport::TestCase
+ def assert_controller actual
+ assert_equal ActionController::TestCase, actual
+ end
+
+ def refute_controller actual
+ refute_equal ActionController::TestCase, actual
+ end
+
+ def test_spec_type_resolves_for_class_constants
+ assert_controller MiniTest::Spec.spec_type(ApplicationController)
+ assert_controller MiniTest::Spec.spec_type(ModelsController)
+ end
+
+ def test_spec_type_resolves_for_matching_strings
+ assert_controller MiniTest::Spec.spec_type("WidgetController")
+ assert_controller MiniTest::Spec.spec_type("WidgetControllerTest")
+ assert_controller MiniTest::Spec.spec_type("Widget Controller Test")
+ # And is not case sensitive
+ assert_controller MiniTest::Spec.spec_type("widgetcontroller")
+ assert_controller MiniTest::Spec.spec_type("widgetcontrollertest")
+ assert_controller MiniTest::Spec.spec_type("widget controller test")
+ end
+
+ def test_spec_type_wont_match_non_space_characters
+ refute_controller MiniTest::Spec.spec_type("Widget Controller\tTest")
+ refute_controller MiniTest::Spec.spec_type("Widget Controller\rTest")
+ refute_controller MiniTest::Spec.spec_type("Widget Controller\nTest")
+ refute_controller MiniTest::Spec.spec_type("Widget Controller\fTest")
+ refute_controller MiniTest::Spec.spec_type("Widget ControllerXTest")
+ end
+end
diff --git a/actionpack/test/dispatch/mime_type_test.rb b/actionpack/test/dispatch/mime_type_test.rb
index 3e83f3d4fa..e2a9ba782d 100644
--- a/actionpack/test/dispatch/mime_type_test.rb
+++ b/actionpack/test/dispatch/mime_type_test.rb
@@ -185,9 +185,11 @@ class MimeTypeTest < ActiveSupport::TestCase
all_types.uniq!
# Remove custom Mime::Type instances set in other tests, like Mime::GIF and Mime::IPHONE
all_types.delete_if { |type| !Mime.const_defined?(type.upcase) }
- verified, unverified = all_types.partition { |type| Mime::Type.browser_generated_types.include? type }
- assert verified.each { |type| assert Mime.const_get(type.upcase).verify_request?, "Verifiable Mime Type is not verified: #{type.inspect}" }
- assert unverified.each { |type| assert !Mime.const_get(type.upcase).verify_request?, "Nonverifiable Mime Type is verified: #{type.inspect}" }
+ assert_deprecated do
+ verified, unverified = all_types.partition { |type| Mime::Type.browser_generated_types.include? type }
+ assert verified.each { |type| assert Mime.const_get(type.upcase).verify_request?, "Verifiable Mime Type is not verified: #{type.inspect}" }
+ assert unverified.each { |type| assert !Mime.const_get(type.upcase).verify_request?, "Nonverifiable Mime Type is verified: #{type.inspect}" }
+ end
end
test "references gives preference to symbols before strings" do
diff --git a/actionpack/test/dispatch/rack_test.rb b/actionpack/test/dispatch/rack_test.rb
index 698f980296..6d239d0a0c 100644
--- a/actionpack/test/dispatch/rack_test.rb
+++ b/actionpack/test/dispatch/rack_test.rb
@@ -176,13 +176,17 @@ end
class RackRequestContentTypeTest < BaseRackTest
test "html content type verification" do
- @request.env['CONTENT_TYPE'] = Mime::HTML.to_s
- assert @request.content_mime_type.verify_request?
+ assert_deprecated do
+ @request.env['CONTENT_TYPE'] = Mime::HTML.to_s
+ assert @request.content_mime_type.verify_request?
+ end
end
test "xml content type verification" do
- @request.env['CONTENT_TYPE'] = Mime::XML.to_s
- assert !@request.content_mime_type.verify_request?
+ assert_deprecated do
+ @request.env['CONTENT_TYPE'] = Mime::XML.to_s
+ assert !@request.content_mime_type.verify_request?
+ end
end
end
diff --git a/actionpack/test/dispatch/request/json_params_parsing_test.rb b/actionpack/test/dispatch/request/json_params_parsing_test.rb
index 302bff0696..c0c3147e37 100644
--- a/actionpack/test/dispatch/request/json_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/json_params_parsing_test.rb
@@ -46,7 +46,9 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest
begin
$stderr = StringIO.new # suppress the log
json = "[\"person]\": {\"name\": \"David\"}}"
- assert_raise(MultiJson::DecodeError) { post "/parse", json, {'CONTENT_TYPE' => 'application/json', 'action_dispatch.show_exceptions' => false} }
+ exception = assert_raise(ActionDispatch::ParamsParser::ParseError) { post "/parse", json, {'CONTENT_TYPE' => 'application/json', 'action_dispatch.show_exceptions' => false} }
+ assert_equal MultiJson::DecodeError, exception.original_exception.class
+ assert_equal exception.original_exception.message, exception.message
ensure
$stderr = STDERR
end
diff --git a/actionpack/test/dispatch/request/xml_params_parsing_test.rb b/actionpack/test/dispatch/request/xml_params_parsing_test.rb
index 84823e2896..cb68667002 100644
--- a/actionpack/test/dispatch/request/xml_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/xml_params_parsing_test.rb
@@ -68,7 +68,9 @@ class XmlParamsParsingTest < ActionDispatch::IntegrationTest
begin
$stderr = StringIO.new # suppress the log
xml = "<person><name>David</name></pineapple>"
- assert_raise(REXML::ParseException) { post "/parse", xml, default_headers.merge('action_dispatch.show_exceptions' => false) }
+ exception = assert_raise(ActionDispatch::ParamsParser::ParseError) { post "/parse", xml, default_headers.merge('action_dispatch.show_exceptions' => false) }
+ assert_equal REXML::ParseException, exception.original_exception.class
+ assert_equal exception.original_exception.message, exception.message
ensure
$stderr = STDERR
end
diff --git a/actionpack/test/dispatch/routing/inspector_test.rb b/actionpack/test/dispatch/routing/inspector_test.rb
index 97fc4f3e4b..a3034ce001 100644
--- a/actionpack/test/dispatch/routing/inspector_test.rb
+++ b/actionpack/test/dispatch/routing/inspector_test.rb
@@ -24,7 +24,7 @@ module ActionDispatch
def test_displaying_routes_for_engines
engine = Class.new(Rails::Engine) do
- def self.to_s
+ def self.inspect
"Blog::Engine"
end
end
@@ -132,7 +132,7 @@ module ActionDispatch
def test_rake_routes_shows_route_with_rack_app_nested_with_dynamic_constraints
constraint = Class.new do
- def to_s
+ def inspect
"( my custom constraint )"
end
end
diff --git a/actionpack/test/dispatch/spec_type_test.rb b/actionpack/test/dispatch/spec_type_test.rb
new file mode 100644
index 0000000000..6cd19fd333
--- /dev/null
+++ b/actionpack/test/dispatch/spec_type_test.rb
@@ -0,0 +1,41 @@
+require "abstract_unit"
+
+class SpecTypeTest < ActiveSupport::TestCase
+ def assert_dispatch actual
+ assert_equal ActionDispatch::IntegrationTest, actual
+ end
+
+ def refute_dispatch actual
+ refute_equal ActionDispatch::IntegrationTest, actual
+ end
+
+ def test_spec_type_resolves_for_matching_acceptance_strings
+ assert_dispatch MiniTest::Spec.spec_type("WidgetAcceptanceTest")
+ assert_dispatch MiniTest::Spec.spec_type("Widget Acceptance Test")
+ assert_dispatch MiniTest::Spec.spec_type("widgetacceptancetest")
+ assert_dispatch MiniTest::Spec.spec_type("widget acceptance test")
+ end
+
+ def test_spec_type_wont_match_non_space_characters_acceptance
+ refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\tTest")
+ refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\rTest")
+ refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\nTest")
+ refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\fTest")
+ refute_dispatch MiniTest::Spec.spec_type("Widget AcceptanceXTest")
+ end
+
+ def test_spec_type_resolves_for_matching_integration_strings
+ assert_dispatch MiniTest::Spec.spec_type("WidgetIntegrationTest")
+ assert_dispatch MiniTest::Spec.spec_type("Widget Integration Test")
+ assert_dispatch MiniTest::Spec.spec_type("widgetintegrationtest")
+ assert_dispatch MiniTest::Spec.spec_type("widget integration test")
+ end
+
+ def test_spec_type_wont_match_non_space_characters_integration
+ refute_dispatch MiniTest::Spec.spec_type("Widget Integration\tTest")
+ refute_dispatch MiniTest::Spec.spec_type("Widget Integration\rTest")
+ refute_dispatch MiniTest::Spec.spec_type("Widget Integration\nTest")
+ refute_dispatch MiniTest::Spec.spec_type("Widget Integration\fTest")
+ refute_dispatch MiniTest::Spec.spec_type("Widget IntegrationXTest")
+ end
+end
diff --git a/actionpack/test/dispatch/uploaded_file_test.rb b/actionpack/test/dispatch/uploaded_file_test.rb
index e69c1fbed4..72f3d1db0d 100644
--- a/actionpack/test/dispatch/uploaded_file_test.rb
+++ b/actionpack/test/dispatch/uploaded_file_test.rb
@@ -45,14 +45,26 @@ module ActionDispatch
assert_equal 'thunderhorse', uf.open
end
- def test_delegates_to_tempfile
- tf = Class.new { def read; 'thunderhorse' end }
+ def test_delegates_close_to_tempfile
+ tf = Class.new { def close(unlink_now=false); 'thunderhorse' end }
+ uf = Http::UploadedFile.new(:tempfile => tf.new)
+ assert_equal 'thunderhorse', uf.close
+ end
+
+ def test_close_accepts_parameter
+ tf = Class.new { def close(unlink_now=false); "thunderhorse: #{unlink_now}" end }
+ uf = Http::UploadedFile.new(:tempfile => tf.new)
+ assert_equal 'thunderhorse: true', uf.close(true)
+ end
+
+ def test_delegates_read_to_tempfile
+ tf = Class.new { def read(length=nil, buffer=nil); 'thunderhorse' end }
uf = Http::UploadedFile.new(:tempfile => tf.new)
assert_equal 'thunderhorse', uf.read
end
- def test_delegates_to_tempfile_with_params
- tf = Class.new { def read *args; args end }
+ def test_delegates_read_to_tempfile_with_params
+ tf = Class.new { def read(length=nil, buffer=nil); [length, buffer] end }
uf = Http::UploadedFile.new(:tempfile => tf.new)
assert_equal %w{ thunder horse }, uf.read(*%w{ thunder horse })
end
diff --git a/actionpack/test/metal/caching_test.rb b/actionpack/test/metal/caching_test.rb
deleted file mode 100644
index a2b6763754..0000000000
--- a/actionpack/test/metal/caching_test.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'abstract_unit'
-
-CACHE_DIR = 'test_cache'
-# Don't change '/../temp/' cavalierly or you might hose something you don't want hosed
-FILE_STORE_PATH = File.join(File.dirname(__FILE__), '/../temp/', CACHE_DIR)
-
-class CachingController < ActionController::Metal
- abstract!
-
- include ActionController::Caching
-
- self.page_cache_directory = FILE_STORE_PATH
- self.cache_store = :file_store, FILE_STORE_PATH
-end
-
-class PageCachingTestController < CachingController
- caches_page :ok
-
- def ok
- self.response_body = "ok"
- end
-end
-
-class PageCachingTest < ActionController::TestCase
- tests PageCachingTestController
-
- def test_should_cache_get_with_ok_status
- get :ok
- assert_response :ok
- assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/ok.html"), "get with ok status should have been cached"
- end
-end
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb
index 25d85c47c7..a04694714d 100644
--- a/actionpack/test/template/asset_tag_helper_test.rb
+++ b/actionpack/test/template/asset_tag_helper_test.rb
@@ -192,9 +192,9 @@ class AssetTagHelperTest < ActionView::TestCase
ImageLinkToTag = {
%(image_tag("xml.png")) => %(<img alt="Xml" src="/images/xml.png" />),
%(image_tag("rss.gif", :alt => "rss syndication")) => %(<img alt="rss syndication" src="/images/rss.gif" />),
+ %(image_tag("gold.png", :size => "20")) => %(<img alt="Gold" height="20" src="/images/gold.png" width="20" />),
%(image_tag("gold.png", :size => "45x70")) => %(<img alt="Gold" height="70" src="/images/gold.png" width="45" />),
%(image_tag("gold.png", "size" => "45x70")) => %(<img alt="Gold" height="70" src="/images/gold.png" width="45" />),
- %(image_tag("error.png", "size" => "45")) => %(<img alt="Error" src="/images/error.png" />),
%(image_tag("error.png", "size" => "45 x 70")) => %(<img alt="Error" src="/images/error.png" />),
%(image_tag("error.png", "size" => "x")) => %(<img alt="Error" src="/images/error.png" />),
%(image_tag("google.com.png")) => %(<img alt="Google.com" src="/images/google.com.png" />),
diff --git a/actionpack/test/template/spec_type_test.rb b/actionpack/test/template/spec_type_test.rb
new file mode 100644
index 0000000000..08a7bdf81d
--- /dev/null
+++ b/actionpack/test/template/spec_type_test.rb
@@ -0,0 +1,39 @@
+require 'abstract_unit'
+
+class ActionViewSpecTypeTest < ActiveSupport::TestCase
+ def assert_view actual
+ assert_equal ActionView::TestCase, actual
+ end
+
+ def refute_view actual
+ refute_equal ActionView::TestCase, actual
+ end
+
+ def test_spec_type_resolves_for_matching_helper_strings
+ assert_view MiniTest::Spec.spec_type("WidgetHelper")
+ assert_view MiniTest::Spec.spec_type("WidgetHelperTest")
+ assert_view MiniTest::Spec.spec_type("Widget Helper Test")
+ # And is not case sensitive
+ assert_view MiniTest::Spec.spec_type("widgethelper")
+ assert_view MiniTest::Spec.spec_type("widgethelpertest")
+ assert_view MiniTest::Spec.spec_type("widget helper test")
+ end
+
+ def test_spec_type_resolves_for_matching_view_strings
+ assert_view MiniTest::Spec.spec_type("WidgetView")
+ assert_view MiniTest::Spec.spec_type("WidgetViewTest")
+ assert_view MiniTest::Spec.spec_type("Widget View Test")
+ # And is not case sensitive
+ assert_view MiniTest::Spec.spec_type("widgetview")
+ assert_view MiniTest::Spec.spec_type("widgetviewtest")
+ assert_view MiniTest::Spec.spec_type("widget view test")
+ end
+
+ def test_spec_type_wont_match_non_space_characters
+ refute_view MiniTest::Spec.spec_type("Widget Helper\tTest")
+ refute_view MiniTest::Spec.spec_type("Widget Helper\rTest")
+ refute_view MiniTest::Spec.spec_type("Widget Helper\nTest")
+ refute_view MiniTest::Spec.spec_type("Widget Helper\fTest")
+ refute_view MiniTest::Spec.spec_type("Widget HelperXTest")
+ end
+end
diff --git a/actionpack/test/template/test_case_test.rb b/actionpack/test/template/test_case_test.rb
index 387aafebd4..5265ae6b3a 100644
--- a/actionpack/test/template/test_case_test.rb
+++ b/actionpack/test/template/test_case_test.rb
@@ -64,7 +64,7 @@ module ActionView
assert_equal 'Howdy!', from_another_helper
end
- test "determine_default_helper_class returns nil if name.sub(/Test$/, '').constantize resolves to a class" do
+ test "determine_default_helper_class returns nil if the test name constant resolves to a class" do
assert_nil self.class.determine_default_helper_class("String")
end
diff --git a/actionpack/test/template/test_test.rb b/actionpack/test/template/test_test.rb
index 108a674d95..e843a1deb4 100644
--- a/actionpack/test/template/test_test.rb
+++ b/actionpack/test/template/test_test.rb
@@ -78,3 +78,59 @@ class CrazyStringHelperTest < ActionView::TestCase
assert_equal PeopleHelper, self.class.helper_class
end
end
+
+describe PeopleHelper do
+ it "resolves the right helper_class" do
+ assert_equal PeopleHelper, self.class.helper_class
+ end
+end
+
+describe PeopleHelper, :helper_class do
+ it "resolves the right helper_class" do
+ assert_equal PeopleHelper, self.class.helper_class
+ end
+end
+
+describe PeopleHelper do
+ describe "even while nested" do
+ it "resolves the right helper_class" do
+ assert_equal PeopleHelper, self.class.helper_class
+ end
+ end
+end
+
+describe PeopleHelper, :helper_class do
+ describe "even while nested" do
+ it "resolves the right helper_class" do
+ assert_equal PeopleHelper, self.class.helper_class
+ end
+ end
+end
+
+describe "PeopleHelper" do
+ it "resolves the right helper_class" do
+ assert_equal PeopleHelper, self.class.helper_class
+ end
+end
+
+describe "PeopleHelperTest" do
+ it "resolves the right helper_class" do
+ assert_equal PeopleHelper, self.class.helper_class
+ end
+end
+
+describe "PeopleHelper" do
+ describe "even while nested" do
+ it "resolves the right helper_class" do
+ assert_equal PeopleHelper, self.class.helper_class
+ end
+ end
+end
+
+describe "PeopleHelperTest" do
+ describe "even while nested" do
+ it "resolves the right helper_class" do
+ assert_equal PeopleHelper, self.class.helper_class
+ end
+ end
+end