Module: Localite::Scope::Etest

Defined in:
lib/localite/scope.rb

Constant Summary collapse

Scopes =
Localite::Scope::Scopes

Instance Method Summary collapse

Instance Method Details

#test_empty_scopesObject



125
126
127
128
129
130
131
# File 'lib/localite/scope.rb', line 125

def test_empty_scopes
  r = []
  Localite.scopes.each("str.y") do |scoped|
    r << scoped
  end
  assert_equal %w(str.y), r
end

#test_modiObject



133
134
135
136
137
138
139
# File 'lib/localite/scope.rb', line 133

def test_modi
  assert_equal "abc", "param".t(:xxx => "abc")
  assert_equal "a > c", "param".t(:xxx => "a > c")
  assert_equal "a > c", Localite.text { "param".t(:xxx => "a > c") }
  assert_equal "a &gt; c", Localite.html { "param".t(:xxx => "a > c") }
  assert_equal "a > c", "param".t(:xxx => "a > c")
end

#test_more_scopesObject



105
106
107
108
109
110
111
112
113
# File 'lib/localite/scope.rb', line 105

def test_more_scopes
  Localite.scope("a", :b, "b") do 
    r = []
    Localite.scopes.each("str") do |scoped|
      r << scoped
    end
    assert_equal %w(a.b.b.str a.b.str a.str str), r
  end
end

#test_more_scopes_w_dotsObject



115
116
117
118
119
120
121
122
123
# File 'lib/localite/scope.rb', line 115

def test_more_scopes_w_dots
  Localite.scope("a", :b, "b.c.d") do 
    r = []
    Localite.scopes.each("str.y") do |scoped|
      r << scoped
    end
    assert_equal %w(a.b.b.c.d.str.y a.b.str.y a.str.y str.y), r
  end
end

#test_scopeObject



90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/localite/scope.rb', line 90

def test_scope
  scope = Scopes.new
  scope.exec("a") do 
    scope.exec("b") do 
      scope.exec("b") do 
        r = []
        scope.each("str") do |scoped|
          r << scoped
        end
        assert_equal %w(a.b.b.str a.b.str a.str str), r
      end
    end
  end
end