i18n_scope 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/test/i18n_scope_test.rb +61 -0
- data/test/test_helper.rb +3 -0
- metadata +6 -4
data/Rakefile
CHANGED
@@ -45,7 +45,7 @@ spec = Gem::Specification.new do |s|
|
|
45
45
|
|
46
46
|
# Change these as appropriate
|
47
47
|
s.name = "i18n_scope"
|
48
|
-
s.version = "0.1.
|
48
|
+
s.version = "0.1.3"
|
49
49
|
s.summary = "Magic scoping for I18n"
|
50
50
|
s.author = "Matthew Rudy Jacobs"
|
51
51
|
s.email = "MatthewRudyJacobs@gmail.com"
|
@@ -58,7 +58,7 @@ spec = Gem::Specification.new do |s|
|
|
58
58
|
# s.rdoc_options = %w(--main README)
|
59
59
|
|
60
60
|
# Add any extra files to include in the gem (like your README)
|
61
|
-
s.files = %w(Rakefile) + Dir.glob("{test,lib/**/*
|
61
|
+
s.files = %w(Rakefile) + Dir.glob("{test,lib}/**/*")
|
62
62
|
s.require_paths = ["lib"]
|
63
63
|
|
64
64
|
# If you want to depend on other gems, add them here, along with any
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class I18nScopeTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_scoped_empty
|
6
|
+
scope = I18n.scoped()
|
7
|
+
assert_equal "", scope.translation_key
|
8
|
+
|
9
|
+
scope2 = scope.something
|
10
|
+
assert_equal "something", scope2.translation_key
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_scoped_single_key
|
14
|
+
scope = I18n.scoped(:abc)
|
15
|
+
assert_equal "abc", scope.translation_key
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_scoped_multiple_key
|
19
|
+
scope = I18n.scoped([:abc, :def])
|
20
|
+
assert_equal "abc.def", scope.translation_key
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_chaining
|
24
|
+
scope = I18n.scoped([:abc]).def.ghi.jkl
|
25
|
+
assert_equal "abc.def.ghi.jkl", scope.translation_key
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_chaining_is_not_in_place
|
29
|
+
empty = I18n.scoped()
|
30
|
+
|
31
|
+
scope1 = empty.abc.def
|
32
|
+
scope2 = empty.ghi.jkl
|
33
|
+
scope3 = scope1.mno.pqr
|
34
|
+
|
35
|
+
assert_equal "", empty.translation_key
|
36
|
+
assert_equal "abc.def", scope1.translation_key
|
37
|
+
assert_equal "ghi.jkl", scope2.translation_key
|
38
|
+
assert_equal "abc.def.mno.pqr", scope3.translation_key
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_method_missing_is_reasonable
|
42
|
+
base = I18n.scoped(:base)
|
43
|
+
|
44
|
+
assert_raise(NoMethodError) do
|
45
|
+
base + "something with a plus"
|
46
|
+
end
|
47
|
+
|
48
|
+
assert_raise(NoMethodError) do
|
49
|
+
base.some_question?
|
50
|
+
end
|
51
|
+
|
52
|
+
assert_raise(NoMethodError) do
|
53
|
+
base.some_bang!
|
54
|
+
end
|
55
|
+
|
56
|
+
assert u = base._underscores_are_ok_
|
57
|
+
assert_equal "base._underscores_are_ok_", u.translation_key
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_scope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthew Rudy Jacobs
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-19 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -42,6 +42,8 @@ extra_rdoc_files: []
|
|
42
42
|
|
43
43
|
files:
|
44
44
|
- Rakefile
|
45
|
+
- test/i18n_scope_test.rb
|
46
|
+
- test/test_helper.rb
|
45
47
|
- lib/i18n/scope.rb
|
46
48
|
- lib/i18n_scope.rb
|
47
49
|
has_rdoc: true
|