test/rails-localization_test.rb in rails-localization-1.2.0 vs test/rails-localization_test.rb in rails-localization-2.1.0
- old
+ new
@@ -3,10 +3,19 @@
require File.expand_path("support/capybara_helper", File.dirname(__FILE__))
class RailsLocalizationTest < ActionDispatch::IntegrationTest
include CapybaraHelper
+ setup do
+ I18n.available_locales = [:en, :ru]
+ end
+
+ teardown do
+ ::I18n.locale = ::I18n.default_locale
+ I18n.available_locales = []
+ end
+
#context "sub app" do
test "should access without locale" do
visit "/sub"
assert_equal 200, page.status_code
@@ -79,11 +88,11 @@
visit "/"
assert_equal 200, page.status_code
assert page.has_content? "translation missing: en.main.index"
end
-
+
test "root page should access with english locale" do
visit "/en"
assert_equal 200, page.status_code
assert page.has_content? "translation missing: en.main.index"
@@ -102,31 +111,31 @@
assert page.has_content? "translation missing: ru.main.index"
end
#end
#context "welcome page" do
- def test_welcome_with_locale_1
+ test "page with locale 1 returns context" do
visit "/en/welcome"
assert_equal 200, page.status_code
assert page.has_content? "translation missing: en.main.welcome"
end
- def test_welcome_with_locale_2
+ test "page with locale 2 returns context" do
visit "/ru/welcome"
assert_equal 200, page.status_code
assert page.has_content? "translation missing: ru.main.welcome"
end
#end
-
+
#context "404" do
- def test_wrong_page_without_locale
+ test "wrong page without locale" do
assert_raise ActionController::RoutingError do
visit "/test"
end
end
- def test_wrong_page_with_locale
+ test "wrong page with locale" do
assert_raise ActionController::RoutingError do
visit "en/test"
end
end
#end
@@ -180,6 +189,6 @@
assert_raise ActionController::RoutingError do
visit "/ru/users/with_defined_locale"
end
end
#end
-end
\ No newline at end of file
+end