babylonia 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ec84f550c2f0845d6b9a2b16ede6c04dcd8db75
4
- data.tar.gz: e181bce61c3a830c95017a9464577a602a3917e9
3
+ metadata.gz: 471b84c7ea7c5f3e6a22c69a64b74438b159480c
4
+ data.tar.gz: 3895c1969ff6a922574c66123a819211e849f60f
5
5
  SHA512:
6
- metadata.gz: bf514ab66051cf4c21a6068df9c2dba0bd6eeb41acddf838a32f03d4aae9a3ed6df0e990d05efab0560ecc09abe74a6f7c62006958edd3c458d9d8e011ea3346
7
- data.tar.gz: cdb741ec672ca3f50c4072193c1d392ff9240a5a8fda1e9d44ced1001dbbd84b1c383cd518a0eaf438081ab23c32801363ef5a2cde7623efadd889bfbbf6e996
6
+ metadata.gz: 960ef518e49a6a76ab9fd5ac1a1016123b9b3a10cba86c2fb646f7ad2cdd03d52b55cdd1ad474c5b36c2188efeead630c238bf21ca42135cd1bc73538c9f8090
7
+ data.tar.gz: 1a0d5661cc64f338b0d83fac5bf1d8f370e4c33a526c65c749cd5a59f64262d3e168626aea25af7c7c13d98c3f609c921ab473acba4168553d9eb3722ae9925f
@@ -66,6 +66,20 @@ Let's once assume a pretty basic class. Extend it with the Babylonian Class meth
66
66
  fallback: false #=> will not fallback to default locale if no translation for locale is present
67
67
  placeholder: "<span class='translation missing'>Translation missing in Transsylvania</span>" a placeholder if no translation is present
68
68
  end
69
+
70
+ == Neat Helpers
71
+ Got to have helpers to build that tower with: These come with every babylonian tower built:
72
+ t = Transsylvania.new
73
+ t.locale #=> returns the current locale
74
+ t.locales #=> returns every locale present in each(!) translated field
75
+ t.has_locale?(locale) #=> returns true if all(!) fields are translated in that locale
76
+ t.available_locales #=> returns the locales available for translation, but not necessarily present in each translated field
77
+ t.has_available_locale? #=> returns true if a locale is available for translation
78
+ t.default_locale #=> returns the current default locale
79
+ t.locale_fallback? #=> returns true if the translations will fall back to the default locale
80
+ t.missing_translation_placeholder(field) #=> Returns a placeholder for missing translation for field, if defined
81
+ t.localized?(attribute) #=> returns if attribute is localized
82
+
69
83
  == Contributing to babylonia
70
84
 
71
85
  Please note that only open source APIs can be accepted as contributions to this gem. Private / Premium APIs have to be written as your own extension and will not be added to the gem code.
@@ -11,50 +11,34 @@ module Babylonia
11
11
  # Class methods to extend a class with in order to make it able to handle translatable attributes
12
12
  #
13
13
  module ClassMethods
14
-
15
- private
16
-
17
- def add_to_handled_babylonian_fields data
18
- instance_variable_set(:@handled_babylonian_fields, (instance_variable_get(:@handled_babylonian_fields) || []) + data.map(&:to_sym))
19
- end
20
-
21
- public
22
- # Store all handled fields in a class instance variable
23
- #
24
- def handled_babylonian_fields
25
- instance_variable_get(:@handled_babylonian_fields) || instance_variable_set(:@handled_babylonian_fields, [])
26
- end
27
14
  # Main class method ob Babylonia. Use to make attributes translatable
28
15
  # @param [Symbol] fields the attributes to translate
29
16
  # @param [Hash] options The options for translation
30
- # @option [Symbol, Proc, String] locale The current locale - can be either a symbol that will be sent to the instance, a locale symbol that is included in available_locales or a proc that will get called with the instance and the attribute name. Defaults to I18n.locale at the time of use
31
- # @option [Symbol, Proc, String] default_locale The fallback / default locale - can be either a symbol that will be sent to the instance, a locale symbol that is included in available_locales, a proc that will get called with the instance and the attribute name
32
- # @option [Symbol, Proc, Array] available_locales The available locales - can be either a symbol that will be sent to the instance, a proc that will get called with the instance and the attribute name, or an Array of symbols of available locales. Defaults to I18n.available_locales at the time of use.
17
+ # @option [Symbol, Proc, String] locale The current locale - can be either a symbol that will be sent to the instance, a locale symbol that is included in available_locales or a proc that will get called with the instance. Defaults to I18n.locale at the time of use
18
+ # @option [Symbol, Proc, String] default_locale The fallback / default locale - can be either a symbol that will be sent to the instance, a locale symbol that is included in available_locales, a proc that will get called with the instance
19
+ # @option [Symbol, Proc, Array] available_locales The available locales - can be either a symbol that will be sent to the instance, a proc that will get called with the instance, or an Array of symbols of available locales. Defaults to I18n.available_locales at the time of use.
33
20
  # @option [Boolean] fallback Wheter to fallback to the default locale or not
34
21
  # @option [String] placeholder The placeholder to use for missing translations
35
22
  #
36
23
  def build_babylonian_tower_on(*fields)
37
- babylonian_options = fields.last.is_a?(Hash) ? fields.pop : {}
38
- add_to_handled_babylonian_fields fields
39
- babylonian_options[:locale] ||= lambda { |r, f| I18n.locale }
40
- babylonian_options[:default_locale] ||= lambda { |r, f| I18n.default_locale }
41
- babylonian_options[:available_locales] ||= lambda { |r, f| I18n.available_locales }
42
- babylonian_options[:fallback] = true if babylonian_options[:fallback].nil?
24
+ options = fields.last.is_a?(Hash) ? fields.pop : {}
25
+ options[:locale] ||= lambda { |r| I18n.locale }
26
+ options[:default_locale] ||= lambda { |r| I18n.default_locale }
27
+ options[:available_locales] ||= lambda { |r| I18n.available_locales }
28
+ options[:fallback] = true if options[:fallback].nil?
43
29
 
44
30
  fields.each do |field|
45
- instance_variable_set(:"@babylonian_options_for_#{field}", babylonian_options)
46
-
47
31
  # Alias method chain the field to a translated value
48
32
  # @param [Symbol] locale Pass a locale to get the field translation in this specific locale
49
33
  # @return [String, NilClass] Either the string with the translation, the fallback, the placeholder or nil
50
34
  # @example Call a field in italian
51
35
  # your_instance.field(:it) #=> "Translation"
52
36
  #
53
- define_method :"#{field}_translated" do |locale=nil|
37
+ define_method :"#{field}_translated" do |l=nil|
54
38
  field_hash = send(:"#{field}_hash")
55
- translation = field_hash[locale || evaluate_babylonian_option!(:locale, field)]
56
- translation = field_hash[evaluate_babylonian_option!(:default_locale, field)] if (translation.nil? or translation.empty?) and evaluate_babylonian_option!(:fallback, field)
57
- (translation.nil? or translation.empty?) ? evaluate_babylonian_option!(:placeholder, field) : translation
39
+ translation = field_hash[l || locale]
40
+ translation = field_hash[default_locale] if translation.nil? or translation.empty? and locale_fallback?
41
+ (translation.nil? or translation.empty?) ? missing_translation_placeholder(field) : translation
58
42
  end
59
43
  alias_method :"#{field}_raw", field
60
44
  alias_method field, :"#{field}_translated"
@@ -67,31 +51,6 @@ module Babylonia
67
51
  field_content.is_a?(String) ? YAML.load(field_content) : {}
68
52
  end
69
53
 
70
- # Return all the languages stored
71
- # @return [Array] An array containing all languages stored in the field
72
- #
73
- define_method :"#{field}_languages" do
74
- send(:"#{field}_hash").keys
75
- end
76
-
77
- define_method :has_translated_attribute? do |attr|
78
- self.class.handled_babylonian_fields.include?(attr.to_sym)
79
- end
80
-
81
- # Return if a translation in the language is stored for the field
82
- # @return [Boolean] True if a translation is stored
83
- #
84
- define_method :"#{field}_has_locale?" do |locale|
85
- send(:"#{field}_languages").include?(locale.to_sym)
86
- end
87
-
88
- # Return if a locale is theoretically available for the field
89
- # @return [Boolean] True if the language is available
90
- #
91
- define_method :"#{field}_has_available_locale?" do |locale|
92
- evaluate_babylonian_option!(:available_locales, field).include?(locale.to_sym)
93
- end
94
-
95
54
  # Set the field to a value. This either takes a string or a hash
96
55
  # If given a String, the current locale is set to this value
97
56
  # If given a Hash, the hash is merged into the current translation hash, and empty values are purged
@@ -105,34 +64,100 @@ module Babylonia
105
64
  current_hash = send(:"#{field}_hash")
106
65
 
107
66
  if data.is_a?(String)
108
- current_hash.merge! evaluate_babylonian_option!(:locale, field) => data
67
+ current_hash.merge! locale => data
109
68
  elsif data.is_a?(Hash)
110
- data.delete_if{|k,v| !send(:"#{field}_has_available_locale?", k) }
69
+ data.delete_if{|k,v| !has_available_locale?(k) }
111
70
  current_hash.merge! data
112
71
  end
113
72
 
114
- send(:"#{field}_raw=", YAML.dump(current_hash.delete_if{|k,v| v.nil? || v.empty? }))
73
+ send(:"#{field}_raw=", YAML.dump(current_hash.delete_if{|k,v| v.nil? or v.empty? }))
115
74
  end
116
75
  alias_method :"#{field}_raw=", :"#{field}="
117
76
  alias_method :"#{field}=", :"#{field}_translated="
118
77
  end
119
78
 
79
+ # Return the currently active locale for the object
80
+ # @return [Symbol] The currently active locale
81
+ #
82
+ define_method :locale do
83
+ evaluate_localization_option!(:locale)
84
+ end
85
+
86
+ # Return the default locale for the object
87
+ # @return [Symbol] The currently active locale
88
+ #
89
+ define_method :default_locale do
90
+ evaluate_localization_option!(:default_locale)
91
+ end
92
+
93
+ # Return if the object falls back on translations
94
+ # @return [Boolean] if the translations fall back to the default locale
95
+ #
96
+ define_method :locale_fallback? do
97
+ evaluate_localization_option!(:fallback)
98
+ end
99
+
100
+ # Return the missing translation placeholder
101
+ # @return [String] The missing translation placeholder
102
+ #
103
+ define_method :missing_translation_placeholder do |field|
104
+ evaluate_localization_option!(:placeholder, field)
105
+ end
106
+
107
+ # Return languages stored in all translated fields
108
+ # @return [Array] An array containing all languages stored
109
+ #
110
+ define_method :locales do
111
+ first_field_locales = send(:"#{fields.first}_hash").keys
112
+ fields.inject(first_field_locales){|o, f| o & send(:"#{f}_hash").keys }
113
+ end
114
+
115
+ # Return if a translation in the language is stored in all translated fields
116
+ # @return [Boolean] True if a translation is stored
117
+ #
118
+ define_method :has_locale? do |locale|
119
+ locales.include?(locale.to_sym)
120
+ end
121
+
122
+ # Return all the available locales
123
+ # @return [Array] An array of symbols of all available locales
124
+ #
125
+ define_method :available_locales do
126
+ evaluate_localization_option!(:available_locales)
127
+ end
128
+
129
+ # Return if a locale is theoretically available in all translated fields
130
+ # @return [Boolean] True if the language is available
131
+ #
132
+ define_method :has_available_locale? do |locale|
133
+ available_locales.include?(locale.to_sym)
134
+ end
135
+
136
+ # Return if an attribute is localized
137
+ # @return [Boolean] True if the attribute is localized
138
+ #
139
+ define_method :localized? do |attr|
140
+ fields.include?(attr.to_sym)
141
+ end
142
+
120
143
  # Define method missing to be able to access a language directly
121
144
  define_method :method_missing do |meth, *args, &block|
122
- if (m = meth.to_s.match(/\A([^_]+)_(\w+)(=)?\z/).to_a[1..3]) && has_translated_attribute?(m[0]) && send(:"#{m[0]}_has_available_locale?", m[1])
145
+ if (m = meth.to_s.match(/\A([^_]+)_(\w+)(=)?\z/).to_a[1..3]) && localized?(m[0]) && has_available_locale?(m[1])
123
146
  send(m[0] + m[2].to_s, m[2] ? {m[1].to_sym => args.first} : m[1].to_sym)
124
147
  else
125
148
  super(meth, *args, &block)
126
149
  end
127
150
  end
128
151
 
129
- define_method :evaluate_babylonian_option! do |option, field, recursion=false|
130
- options = self.class.instance_variable_get :"@babylonian_options_for_#{field}"
131
-
152
+ # Evaluate a localization option
153
+ #
154
+ define_method :evaluate_localization_option! do |option, field=nil, recursion=false|
132
155
  o = options[option]
133
- if o.is_a?(Proc)
156
+ if o.is_a?(Proc) && field
134
157
  o.call self, field
135
- elsif o.is_a?(Symbol) && (recursion || !evaluate_babylonian_option!(:available_locales, field, true).include?(o))
158
+ elsif o.is_a?(Proc)
159
+ o.call self
160
+ elsif o.is_a?(Symbol) && (recursion || !evaluate_localization_option!(:available_locales, nil, true).include?(o))
136
161
  send o
137
162
  else
138
163
  o
@@ -1,5 +1,5 @@
1
1
  module Babylonia
2
2
  # The current gem version
3
3
  #
4
- VERSION = '0.0.3'
4
+ VERSION = '0.1.0'
5
5
  end
@@ -1,27 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Babylonia::ClassMethods do
4
-
5
- class BabylonianFields
6
- extend Babylonia::ClassMethods
3
+ describe Babylonia::ClassMethods do
4
+ context "without options" do
5
+ subject { BabylonianFields.new }
6
+ class BabylonianFields
7
+ extend Babylonia::ClassMethods
7
8
 
8
- attr_accessor :marshes, :grasslands, :desert, :sky
9
+ attr_accessor :marshes, :sky
9
10
 
10
- build_babylonian_tower_on :marshes
11
- build_babylonian_tower_on :grasslands, available_locales: [:pi, :de, :en, :it], locale: :architects_tongue, default_locale: lambda {|r, f| r.builders_tongue || :en }
12
- build_babylonian_tower_on :desert, :sky, fallback: false, placeholder: lambda {|r, field| "<span class='missing translation'>Translation missing for " + field.to_s + "</span>"}
13
-
14
- def architects_tongue
15
- :pi
11
+ build_babylonian_tower_on :marshes, :sky
16
12
  end
17
13
 
18
- def builders_tongue
19
- nil
20
- end
21
- end
22
-
23
- context "without options" do
24
- subject { BabylonianFields.new }
25
14
  before(:each) do
26
15
  I18n.stub locale: :en, default_locale: :de, available_locales: [:de, :en, :it]
27
16
  end
@@ -116,7 +105,7 @@ describe Babylonia::ClassMethods do
116
105
  end
117
106
  end
118
107
  end
119
- describe "marshes=" do
108
+ describe "#marshes=" do
120
109
  context "with no existing data" do
121
110
  context "with a string" do
122
111
  it "should set the current locales data" do
@@ -157,7 +146,7 @@ describe Babylonia::ClassMethods do
157
146
  end
158
147
  end
159
148
  end
160
- describe "marshes_hash" do
149
+ describe "#marshes_hash" do
161
150
  before(:each) do
162
151
  subject.marshes_raw = "---\n:it: SOME ITALIAN\n:en: SOME ENGLISH\n:de: SOME DEUTSCH\n"
163
152
  end
@@ -165,26 +154,109 @@ describe Babylonia::ClassMethods do
165
154
  subject.marshes_hash.should == {it: 'SOME ITALIAN', en: 'SOME ENGLISH', de: 'SOME DEUTSCH'}
166
155
  end
167
156
  end
168
- describe "marshes_languages" do
157
+ describe "#locales" do
169
158
  before(:each) do
170
159
  subject.marshes_raw = "---\n:it: SOME ITALIAN\n:en: SOME ENGLISH\n:de: SOME DEUTSCH\n"
160
+ subject.sky_raw = "---\n:it: SOME ITALIAN\n:en: SOME ENGLISH\n:de: SOME DEUTSCH\n"
171
161
  end
172
162
  it "should return the translated languages of the field" do
173
- subject.marshes_languages.sort.should == [:de, :en, :it]
163
+ subject.locales.sort.should == [:de, :en, :it]
164
+ end
165
+ end
166
+ describe "#has_locale?" do
167
+ before(:each) do
168
+ subject.marshes_raw = "---\n:it: SOME ITALIAN\n:en: SOME ENGLISH\n:de: SOME DEUTSCH\n"
169
+ subject.sky_raw = "---\n:it: SOME ITALIAN\n:en: SOME ENGLISH\n:de: SOME DEUTSCH\n"
170
+ end
171
+ context "with the locale present in the translation hashes" do
172
+ it "should return true" do
173
+ subject.should be_has_locale(:it)
174
+ end
175
+ end
176
+ context "with the locale not present in the translation hashes" do
177
+ it "should return true" do
178
+ subject.should_not be_has_locale(:pi)
179
+ end
180
+ end
181
+ end
182
+ describe "#available_locales" do
183
+ before(:each) do
184
+ I18n.stub available_locales: [:de, :en]
185
+ end
186
+ it "should return available locales" do
187
+ subject.available_locales.sort.should == [:de, :en]
188
+ end
189
+ end
190
+ describe "#has_available_locale" do
191
+ before(:each) do
192
+ I18n.stub available_locales: [:de, :en]
193
+ end
194
+ context "with an available locale" do
195
+ it "should return true" do
196
+ subject.should be_has_available_locale(:de)
197
+ end
198
+ end
199
+ context "with an available locale" do
200
+ it "should return true" do
201
+ subject.should_not be_has_available_locale(:it)
202
+ end
203
+ end
204
+ end
205
+ describe "#localized?" do
206
+ context "with a localized attribute" do
207
+ it "should return true" do
208
+ subject.should be_localized(:sky)
209
+ end
210
+ end
211
+ context "with a unlocalized attribute" do
212
+ it "should return true" do
213
+ subject.should_not be_localized(:desert)
214
+ end
215
+ end
216
+ end
217
+ describe "#missing_translation_placeholder" do
218
+ it "should return nil" do
219
+ subject.missing_translation_placeholder('FIELD').should be_nil
220
+ end
221
+ end
222
+ describe "#locale_fallback?" do
223
+ it "should return false" do
224
+ subject.should be_locale_fallback
174
225
  end
175
226
  end
176
227
  end
177
228
 
178
- context "with options" do
179
- subject { BabylonianFields.new }
229
+ context "with options opposite the defaults" do
230
+ class BabylonianFieldsWithOptions
231
+ extend Babylonia::ClassMethods
232
+
233
+ attr_accessor :grasslands, :desert
234
+
235
+ build_babylonian_tower_on :grasslands, :desert,
236
+ available_locales: [:pi, :de, :en, :it],
237
+ locale: :architects_tongue,
238
+ default_locale: lambda {|r| r.builders_tongue || :en },
239
+ fallback: false,
240
+ placeholder: lambda {|r, field| "<span class='missing translation'>Translation missing for " + field.to_s + "</span>"}
241
+
242
+ def architects_tongue
243
+ :pi
244
+ end
245
+
246
+ def builders_tongue
247
+ nil
248
+ end
249
+ end
250
+
251
+ subject { BabylonianFieldsWithOptions.new }
180
252
  before(:each) do
181
253
  I18n.stub locale: :en, default_locale: :de
182
254
  end
183
255
 
184
256
  describe "#grasslands" do
185
257
  context "with no data" do
186
- it "should return nil" do
187
- subject.grasslands.should be_nil
258
+ it "should return the placeholder" do
259
+ subject.grasslands.should == "<span class='missing translation'>Translation missing for grasslands</span>"
188
260
  end
189
261
  end
190
262
  context "with some raw data" do
@@ -204,12 +276,12 @@ describe Babylonia::ClassMethods do
204
276
  before(:each) do
205
277
  subject.stub grasslands_raw: "---\n:en: FALLBACK"
206
278
  end
207
- it "should return the fallback data" do
208
- subject.grasslands.should == "FALLBACK"
279
+ it "should not return the fallback data" do
280
+ subject.grasslands.should == "<span class='missing translation'>Translation missing for grasslands</span>"
209
281
  end
210
282
  context "with a locale argument" do
211
- it "should return the fallback" do
212
- subject.grasslands(:pi).should == 'FALLBACK'
283
+ it "should return the not return the fallback" do
284
+ subject.grasslands(:pi).should == "<span class='missing translation'>Translation missing for grasslands</span>"
213
285
  end
214
286
  end
215
287
  end
@@ -218,11 +290,11 @@ describe Babylonia::ClassMethods do
218
290
  subject.stub grasslands_raw: "---\n:it: NO_FALLBACK"
219
291
  end
220
292
  it "should return the fallback data" do
221
- subject.grasslands.should be_nil
293
+ subject.grasslands.should == "<span class='missing translation'>Translation missing for grasslands</span>"
222
294
  end
223
295
  context "with a locale argument" do
224
296
  it "should return the fallback" do
225
- subject.grasslands(:en).should be_nil
297
+ subject.grasslands(:en).should == "<span class='missing translation'>Translation missing for grasslands</span>"
226
298
  end
227
299
  end
228
300
  end
@@ -283,31 +355,93 @@ describe Babylonia::ClassMethods do
283
355
  context "with a string" do
284
356
  it "should be deleted" do
285
357
  subject.grasslands = ''
286
- subject.grasslands.should be_nil
358
+ subject.grasslands.should == "<span class='missing translation'>Translation missing for grasslands</span>"
287
359
  end
288
360
  end
289
361
  context "with nil" do
290
362
  it "should be deleted" do
291
363
  subject.grasslands = nil
292
- subject.grasslands.should be_nil
364
+ subject.grasslands.should == "<span class='missing translation'>Translation missing for grasslands</span>"
293
365
  end
294
366
  end
295
367
  context "with a hash containing an empty string" do
296
368
  it "should be deleted" do
297
369
  subject.grasslands = {it: ''}
298
- subject.grasslands(:it).should be_nil
370
+ subject.grasslands(:it).should == "<span class='missing translation'>Translation missing for grasslands</span>"
299
371
  end
300
372
  end
301
373
  context "with a hash containing nil" do
302
374
  it "should be deleted" do
303
375
  subject.grasslands = {it: nil}
304
- subject.grasslands(:it).should be_nil
376
+ subject.grasslands(:it).should == "<span class='missing translation'>Translation missing for grasslands</span>"
305
377
  end
306
378
  end
307
379
  end
308
380
  end
309
381
  end
382
+ describe "#locales" do
383
+ before(:each) do
384
+ subject.grasslands_raw = "---\n:it: SOME ITALIAN\n:en: SOME ENGLISH\n:de: SOME DEUTSCH\n"
385
+ subject.desert_raw = "---\n:it: SOME ITALIAN\n:en: SOME ENGLISH\n:de: SOME DEUTSCH\n"
386
+ end
387
+ it "should return the translated languages of the field" do
388
+ subject.locales.sort.should == [:de, :en, :it]
389
+ end
390
+ end
391
+ describe "#has_locale?" do
392
+ before(:each) do
393
+ subject.grasslands_raw = "---\n:it: SOME ITALIAN\n:en: SOME ENGLISH\n:de: SOME DEUTSCH\n"
394
+ subject.desert_raw = "---\n:it: SOME ITALIAN\n:en: SOME ENGLISH\n:de: SOME DEUTSCH\n"
395
+ end
396
+ context "with the locale present in the translation hashes" do
397
+ it "should return true" do
398
+ subject.should be_has_locale(:it)
399
+ end
400
+ end
401
+ context "with the locale not present in the translation hashes" do
402
+ it "should return true" do
403
+ subject.should_not be_has_locale(:pi)
404
+ end
405
+ end
406
+ end
407
+ describe "#available_locales" do
408
+ it "should return available locales" do
409
+ subject.available_locales.sort.should == [:de, :en, :it, :pi]
410
+ end
411
+ end
412
+ describe "#has_available_locale" do
413
+ context "with an available locale" do
414
+ it "should return true" do
415
+ subject.should be_has_available_locale(:pi)
416
+ end
417
+ end
418
+ context "with an available locale" do
419
+ it "should return true" do
420
+ subject.should_not be_has_available_locale(:gb)
421
+ end
422
+ end
423
+ end
424
+ describe "#localized?" do
425
+ context "with a localized attribute" do
426
+ it "should return true" do
427
+ subject.should be_localized(:grasslands)
428
+ end
429
+ end
430
+ context "with a unlocalized attribute" do
431
+ it "should return true" do
432
+ subject.should_not be_localized(:fields)
433
+ end
434
+ end
435
+ end
436
+ describe "#missing_translation_placeholder" do
437
+ it "should return the defined placeholder for the field" do
438
+ subject.missing_translation_placeholder('FIELD').should == "<span class='missing translation'>Translation missing for FIELD</span>"
439
+ end
440
+ end
441
+ describe "#locale_fallback?" do
442
+ it "should return false" do
443
+ subject.should_not be_locale_fallback
444
+ end
445
+ end
310
446
  end
311
-
312
-
313
447
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: babylonia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beat Richartz