svenfuchs-i18n-tools 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/core_ext/hash/iterate_nested.rb +35 -0
- data/lib/core_ext/hash/slice.rb +20 -0
- data/lib/core_ext/hash/sorted_yaml_style.rb +17 -0
- data/lib/core_ext/hash/symbolize_keys.rb +14 -0
- data/lib/core_ext/module/attribute_accessors.rb +48 -0
- data/lib/core_ext/object/deep_clone.rb +5 -0
- data/lib/core_ext/object/instance_variables.rb +9 -0
- data/lib/core_ext/object/meta_class.rb +5 -0
- data/lib/core_ext/object/tap.rb +6 -0
- data/lib/i18n/backend/simple_storage.rb +119 -0
- data/lib/i18n/commands/keys.rb +84 -0
- data/lib/i18n/exceptions/key_exists.rb +9 -0
- data/lib/i18n/index.rb +33 -0
- data/lib/i18n/index/base.rb +38 -0
- data/lib/i18n/index/file.rb +55 -0
- data/lib/i18n/index/format.rb +49 -0
- data/lib/i18n/index/key.rb +45 -0
- data/lib/i18n/index/occurence.rb +18 -0
- data/lib/i18n/index/simple.rb +69 -0
- data/lib/i18n/index/simple/data.rb +34 -0
- data/lib/i18n/index/simple/storage.rb +79 -0
- data/lib/i18n/ripper2ruby.rb +7 -0
- data/lib/i18n/ripper2ruby/translate_args_list.rb +89 -0
- data/lib/i18n/ripper2ruby/translate_call.rb +66 -0
- data/lib/i18n/translation_properties.rb +38 -0
- data/test/all.rb +1 -1
- data/test/core_ext/hash_iterate_nested.rb +31 -0
- data/test/fixtures/all.rb.src +106 -0
- data/test/fixtures/config.yml +3 -0
- data/test/fixtures/locale/de.yml +4 -0
- data/test/fixtures/locale/en.yml +4 -0
- data/test/fixtures/source_1.rb +2 -1
- data/test/fixtures/translate/double_key.rb +32 -0
- data/test/fixtures/translate/double_scope.rb +32 -0
- data/test/fixtures/translate/single_key.rb +10 -0
- data/test/fixtures/translate/single_scope.rb +32 -0
- data/test/i18n/backend/simple_storage_test.rb +81 -0
- data/test/i18n/backend/translation_properties_test.rb +33 -0
- data/test/i18n/index/all.rb +1 -0
- data/test/i18n/index/args_replace_test.rb +218 -0
- data/test/i18n/index/calls_replace_test.rb +67 -0
- data/test/i18n/index/commands_test.rb +75 -0
- data/test/i18n/index/key_test.rb +32 -0
- data/test/i18n/index/simple_test.rb +67 -0
- data/test/i18n/ripper2ruby/translate_call_test.rb +98 -0
- data/test/test_helper.rb +66 -9
- metadata +49 -32
- data/MIT-LICENSE +0 -20
- data/README.textile +0 -1
- data/bin/i18n-keys +0 -6
- data/lib/ansi.rb +0 -19
- data/lib/i18n/keys.rb +0 -51
- data/lib/i18n/keys/commands.rb +0 -53
- data/lib/i18n/keys/formatter.rb +0 -39
- data/lib/i18n/keys/index.rb +0 -209
- data/lib/i18n/keys/occurence.rb +0 -120
- data/lib/i18n/parser/erb_parser.rb +0 -54
- data/lib/i18n/parser/ruby_parser.rb +0 -93
- data/test/commands_test.rb +0 -1
- data/test/erb_parser_test.rb +0 -31
- data/test/index_test.rb +0 -135
- data/test/keys_test.rb +0 -75
- data/test/occurence_test.rb +0 -130
- data/test/ruby_parser_test.rb +0 -54
data/test/commands_test.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
data/test/erb_parser_test.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
require 'erb'
|
3
|
-
|
4
|
-
class ErbParserTest < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@erb = File.read("#{File.dirname(__FILE__)}/fixtures/template.html.erb")
|
7
|
-
@ruby = I18n::ErbParser.new.to_ruby(@erb)
|
8
|
-
@expected = <<-src
|
9
|
-
f.field_set do
|
10
|
-
column do
|
11
|
-
[:foo].each do |foo|
|
12
|
-
t(:erb_1)
|
13
|
-
end
|
14
|
-
t(:erb_2)
|
15
|
-
t(:'foo.erb_3')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
src
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_sexp_filename
|
22
|
-
assert_equal @erb.length, @ruby.length
|
23
|
-
%w(erb_1 erb_2 foo.erb_3).each do |token|
|
24
|
-
assert @ruby.index(token)
|
25
|
-
assert_equal @erb.index(token), @ruby.index(token)
|
26
|
-
end
|
27
|
-
@expected.split("\n").each do |token|
|
28
|
-
assert @ruby.index(token)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/test/index_test.rb
DELETED
@@ -1,135 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
class IndexTest < Test::Unit::TestCase
|
4
|
-
include I18n
|
5
|
-
|
6
|
-
def setup
|
7
|
-
I18n::Keys.verbose = false
|
8
|
-
@filenames = %W( #{File.dirname(__FILE__)}/fixtures/source_1.rb
|
9
|
-
#{File.dirname(__FILE__)}/fixtures/source_2.rb )
|
10
|
-
@default_keys_root, Keys.root = Keys.root, File.expand_path(File.dirname(__FILE__)) + '/fixtures'
|
11
|
-
FileUtils.cp(@filenames[0], "#{@filenames[0]}.backup")
|
12
|
-
end
|
13
|
-
|
14
|
-
def teardown
|
15
|
-
Keys::Index.delete_all
|
16
|
-
Keys.root = @default_keys_root
|
17
|
-
FileUtils.mv("#{@filenames[0]}.backup", @filenames[0])
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_index_default_pattern
|
21
|
-
Keys.config = nil
|
22
|
-
assert_equal '/**/*.{rb,erb}', Keys::Index.new.pattern
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_index_finds_files
|
26
|
-
expected = %w(test/fixtures/source_1.rb test/fixtures/source_2.rb).map { |p| File.expand_path(p) }
|
27
|
-
assert_equal expected, Keys::Index.new.files & expected
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_occurences_built_lazily_on_a_fresh_index
|
31
|
-
index = Keys::Index.new(:default)
|
32
|
-
expected = [:bar, :baaar, :baar, :bar, :bar_1, :bar_2]
|
33
|
-
assert_equal expected, index.occurences.select { |key| expected.include?(key.key) }.map(&:key)
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_occurences_from_marshalled_index
|
37
|
-
index = Keys::Index.new(:marshalled)
|
38
|
-
index.update
|
39
|
-
index = Keys::Index.load(:marshalled)
|
40
|
-
expected = [:bar, :baaar, :baar, :bar, :bar_1, :bar_2]
|
41
|
-
assert_equal expected, index.occurences.select { |key| expected.include?(key.key) }.map(&:key)
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_index_create_builds_and_saves_the_index
|
45
|
-
index = Keys::Index.new(:create)
|
46
|
-
assert !index.exists?
|
47
|
-
index = Keys::Index.create(:create, :pattern => '/**/*.{rb}')
|
48
|
-
assert index.built?
|
49
|
-
assert index.exists?
|
50
|
-
assert_equal '/**/*.{rb}', index.pattern
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_index_load_or_create_creates_an_index
|
54
|
-
index = Keys::Index.load_or_create(:load_or_create, :pattern => '/**/*.{rb}')
|
55
|
-
assert index.exists?
|
56
|
-
assert_equal '/**/*.{rb}', index.pattern
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_index_load_or_create_or_init_with_no_name_given_does_not_save_the_index
|
60
|
-
index = Keys::Index.load_or_create_or_init(:pattern => '/**/*.{rb}')
|
61
|
-
assert !index.exists?
|
62
|
-
assert_equal '/**/*.{rb}', index.pattern
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_index_load_or_create_or_init_with_true_given_saves_the_default_index
|
66
|
-
index = Keys::Index.load_or_create_or_init(true, :pattern => '/**/*.{rb}')
|
67
|
-
assert index.exists?
|
68
|
-
assert_equal :default, index.name
|
69
|
-
assert_equal '/**/*.{rb}', index.pattern
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_index_load_or_create_or_init_with_name_given_saves_the_named_index
|
73
|
-
index = Keys::Index.load_or_create_or_init(:foo, :pattern => '/**/*.{rb}')
|
74
|
-
assert index.exists?
|
75
|
-
assert_equal :foo, index.name
|
76
|
-
assert_equal '/**/*.{rb}', index.pattern
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_index_exists_is_true_when_index_directory_exists
|
80
|
-
index = Keys::Index.create('foo')
|
81
|
-
assert index.exists?
|
82
|
-
FileUtils.rm_r(index.filename)
|
83
|
-
assert !index.exists?
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_index_inject_with_no_keys_given_iterates_over_all_occurences
|
87
|
-
index = Keys::Index.new(:pattern => '/**/*.{rb}')
|
88
|
-
expected = [:bar, :baaar, :baar, :'foo.bar', :bar, :bar_1, :bar_2]
|
89
|
-
result = index.inject([]) { |result, occurence| result << occurence.key }
|
90
|
-
assert_equal expected, result
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_index_inject_with_keys_given_iterates_over_occurences_of_given_keys
|
94
|
-
index = Keys::Index.new(:pattern => '/**/*.{rb}')
|
95
|
-
expected = [:bar, :baaar, :baar, :bar]
|
96
|
-
result = index.inject([], :bar, :baaar, :baar) { |result, occurence| result << occurence.key }
|
97
|
-
assert_equal expected, result
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_key_included_with_no_keys_given_returns_true
|
101
|
-
index = Keys::Index.new
|
102
|
-
assert index.send(:key_matches?, :foo, [])
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_key_included_with_the_key_included_returns_true
|
106
|
-
index = Keys::Index.new
|
107
|
-
assert index.send(:key_matches?, :foo, { :foo => /^foo$/, :bar => /^bar$/ })
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_key_pattern_with_no_wild_cards_returns_a_pattern_matching_only_the_key
|
111
|
-
index = Keys::Index.new
|
112
|
-
assert_equal /^foo\.bar$/, index.send(:key_pattern, :'foo.bar')
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_key_pattern_with_a_dot_separated_wild_card_at_the_end_returns_a_pattern_matching_all_keys_starting_with_key
|
116
|
-
index = Keys::Index.new
|
117
|
-
assert_equal /^foo\.bar\./, index.send(:key_pattern, :'foo.bar.*')
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_replace_replaces_key_without_wildcard_in_source_file
|
121
|
-
index = Keys::Index.create(:replace)
|
122
|
-
bar = index.by_key[:bar].first
|
123
|
-
index.replace!(bar, 'foo')
|
124
|
-
assert_equal " t(:foo)\n", bar.line
|
125
|
-
|
126
|
-
index = Keys::Index.load(:replace)
|
127
|
-
foo = index.by_key[:bar].first
|
128
|
-
assert foo == bar
|
129
|
-
end
|
130
|
-
|
131
|
-
# TODO
|
132
|
-
# - after replace make sure the index is updated
|
133
|
-
# - somehow also update the yaml/rb files
|
134
|
-
|
135
|
-
end
|
data/test/keys_test.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
class KeysTest < Test::Unit::TestCase
|
4
|
-
include I18n
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@filenames = %W( #{File.dirname(__FILE__)}/fixtures/source_1.rb
|
8
|
-
#{File.dirname(__FILE__)}/fixtures/source_2.rb )
|
9
|
-
@default_keys_root, Keys.root = Keys.root, File.expand_path(File.dirname(__FILE__))
|
10
|
-
end
|
11
|
-
|
12
|
-
def teardown
|
13
|
-
Keys::Index.delete_all
|
14
|
-
Keys.root = @default_keys_root
|
15
|
-
Keys.config = nil
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_root_defaults_to_dot
|
19
|
-
assert_equal '.', @default_keys_root
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_can_set_root
|
23
|
-
old_root = I18n::Keys.root
|
24
|
-
assert_nothing_raised { I18n::Keys.root = 'path/to/root' }
|
25
|
-
assert_equal 'path/to/root', I18n::Keys.root
|
26
|
-
I18n::Keys.root = old_root
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_index_given_no_name_returns_an_unbuilt_and_unsaved_index
|
30
|
-
index = Keys.index
|
31
|
-
assert_equal Keys::Index, index.class
|
32
|
-
assert !index.built?
|
33
|
-
assert !index.exists?
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_index_given_true_as_a_name_returns_the_built_default_index
|
37
|
-
index = Keys.index(true)
|
38
|
-
assert_equal Keys::Index, index.class
|
39
|
-
assert_equal :default, index.name
|
40
|
-
assert index.built?
|
41
|
-
assert index.exists?
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_index_given_a_regular_name_returns_the_built_named_index
|
45
|
-
index = Keys.index(:foo)
|
46
|
-
assert_equal Keys::Index, index.class
|
47
|
-
assert_equal :foo, index.name
|
48
|
-
assert index.built?
|
49
|
-
assert index.exists?
|
50
|
-
end
|
51
|
-
|
52
|
-
# def test_find_all_in_file
|
53
|
-
# expected = [:bar, :baaar, :baar, "bar", "bar_1"]
|
54
|
-
# keys = I18n::Keys.find(:files => @filenames[0])
|
55
|
-
# assert_equal expected, keys.select { |key| expected.include?(key.key) }.map(&:key)
|
56
|
-
# end
|
57
|
-
#
|
58
|
-
# def test_find_all_in_files
|
59
|
-
# expected = ['bar_1', :bar_2]
|
60
|
-
# keys = I18n::Keys.find(:files => @filenames)
|
61
|
-
# assert_equal expected, keys.select { |key| expected.include?(key.key) }.map(&:key)
|
62
|
-
# end
|
63
|
-
#
|
64
|
-
# def test_find_key_in_file
|
65
|
-
# expected = [:bar]
|
66
|
-
# keys = I18n::Keys.find(:keys => :bar, :files => @filenames[0])
|
67
|
-
# assert_equal expected, keys.select { |key| expected.include?(key.key) }.map(&:key)
|
68
|
-
# end
|
69
|
-
#
|
70
|
-
# def test_find_key_in_files
|
71
|
-
# expected = [:bar]
|
72
|
-
# keys = I18n::Keys.find(:keys => :bar, :files => @filenames)
|
73
|
-
# assert_equal expected, keys.select { |key| expected.include?(key.key) }.map(&:key)
|
74
|
-
# end
|
75
|
-
end
|
data/test/occurence_test.rb
DELETED
@@ -1,130 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
class OccurenceTest < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
I18n::Keys.verbose = false
|
6
|
-
end
|
7
|
-
|
8
|
-
def setup
|
9
|
-
I18n::Keys.verbose = false
|
10
|
-
@filename = "#{File.dirname(__FILE__)}/fixtures/source_1.rb"
|
11
|
-
FileUtils.cp(@filename, "#{@filename}.backup")
|
12
|
-
end
|
13
|
-
|
14
|
-
def teardown
|
15
|
-
FileUtils.mv("#{@filename}.backup", @filename)
|
16
|
-
end
|
17
|
-
|
18
|
-
def occurence(key = :bar)
|
19
|
-
index = I18n::Keys::Index.new
|
20
|
-
index.update
|
21
|
-
index.by_key[key.to_sym].first
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_line_without_highlighting
|
25
|
-
assert_equal " t(:'baar')\n", occurence(:baar).line
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_line_with_highlighting
|
29
|
-
assert_equal " t(\e[0;31;1m:'baar'\e[0m)\n", occurence(:baar).line(true)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_occurence_line_num
|
33
|
-
assert_equal 3, occurence.line_num
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_occurence_column
|
37
|
-
assert_equal 7, occurence.column
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_occurence_length
|
41
|
-
assert_equal 4, occurence.length
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_original_key
|
45
|
-
assert ":bar", occurence.original_key
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_content_head
|
49
|
-
assert_equal "def foo\n t(", occurence.content_head[-14, 999]
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_content_tail
|
53
|
-
assert_equal ")\n t(:\"baaar\")\n", occurence.content_tail[0, 18]
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_line_head
|
57
|
-
assert_equal " t(", occurence.line_head
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_line_tail
|
61
|
-
assert_equal ")\n", occurence.line_tail
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_context_returns_the_context_of_the_occurence_with_2_lines_setting
|
65
|
-
context = occurence(:baar).context.split("\n")
|
66
|
-
assert_equal 5, context.length
|
67
|
-
assert_equal " t(\e[0;31;1m:'baar'\e[0m)", context[2]
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_context_returns_the_context_of_the_occurence_with_3_lines_setting
|
71
|
-
I18n::Keys::Occurence.context_lines = 3
|
72
|
-
context = occurence(:baar).context.split("\n")
|
73
|
-
assert_equal 7, context.length
|
74
|
-
assert_equal " t(\e[0;31;1m:'baar'\e[0m)", context[3]
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_replace_simple_symbol_with_simple_symbol
|
78
|
-
bar = occurence(:bar)
|
79
|
-
bar.replace!(:oooooooo)
|
80
|
-
assert_equal " t(\e[0;31;1m:oooooooo\e[0m)\n", bar.line(true)
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_replace_simple_symbol_with_quoted_symbol
|
84
|
-
bar = occurence(:bar)
|
85
|
-
bar.replace!(:'oooo.oooo')
|
86
|
-
assert_equal " t(\e[0;31;1m:\"oooo.oooo\"\e[0m)\n", bar.line(true)
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_replace_simple_symbol_with_string
|
90
|
-
bar = occurence(:bar)
|
91
|
-
bar.replace!('oooooooo')
|
92
|
-
assert_equal " t(\e[0;31;1m:oooooooo\e[0m)\n", bar.line(true)
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_replace_quoted_symbol_with_simple_symbol
|
96
|
-
bar = occurence(:'foo.bar')
|
97
|
-
bar.replace!(:oooooooo)
|
98
|
-
assert_equal " t(\e[0;31;1m:oooooooo\e[0m)\n", bar.line(true)
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_replace_quoted_symbol_with_quoted_symbol
|
102
|
-
bar = occurence(:'foo.bar')
|
103
|
-
bar.replace!(:'oooo.oooo')
|
104
|
-
assert_equal " t(\e[0;31;1m:\"oooo.oooo\"\e[0m)\n", bar.line(true)
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_replace_quoted_symbol_with_string
|
108
|
-
bar = occurence(:'foo.bar')
|
109
|
-
bar.replace!('oooooooo')
|
110
|
-
assert_equal " t(\e[0;31;1m:oooooooo\e[0m)\n", bar.line(true)
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_replace_string_with_simple_symbol
|
114
|
-
bar = occurence('bar_1')
|
115
|
-
bar.replace!(:oooooooo)
|
116
|
-
assert_equal " t(\e[0;31;1m:oooooooo\e[0m)\n", bar.line(true)
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_replace_string_with_quoted_symbol
|
120
|
-
bar = occurence('bar_1')
|
121
|
-
bar.replace!(:'oooo.oooo')
|
122
|
-
assert_equal " t(\e[0;31;1m:\"oooo.oooo\"\e[0m)\n", bar.line(true)
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_replace_string_with_string
|
126
|
-
bar = occurence('bar_1')
|
127
|
-
bar.replace!('oooooooo')
|
128
|
-
assert_equal " t(\e[0;31;1m:oooooooo\e[0m)\n", bar.line(true)
|
129
|
-
end
|
130
|
-
end
|
data/test/ruby_parser_test.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
class RubyParserTest < Test::Unit::TestCase
|
4
|
-
def test_sexp_filename
|
5
|
-
filename = File.dirname(__FILE__) + '/fixtures/source_1.rb'
|
6
|
-
sexp = I18n::RubyParser.new.parse(File.read(filename), filename)
|
7
|
-
assert_equal filename, sexp.file
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_sexp_source_positions
|
11
|
-
assert_equal 2, 't(:foo)'.to_sexp.find_node(:lit).source_start_pos
|
12
|
-
assert_equal 5, 't(:foo)'.to_sexp.find_node(:lit).source_end_pos
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_sexp_source_symbol
|
16
|
-
assert_equal ':foo', 't(:foo)'.to_sexp.find_node(:lit).source
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_sexp_source_symbol_and_options
|
20
|
-
assert_equal ':foo', 't(:foo, :bar => :baz)'.to_sexp.find_node(:lit).source
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_sexp_source_symbol_with_double_quotes
|
24
|
-
assert_equal ':"foo"', 't(:"foo")'.to_sexp.find_node(:lit).source
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_sexp_source_symbol_with_double_quotes_and_options
|
28
|
-
assert_equal ':"foo"', 't(:"foo", :bar => :baz)'.to_sexp.find_node(:lit).source
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_sexp_source_symbol_with_single_quotes
|
32
|
-
assert_equal ":'foo'", "t(:'foo')".to_sexp.find_node(:lit).source
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_sexp_source_symbol_with_single_quotes_and_options
|
36
|
-
assert_equal ":'foo'", "t(:'foo', :bar => :baz)".to_sexp.find_node(:lit).source
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_sexp_source_string_with_double_quotes
|
40
|
-
assert_equal '"foo"', 't("foo")'.to_sexp.find_node(:str).source
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_sexp_source_string_with_double_quotes_and_options
|
44
|
-
assert_equal '"foo"', 't("foo", :bar => :baz)'.to_sexp.find_node(:str).source
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_sexp_source_string_with_single_quotes
|
48
|
-
assert_equal "'foo'", "t('foo')".to_sexp.find_node(:str).source
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_sexp_source_string_with_single_quotes_and_options
|
52
|
-
assert_equal "'foo'", "t('foo', :bar => :baz)".to_sexp.find_node(:str).source
|
53
|
-
end
|
54
|
-
end
|