gettext_i18n_rails 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,91 +0,0 @@
1
- require "spec_helper"
2
-
3
- FastGettext.silence_errors
4
-
5
- describe GettextI18nRails do
6
- before do
7
- GettextI18nRails.translations_are_html_safe = nil
8
- end
9
-
10
- it "extends all classes with fast_gettext" do
11
- _('test')
12
- end
13
-
14
- describe 'translations_are_html_safe' do
15
- before do
16
- GettextI18nRails.translations_are_html_safe = nil
17
- end
18
-
19
- it "makes translations not html_safe by default" do
20
- _('x').html_safe?.should == false
21
- s_('x').html_safe?.should == false
22
- n_('x','y',2).html_safe?.should == false
23
- String._('x').html_safe?.should == false
24
- String.s_('x').html_safe?.should == false
25
- String.n_('x','y',2).html_safe?.should == false
26
- end
27
-
28
- it "makes instance translations html_safe when wanted" do
29
- GettextI18nRails.translations_are_html_safe = true
30
- _('x').html_safe?.should == true
31
- s_('x').html_safe?.should == true
32
- n_('x','y',2).html_safe?.should == true
33
- end
34
-
35
- it "makes class translations html_safe when wanted" do
36
- GettextI18nRails.translations_are_html_safe = true
37
- String._('x').html_safe?.should == true
38
- String.s_('x').html_safe?.should == true
39
- String.n_('x','y',2).html_safe?.should == true
40
- end
41
-
42
- it "does not make everything html_safe" do
43
- 'x'.html_safe?.should == false
44
- end
45
- end
46
-
47
- it "sets up out backend" do
48
- I18n.backend.is_a?(GettextI18nRails::Backend).should be_true
49
- end
50
-
51
- it "has a VERSION" do
52
- GettextI18nRails::VERSION.should =~ /^\d+\.\d+\.\d+$/
53
- end
54
-
55
- describe 'FastGettext I18n interaction' do
56
- before do
57
- FastGettext.available_locales = nil
58
- FastGettext.locale = 'de'
59
- end
60
-
61
- it "links FastGettext with I18n locale" do
62
- FastGettext.locale = 'xx'
63
- I18n.locale.should == :xx
64
- end
65
-
66
- it "does not set an not-accepted locale to I18n.locale" do
67
- FastGettext.available_locales = ['de']
68
- FastGettext.locale = 'xx'
69
- I18n.locale.should == :de
70
- end
71
-
72
- it "links I18n.locale and FastGettext.locale" do
73
- I18n.locale = :yy
74
- FastGettext.locale.should == 'yy'
75
- end
76
-
77
- it "does not set a non-available locale though I18n.locale" do
78
- FastGettext.available_locales = ['de']
79
- I18n.locale = :xx
80
- FastGettext.locale.should == 'de'
81
- I18n.locale.should == :de
82
- end
83
-
84
- it "converts gettext to i18n style for nested locales" do
85
- FastGettext.available_locales = ['de_CH']
86
- I18n.locale = :"de-CH"
87
- FastGettext.locale.should == 'de_CH'
88
- I18n.locale.should == :"de-CH"
89
- end
90
- end
91
- end
data/spec/spec_helper.rb DELETED
@@ -1,112 +0,0 @@
1
- require 'rubygems'
2
-
3
- $LOAD_PATH << File.expand_path("../lib", File.dirname(__FILE__))
4
-
5
- require 'active_support/version'
6
- if RUBY_VERSION > "2" && ActiveSupport::VERSION::MAJOR == 2
7
- warn "Not running ruby 2 vs rails 2 tests"
8
- exit 0
9
- end
10
-
11
- require 'tempfile'
12
- require 'active_support'
13
- require 'active_record'
14
- require 'action_controller'
15
- require 'action_mailer'
16
- require 'fast_gettext'
17
- require 'gettext_i18n_rails'
18
- require 'temple'
19
-
20
- begin
21
- Gem.all_load_paths
22
- rescue
23
- puts "Fixing Gem.all_load_paths"
24
- module Gem;def self.all_load_paths;[];end;end
25
- end
26
-
27
-
28
- # make temple not blow up in rails 2 env
29
- class << Temple::Templates
30
- alias_method :method_missing_old, :method_missing
31
- def method_missing(name, engine, options = {})
32
- name == :Rails || method_missing_old(name, engine, options)
33
- end
34
- end
35
-
36
- module Rails
37
- def self.root
38
- File.dirname(__FILE__)
39
- end
40
- end
41
-
42
- def with_file(content)
43
- Tempfile.open('gettext_i18n_rails_specs') do |f|
44
- f.write(content)
45
- f.close
46
- yield f.path
47
- end
48
- end
49
-
50
- ActiveRecord::Base.establish_connection(
51
- :adapter => "sqlite3",
52
- :database => ":memory:"
53
- )
54
-
55
- ActiveRecord::Schema.define(:version => 1) do
56
- create_table :car_seats, :force=>true do |t|
57
- t.string :seat_color
58
- end
59
-
60
- create_table :parts, :force=>true do |t|
61
- t.string :name
62
- t.references :car_seat
63
- end
64
-
65
- create_table :not_at_all_conventionals, :force=>true do |t|
66
- t.string :name
67
- end
68
-
69
- create_table :sti_parents, :force => true do |t|
70
- t.string :type
71
- t.string :child_attribute
72
- end
73
-
74
- create_table :concrete_child_classes, :force => true do |t|
75
- t.string :child_attribute
76
- end
77
-
78
- create_table :other_concrete_child_classes, :force => true do |t|
79
- t.string :another_child_attribute
80
- end
81
- end
82
-
83
- class CarSeat < ActiveRecord::Base
84
- validates_presence_of :seat_color, :message=>"translate me"
85
- has_many :parts
86
- accepts_nested_attributes_for :parts
87
- end
88
-
89
- class Part < ActiveRecord::Base
90
- belongs_to :car_seat
91
- end
92
-
93
- class StiParent < ActiveRecord::Base; end
94
- class StiChild < StiParent; end
95
-
96
- class AbstractParentClass < ActiveRecord::Base
97
- self.abstract_class = true
98
- end
99
- class ConcreteChildClass < AbstractParentClass; end
100
- class OtherConcreteChildClass < AbstractParentClass; end
101
-
102
- class NotConventional < ActiveRecord::Base
103
- if ActiveRecord::VERSION::MAJOR == 2
104
- set_table_name :not_at_all_conventionals
105
- else
106
- self.table_name = :not_at_all_conventionals
107
- end
108
- end
109
-
110
- class Idea < ActiveRecord::Base
111
- self.abstract_class = true
112
- end