lolita-i18n 0.5.6 → 0.5.7

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: 6dbd5a79aef20c66bcdc9f27d4d85fb01f8720a7
4
- data.tar.gz: 8a3eba1f6b433de69dd7c2b25a147d6ab28ac78e
3
+ metadata.gz: f500d667490e09464baaa16c0e26b6583c375064
4
+ data.tar.gz: 5a4fcd9e2cff8e7d718fb649ac27940da5ac7517
5
5
  SHA512:
6
- metadata.gz: f1b3bed0c85e87f7626aa02c0b0fd0beab631319aef7d15ab86c9bb3d3d8dce195a3fe7ab9ae3f08e1d3a004d46076acd2e27ca8a9401e8e0906fc34fdee164a
7
- data.tar.gz: 06c40619addc9ccaff3f9703c1b30f3c97fb5d7cdaa9cd60a5df5b294d5fb2591de85edd360555876885e4a6759e8886bbab512c2b2ea7373357e5427aeb5731
6
+ metadata.gz: a223a81628cde28509ba332550755f55a2be4c7168a20c779508af178d68cb3ac5880e2426ee941b14c38ad4560567f6c386c2be6273c668178af3d7dc56db19
7
+ data.tar.gz: ae6b940f0014e20deaa3637229da21d56f9e9dde966083868001a3df40bd3244119710639a18ad9bd010c319b11bdd93e32b25ab8b20d6b6f711493f7f8f1681
data/Gemfile CHANGED
@@ -5,12 +5,13 @@ gemspec
5
5
  group :test do
6
6
  gem 'byebug'
7
7
  gem 'rails', '~> 3.2.0'
8
+ gem 'lolita', '~> 4.0'
8
9
  gem 'simplecov', '~> 0.7.1'
9
10
  gem 'bson_ext', '~> 1.10.1'
10
11
  gem 'mongoid', '~> 2.7.1'
11
12
  gem 'rspec-rails', '~> 2.14'
12
13
  gem 'capybara', '~> 2.1'
13
- gem 'selenium-webdriver', '~> 2.41.0'
14
+ gem 'selenium-webdriver'
14
15
  gem 'sass', '~> 3.2.3'
15
16
  gem 'coffee-script', '~>2.2.0'
16
17
  gem 'axlsx', '~> 2.0.1'
data/LICENSE.txt CHANGED
@@ -1,20 +1,20 @@
1
- Copyright (c) 2011 ITHouse (Latvia) and Arturs Meisters
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2011 ITHouse (Latvia) and Arturs Meisters
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -4,6 +4,7 @@ en:
4
4
  ru: Russian
5
5
  de: German
6
6
  sv: Swedish
7
+ sv_SE: Swedish
7
8
  lt: Lithuanian
8
9
  ee: Estonian
9
10
  lolita-i18n:
@@ -4,6 +4,7 @@ lv:
4
4
  ru: Krievu
5
5
  de: Vācu
6
6
  sv: Zviedru
7
+ sv_SE: Zviedru
7
8
  lt: Lietuviešu
8
9
  ee: Igauņu
9
10
  lolita-i18n:
@@ -1,7 +1,7 @@
1
1
  module Lolita
2
2
  module I18n
3
3
  class Version
4
- VERSION = "0.5.6"
4
+ VERSION = "0.5.7"
5
5
 
6
6
  def self.to_s
7
7
  VERSION
data/lolita-i18n.gemspec CHANGED
@@ -18,13 +18,13 @@ Gem::Specification.new do |s|
18
18
  ]
19
19
  s.licenses = ["MIT"]
20
20
 
21
- s.add_runtime_dependency(%q<lolita>, ["~> 3.2"])
21
+ s.add_runtime_dependency(%q<lolita>, [">= 3.2"])
22
22
  s.add_runtime_dependency(%q<i18n>, ["~> 0.6.1"])
23
- s.add_runtime_dependency(%q<hiredis>, ["~> 0.4.5"])
24
- s.add_runtime_dependency(%q<redis>, ["~> 3.0.3"])
25
- s.add_runtime_dependency(%q<yajl-ruby>,["~> 1.1.0"])
26
- s.add_runtime_dependency(%q<unicode_utils>,["~> 1.4.0"])
27
- s.add_runtime_dependency(%q<axlsx>,["~> 2.0.1"])
23
+ s.add_runtime_dependency(%q<hiredis>, ["~> 0.4"])
24
+ s.add_runtime_dependency(%q<redis>, ["~> 3.0"])
25
+ s.add_runtime_dependency(%q<yajl-ruby>,["~> 1.1"])
26
+ s.add_runtime_dependency(%q<unicode_utils>,["~> 1.4"])
27
+ s.add_runtime_dependency(%q<axlsx>,["~> 2.0"])
28
28
  s.files = `git ls-files`.split("\n")
29
29
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
30
30
  s.require_paths = ["lib"]
@@ -4,61 +4,61 @@ describe Lolita::I18nController do
4
4
 
5
5
  describe "GET index" do
6
6
  it "should authorize resource" do
7
- controller.authorization_proxy.should_receive(:authorize!).with(:read,controller.resource_class)
7
+ expect(controller.authorization_proxy).to receive(:authorize!).with(:read,controller.resource_class)
8
8
  get :index
9
9
  end
10
10
 
11
11
  it "should assign all translations to variable" do
12
12
  get :index
13
- assigns[:translations].should be_kind_of(Hash)
13
+ expect(assigns[:translations]).to be_kind_of(Hash)
14
14
  end
15
15
 
16
16
  it "should sort translations when params[:sort] is equal to 1" do
17
17
  i18n_request = double("i18n_request")
18
- i18n_request.stub(:translations)
18
+ allow(i18n_request).to receive(:translations)
19
19
  controller.stub(:i18n_request => i18n_request)
20
- i18n_request.should_not_receive(:sort_translations)
20
+ expect(i18n_request).not_to receive(:sort_translations)
21
21
  get :index
22
22
  i18n_request = double("i18n_request2")
23
- i18n_request.stub(:translations)
23
+ allow(i18n_request).to receive(:translations)
24
24
  controller.stub(:i18n_request => i18n_request)
25
- i18n_request.should_receive(:sort_translations)
25
+ expect(i18n_request).to receive(:sort_translations)
26
26
  get :index, :sort => 1
27
27
  end
28
28
  end
29
29
 
30
30
  describe "PUT update" do
31
31
  it "should authorize resource for update" do
32
- controller.authorization_proxy.should_receive(:authorize!).with(:update,controller.resource_class)
32
+ expect(controller.authorization_proxy).to receive(:authorize!).with(:update,controller.resource_class)
33
33
  put :update, :id => "key", :translation => "translation", :format => :json
34
34
  end
35
35
 
36
36
  it "should create notice when save is successful" do
37
- controller.stub(:i18n_request => stub(:update_key => true))
38
- controller.should_receive(:notice).with(kind_of(String))
37
+ controller.stub(:i18n_request => double(:update_key => true))
38
+ expect(controller).to receive(:notice).with(kind_of(String))
39
39
  put :update, :id => Base64.encode64("lv.title"),:translation => "Tulkots virsraksts", :format => :json
40
40
  end
41
41
 
42
42
  it "should create error when save is unsuccessful" do
43
- controller.stub(:i18n_request => stub(:update_key => false))
44
- controller.should_receive(:error).with(kind_of(String))
43
+ controller.stub(:i18n_request => double(:update_key => false))
44
+ expect(controller).to receive(:error).with(kind_of(String))
45
45
  put :update, :id => Base64.encode64("lv.title"),:translation => "Tulkots virsraksts", :format => :json
46
46
  end
47
47
 
48
48
  it "should render error when Lolita::I18n::Exceptions::MissingInterpolationArgument is raised" do
49
49
  i18n_request = double("request")
50
- i18n_request.stub(:update_key).and_raise(Lolita::I18n::Exceptions::MissingInterpolationArgument.new(["%{count}"]))
50
+ allow(i18n_request).to receive(:update_key).and_raise(Lolita::I18n::Exceptions::MissingInterpolationArgument.new(["%{count}"]))
51
51
  controller.stub(:i18n_request => i18n_request)
52
52
  put :update, :id => Base64.encode64("lv.title"),:translation => "Tulkots virsraksts", :format => :json
53
- response.body.should eq(%q{{"error":"Translation should contain all these variables %{count}"}})
53
+ expect(response.body).to eq(%q{{"error":"Translation should contain all these variables %{count}"}})
54
54
  end
55
55
 
56
56
  it "should render error when any other excption happens" do
57
57
  i18n_request = double("request")
58
- i18n_request.stub(:update_key).and_raise(ArgumentError.new)
58
+ allow(i18n_request).to receive(:update_key).and_raise(ArgumentError.new)
59
59
  controller.stub(:i18n_request => i18n_request)
60
60
  put :update, :id => Base64.encode64("lv.title"),:translation => "Tulkots virsraksts", :format => :json
61
- response.body.should eq(%q{{"error":"Key is not saved. Some error accured."}})
61
+ expect(response.body).to eq(%q{{"error":"Key is not saved. Some error accured."}})
62
62
  end
63
63
  end
64
64
  end
@@ -2,12 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe "Translating process" do
4
4
  def translate_key(key)
5
- page.should have_selector("textarea[name='#{key}']")
5
+ expect(page).to have_selector("textarea[name='#{key}']")
6
6
  fill_in(key, :with => "translation for #{key}")
7
7
  page.execute_script(%Q{$("textarea[name='#{key}']").blur()})
8
8
  page.execute_script(%Q{window.location.href='#'})
9
9
  page.check("show_untranslated")
10
- page.find_field(key).value.should == "translation for #{key}"
10
+ expect(page.find_field(key).value).to eq("translation for #{key}")
11
11
  end
12
12
 
13
13
  before(:each) do
@@ -7,8 +7,8 @@ describe "Viewing all translations", :redis => true, :js => true do
7
7
 
8
8
  it "User see translations in default language and same translation in other language" do
9
9
  within(".i18n-box .list>table>thead") do
10
- page.should have_selector("th", :text => "English")
11
- page.should have_selector("th>select option[selected]", :text => "Latvian")
10
+ expect(page).to have_selector("th", :text => "English")
11
+ expect(page).to have_selector("th>select option[selected]", :text => "Latvian")
12
12
  end
13
13
  end
14
14
 
@@ -16,21 +16,21 @@ describe "Viewing all translations", :redis => true, :js => true do
16
16
  within(".i18n-box .list>table>thead") do
17
17
  page.select("Russian", :from => "active_locale")
18
18
  end
19
- page.should have_selector("th select option[selected]", :text => "Russian")
19
+ expect(page).to have_selector("th select option[selected]", :text => "Russian")
20
20
  end
21
21
 
22
22
  it "User can view only untranslated" do
23
- page.should have_selector("textarea", :text => "Virsraksts")
23
+ expect(page).to have_selector("textarea", :text => "Virsraksts")
24
24
  page.check("show_untranslated")
25
- page.should have_selector("textarea", :text => "Other")
26
- page.should_not have_selector("textarea", :text => "Virsraksts")
25
+ expect(page).to have_selector("textarea", :text => "Other")
26
+ expect(page).not_to have_selector("textarea", :text => "Virsraksts")
27
27
  end
28
28
 
29
29
  it "User can sort original translation in ascending order" do
30
30
  last_trans = page.evaluate_script("$('textarea:last').val()");
31
- last_trans.should_not eq("zzzz")
31
+ expect(last_trans).not_to eq("zzzz")
32
32
  click_link("translation_sort_link")
33
33
  new_last_trans = page.evaluate_script("$('textarea:last').val()");
34
- new_last_trans.should eq("zzzz")
34
+ expect(new_last_trans).to eq("zzzz")
35
35
  end
36
36
  end
@@ -5,55 +5,56 @@ describe Lolita::I18nHelper, :rails => true do
5
5
  good_locale_options = [
6
6
  ["Choose other language",nil],
7
7
  ["Latvian",:lv],
8
- ["Russian",:ru]
8
+ ["Russian",:ru],
9
+ ["Swedish",:sv_SE]
9
10
  ]
10
- helper.locale_options.should eq(good_locale_options)
11
+ expect(helper.locale_options).to eq(good_locale_options)
11
12
  end
12
13
 
13
14
  it "#is_untranslated?" do
14
- helper.is_untranslated?("").should be_true
15
- helper.is_untranslated?("text").should be_false
16
- helper.is_untranslated?([]).should be_true
17
- helper.is_untranslated?({}).should be_true
15
+ expect(helper.is_untranslated?("")).to be_truthy
16
+ expect(helper.is_untranslated?("text")).to be_falsey
17
+ expect(helper.is_untranslated?([])).to be_truthy
18
+ expect(helper.is_untranslated?({})).to be_truthy
18
19
  end
19
20
 
20
21
  it "translation is visible when value is not blank and params does not say to show only untranslated values" do
21
- helper.translation_visible?("", nil).should be_true
22
- helper.translation_visible?("text", nil).should be_true
23
- helper.translation_visible?([], nil).should be_true
24
- helper.translation_visible?({}, nil).should be_true
22
+ expect(helper.translation_visible?("", nil)).to be_truthy
23
+ expect(helper.translation_visible?("text", nil)).to be_truthy
24
+ expect(helper.translation_visible?([], nil)).to be_truthy
25
+ expect(helper.translation_visible?({}, nil)).to be_truthy
25
26
 
26
27
  helper.params[:show_untranslated] = true
27
- helper.translation_visible?("", nil).should be_true
28
- helper.translation_visible?("text", nil).should be_false
29
- helper.translation_visible?([], nil).should be_true
30
- helper.translation_visible?({}, nil).should be_true
28
+ expect(helper.translation_visible?("", nil)).to be_truthy
29
+ expect(helper.translation_visible?("text", nil)).to be_falsey
30
+ expect(helper.translation_visible?([], nil)).to be_truthy
31
+ expect(helper.translation_visible?({}, nil)).to be_truthy
31
32
  end
32
33
 
33
34
  describe "#any_translation_visible?" do
34
35
  it "should detect if any translation from array is visible" do
35
- helper.any_translation_visible?([2,1], nil).should be_true
36
- helper.any_translation_visible?([], nil).should be_true
36
+ expect(helper.any_translation_visible?([2,1], nil)).to be_truthy
37
+ expect(helper.any_translation_visible?([], nil)).to be_truthy
37
38
 
38
39
  helper.params[:show_untranslated] = true
39
- helper.any_translation_visible?([], nil).should be_true
40
- helper.any_translation_visible?(["",1], nil).should be_true
41
- helper.any_translation_visible?(["a","b"], nil).should be_false
40
+ expect(helper.any_translation_visible?([], nil)).to be_truthy
41
+ expect(helper.any_translation_visible?(["",1], nil)).to be_truthy
42
+ expect(helper.any_translation_visible?(["a","b"], nil)).to be_falsey
42
43
  end
43
44
 
44
45
 
45
46
  it "should detect if any translation from hash is visible" do
46
- helper.any_translation_visible?({:a => "1",:b => "2" }, nil).should be_true
47
- helper.any_translation_visible?([], nil).should be_true
47
+ expect(helper.any_translation_visible?({:a => "1",:b => "2" }, nil)).to be_truthy
48
+ expect(helper.any_translation_visible?([], nil)).to be_truthy
48
49
 
49
50
  helper.params[:show_untranslated] = true
50
- helper.any_translation_visible?({}, nil).should be_true
51
- helper.any_translation_visible?({:a => "1",:b => "2" }, nil).should be_false
52
- helper.any_translation_visible?({:a => "1",:b => "" }, nil).should be_true
51
+ expect(helper.any_translation_visible?({}, nil)).to be_truthy
52
+ expect(helper.any_translation_visible?({:a => "1",:b => "2" }, nil)).to be_falsey
53
+ expect(helper.any_translation_visible?({:a => "1",:b => "" }, nil)).to be_truthy
53
54
  end
54
55
 
55
56
  it "should call #translation_visible? for any other value" do
56
- helper.should_receive(:translation_visible?).with("text", '/url')
57
+ expect(helper).to receive(:translation_visible?).with("text", '/url')
57
58
  helper.any_translation_visible?("text", '/url')
58
59
  end
59
60
  end
@@ -65,12 +66,12 @@ describe Lolita::I18nHelper, :rails => true do
65
66
  end
66
67
  end
67
68
  it "should create link with sort in it when params does not include :sort" do
68
- helper.sort_link.should match(/sort=1/)
69
+ expect(helper.sort_link).to match(/sort=1/)
69
70
  end
70
71
 
71
72
  it "should create link witho sort in it when params include :sort" do
72
73
  helper.params[:sort] = "1"
73
- helper.sort_link.should_not match(/sort=1/)
74
+ expect(helper.sort_link).not_to match(/sort=1/)
74
75
  end
75
76
  end
76
77
 
@@ -5,132 +5,132 @@ describe Lolita::I18n::Configuration do
5
5
  let(:redis){ double("redis", :ping => true, client: double(disconnect: true, reconnect: true)) }
6
6
 
7
7
  it "should load rails if Rails is defined" do
8
- Lolita.stub(:rails3?).and_return(true)
9
- subject.should_receive(:require).with('lolita-i18n/rails')
8
+ allow(Lolita).to receive(:rails3?).and_return(true)
9
+ expect(subject).to receive(:require).with('lolita-i18n/rails')
10
10
  subject.load_rails!
11
11
  end
12
12
 
13
13
  it "should allow to assign store with Hash as connection options" do
14
- Redis.should_receive(:new).with({:key => "value"}).and_return(redis)
14
+ expect(Redis).to receive(:new).with({:key => "value"}).and_return(redis)
15
15
  subject.store = {:key => "value"}
16
16
  end
17
17
 
18
18
  it "should allow to assign store as store itself" do
19
19
  subject.store = redis
20
- subject.store.should eq(redis)
20
+ expect(subject.store).to eq(redis)
21
21
  end
22
22
 
23
23
  it "should return assigned store" do
24
24
  subject.store = redis
25
- subject.store.should eq(redis)
25
+ expect(subject.store).to eq(redis)
26
26
  end
27
27
 
28
28
  it "should return new Redis connection and warn when no store is assigned" do
29
- Redis.should_receive(:new).and_return(redis)
30
- subject.should_receive(:warn).with("Lolita::I18n No store specified. See Lolita::I18n")
31
- subject.store.should eq(redis)
29
+ expect(Redis).to receive(:new).and_return(redis)
30
+ expect(subject).to receive(:warn).with("Lolita::I18n No store specified. See Lolita::I18n")
31
+ expect(subject.store).to eq(redis)
32
32
  end
33
33
 
34
34
  it "should lazy create and return backend" do
35
- Redis.should_receive(:new).and_return(redis)
36
- ::I18n::Backend::KeyValue.should_receive(:new).with(redis)
35
+ expect(Redis).to receive(:new).and_return(redis)
36
+ expect(::I18n::Backend::KeyValue).to receive(:new).with(redis)
37
37
  subject.backend
38
38
  end
39
39
 
40
40
  it "should load translations" do
41
41
  yaml_backend = double("yaml_backend")
42
42
  subject.yaml_backend = yaml_backend
43
- yaml_backend.should_receive(:load_translations)
43
+ expect(yaml_backend).to receive(:load_translations)
44
44
  subject.load_translations
45
45
  end
46
46
 
47
47
  it "should initialize chain" do
48
48
  subject.yaml_backend = double("yaml backend")
49
- Redis.stub(:new).and_return(redis)
50
- ::I18n::Backend::Chain.should_receive(:new).with(subject.backend,subject.yaml_backend)
49
+ allow(Redis).to receive(:new).and_return(redis)
50
+ expect(::I18n::Backend::Chain).to receive(:new).with(subject.backend,subject.yaml_backend)
51
51
  subject.initialize_chain
52
- Redis.unstub(:new)
52
+ allow(Redis).to receive(:new).and_call_original
53
53
  end
54
54
 
55
55
  describe "#connect" do
56
- before(:each){ Redis.stub(:new).and_return(redis) }
57
- after(:each){ Redis.unstub(:new) }
56
+ before(:each){ allow(Redis).to receive(:new).and_return(redis) }
57
+ after(:each){ allow(Redis).to receive(:new).and_call_original }
58
58
 
59
59
  it "should call reconnect if not connected" do
60
- subject.should_receive(:initialize_chain).once
60
+ expect(subject).to receive(:initialize_chain).once
61
61
  subject.connect
62
62
  subject.connect
63
63
  end
64
64
 
65
65
  it "should return true when success" do
66
- subject.connect.should be_true
66
+ expect(subject.connect).to be_truthy
67
67
  end
68
68
 
69
69
  it "should return not be true when fail" do
70
- Redis.stub(:new).and_raise(Errno::ECONNREFUSED)
71
- subject.connect.should_not be_true
70
+ allow(Redis).to receive(:new).and_raise(Errno::ECONNREFUSED)
71
+ expect(subject.connect).not_to be_truthy
72
72
  end
73
73
  end
74
74
 
75
75
  describe "#reconnect" do
76
76
  it "should call init if not initialized jet" do
77
- subject.should_receive(:init).once
77
+ expect(subject).to receive(:init).once
78
78
  subject.reconnect
79
79
  end
80
80
 
81
81
  it "should not call init if already initialized" do
82
82
  subject.reconnect
83
- subject.should_not_receive(:init)
83
+ expect(subject).not_to receive(:init)
84
84
  subject.reconnect
85
85
  end
86
86
 
87
87
  it "should return true when success" do
88
- subject.reconnect.should be_true
88
+ expect(subject.reconnect).to be_truthy
89
89
  end
90
90
 
91
91
  it "should return false when fail" do
92
- Redis.stub(:new).and_raise(Errno::ECONNREFUSED)
93
- subject.reconnect.should_not be_true
94
- Redis.unstub(:new)
92
+ allow(Redis).to receive(:new).and_raise(Errno::ECONNREFUSED)
93
+ expect(subject.reconnect).not_to be_truthy
94
+ allow(Redis).to receive(:new).and_call_original
95
95
  end
96
96
 
97
97
  it "should initialize chain" do
98
- subject.should_receive(:initialize_chain).twice
98
+ expect(subject).to receive(:initialize_chain).twice
99
99
  subject.reconnect
100
100
  subject.reconnect
101
101
  end
102
102
 
103
103
  it "should disconnect" do
104
- subject.should_receive(:disconnect)
104
+ expect(subject).to receive(:disconnect)
105
105
  subject.reconnect
106
106
  end
107
107
  end
108
108
 
109
109
  describe "#disconnect" do
110
110
  it "should disconnect if connected" do
111
- subject.store.client.should_receive(:disconnect).twice
111
+ expect(subject.store.client).to receive(:disconnect).twice
112
112
  subject.connect
113
113
  subject.disconnect
114
114
  end
115
115
 
116
116
  it "should not disconnect if not connected"do
117
- subject.store.client.should_not_receive(:disconnect)
117
+ expect(subject.store.client).not_to receive(:disconnect)
118
118
  subject.disconnect
119
119
  end
120
120
  end
121
121
 
122
122
  describe "#init" do
123
123
  it "should call all propper methods" do
124
- subject.should_receive(:include_modules)
125
- subject.should_receive(:set_yaml_backend)
126
- subject.should_receive(:connect)
124
+ expect(subject).to receive(:include_modules)
125
+ expect(subject).to receive(:set_yaml_backend)
126
+ expect(subject).to receive(:connect)
127
127
  subject.init
128
128
  end
129
129
 
130
130
  it "should run only once" do
131
- subject.should_receive(:include_modules).once
132
- subject.should_receive(:set_yaml_backend).once
133
- subject.should_receive(:connect).once
131
+ expect(subject).to receive(:include_modules).once
132
+ expect(subject).to receive(:set_yaml_backend).once
133
+ expect(subject).to receive(:connect).once
134
134
  subject.init
135
135
  subject.init
136
136
  end
@@ -139,9 +139,9 @@ describe Lolita::I18n::Configuration do
139
139
  describe "#include_modules" do
140
140
  it "include module in ::I18n::Backend::Simple" do
141
141
  subject.include_modules
142
- ::I18n::Backend::Simple.ancestors.should include(::I18n::Backend::Flatten)
143
- ::I18n::Backend::Simple.ancestors.should include(::I18n::Backend::Pluralization)
144
- ::I18n::Backend::Simple.ancestors.should include(::I18n::Backend::InterpolationCompiler)
142
+ expect(::I18n::Backend::Simple.ancestors).to include(::I18n::Backend::Flatten)
143
+ expect(::I18n::Backend::Simple.ancestors).to include(::I18n::Backend::Pluralization)
144
+ expect(::I18n::Backend::Simple.ancestors).to include(::I18n::Backend::InterpolationCompiler)
145
145
  end
146
146
  end
147
147
 
@@ -3,13 +3,13 @@ require 'spec_helper'
3
3
  describe Lolita::I18n::Exceptions::MissingInterpolationArgument do
4
4
  it "create new StandartError with custom message" do
5
5
  error = Lolita::I18n::Exceptions::MissingInterpolationArgument.new(["arg1","arg2"])
6
- error.message.should eq("Translation should contain all these variables arg1, arg2")
6
+ expect(error.message).to eq("Translation should contain all these variables arg1, arg2")
7
7
  end
8
8
  end
9
9
 
10
10
  describe Lolita::I18n::Exceptions::TranslationDoesNotMatch do
11
11
  it "should cretae new ArgumentError with custom message" do
12
12
  error = Lolita::I18n::Exceptions::TranslationDoesNotMatch.new("translation", "original")
13
- error.message.should eq("Translation translation does not match original")
13
+ expect(error.message).to eq("Translation translation does not match original")
14
14
  end
15
15
  end
@@ -6,53 +6,53 @@ describe Lolita::I18n::Request do
6
6
  let(:validator){Lolita::I18n::Request::Validator.new}
7
7
 
8
8
  it "should validate string and return error when original and given values interpolations doesn't match" do
9
- ::I18n.stub(:t).and_return("original text")
9
+ allow(::I18n).to receive(:t).and_return("original text")
10
10
  expect{validator.validate("text_key","text")}.not_to raise_error
11
11
 
12
- ::I18n.stub(:t).and_return("text with %{interpolation}")
12
+ allow(::I18n).to receive(:t).and_return("text with %{interpolation}")
13
13
  expect{
14
14
  validator.validate("text_key","text")
15
15
  }.to raise_error(Lolita::I18n::Exceptions::MissingInterpolationArgument)
16
16
  end
17
17
 
18
18
  it "should validate array's each value as string" do
19
- ::I18n.stub(:t).and_return(["a","b","c"])
19
+ allow(::I18n).to receive(:t).and_return(["a","b","c"])
20
20
  expect{validator.validate("array_key",["1","2","3"])}.not_to raise_error
21
21
 
22
- ::I18n.stub(:t).and_return(["a","%{b}","c"])
22
+ allow(::I18n).to receive(:t).and_return(["a","%{b}","c"])
23
23
  expect{
24
24
  validator.validate("array_key",["1","2","3"])
25
25
  }.to raise_error(Lolita::I18n::Exceptions::MissingInterpolationArgument,"Translation should contain all these variables %{b}")
26
26
  end
27
27
 
28
28
  it "should validate hash's each value as string" do
29
- ::I18n.stub(:t).and_return({:a => "1", :b => "2"})
29
+ allow(::I18n).to receive(:t).and_return({:a => "1", :b => "2"})
30
30
  expect{validator.validate("array_key",{"a" => "a", "b" => "b"})}.not_to raise_error
31
31
 
32
- ::I18n.stub(:t).and_return({:a => "1", :b => "2 %{count}"})
32
+ allow(::I18n).to receive(:t).and_return({:a => "1", :b => "2 %{count}"})
33
33
  expect{
34
34
  validator.validate("array_key",{"a" => "a", "b" => "b"})
35
35
  }.to raise_error(Lolita::I18n::Exceptions::MissingInterpolationArgument)
36
36
  end
37
37
 
38
38
  it "should raise error when translation is Array but original is not or sizes does not match" do
39
- ::I18n.stub(:t).and_return("")
39
+ allow(::I18n).to receive(:t).and_return("")
40
40
  expect{
41
41
  validator.validate("key",[1,2])
42
42
  }.to raise_error(Lolita::I18n::Exceptions::TranslationDoesNotMatch)
43
43
 
44
- ::I18n.stub(:t).and_return([1,2])
44
+ allow(::I18n).to receive(:t).and_return([1,2])
45
45
  expect{
46
46
  validator.validate("key",[2])
47
47
  }
48
48
  end
49
49
 
50
50
  it "should raise error when translation is Hash but original is not or keys does not match " do
51
- ::I18n.stub(:t).and_return("")
51
+ allow(::I18n).to receive(:t).and_return("")
52
52
  expect{
53
53
  validator.validate("key",{"a" => 1})
54
54
  }.to raise_error(Lolita::I18n::Exceptions::TranslationDoesNotMatch)
55
- ::I18n.stub(:t).and_return({:a => 2, :b => 3})
55
+ allow(::I18n).to receive(:t).and_return({:a => 2, :b => 3})
56
56
  expect{
57
57
  validator.validate("key",{"a" => 1})
58
58
  }
@@ -71,30 +71,30 @@ describe Lolita::I18n::Request do
71
71
  end
72
72
 
73
73
  it "should return parsed value" do
74
- I18n.stub(:t).and_return("original_value")
74
+ allow(I18n).to receive(:t).and_return("original_value")
75
75
  t = klass.new("key","value")
76
- t.value.should eq("value")
76
+ expect(t.value).to eq("value")
77
77
  end
78
78
 
79
79
  it "should return locale for key" do
80
80
  t = klass.new("lv.key","value")
81
- t.locale.should eq(:lv)
81
+ expect(t.locale).to eq(:lv)
82
82
  end
83
83
 
84
84
  it "should return key" do
85
85
  t = klass.new("lv.key","value")
86
- t.key.should eq("key")
86
+ expect(t.key).to eq("key")
87
87
  end
88
88
 
89
89
  it "should return array for store with locale, key => value and configuration hash" do
90
90
  t = klass.new("lv.my.key","value")
91
- t.for_store.should eq([:lv,{"my.key" => "value"}, {:escape => false}])
91
+ expect(t.for_store).to eq([:lv,{"my.key" => "value"}, {:escape => false}])
92
92
  end
93
93
 
94
94
  it "should return original translation of given key" do
95
- ::I18n.stub(:t).with(kind_of(String), kind_of(Hash)).and_return("original")
95
+ allow(::I18n).to receive(:t).with(kind_of(String), kind_of(Hash)).and_return("original")
96
96
  t = klass.new("ru.my.key","value")
97
- t.original.should eq("original")
97
+ expect(t.original).to eq("original")
98
98
  end
99
99
  end
100
100
 
@@ -106,7 +106,7 @@ describe Lolita::I18n::Request do
106
106
 
107
107
  let(:klass){Lolita::I18n::Request::Translations}
108
108
  let(:translations) {
109
- ::I18n.stub(:t) do |*args|
109
+ allow(::I18n).to receive(:t) do |*args|
110
110
  if args[1] && args[1][:locale] == :en
111
111
  if args[0] == :arr
112
112
  [1,2]
@@ -132,24 +132,24 @@ describe Lolita::I18n::Request do
132
132
 
133
133
  it "should detect if value is final and should't be flattened any more" do
134
134
  t = klass.new({})
135
- t.final_value?(1).should be_true
136
- t.final_value?([]).should be_true
137
- t.final_value?({:other => "other", :one => "one"}).should be_true
138
- t.final_value?({:other => "other"}).should be_false
139
- t.final_value?({:other => [], :one => 1}).should be_false
140
- t.final_value?({:other => {}, :one => 1}).should be_false
135
+ expect(t.final_value?(1)).to be_truthy
136
+ expect(t.final_value?([])).to be_truthy
137
+ expect(t.final_value?({:other => "other", :one => "one"})).to be_truthy
138
+ expect(t.final_value?({:other => "other"})).to be_falsey
139
+ expect(t.final_value?({:other => [], :one => 1})).to be_falsey
140
+ expect(t.final_value?({:other => {}, :one => 1})).to be_falsey
141
141
  end
142
142
 
143
143
  it "should return default translation value for different original values" do
144
144
  t = klass.new({})
145
- ::I18n.stub(:t).and_return([])
146
- t.translation_value("key",[1,2],"ru").should eq([])
147
- ::I18n.stub(:t).and_return({})
148
- t.translation_value("key",{:a=>1},"ru").should eq({})
149
- ::I18n.stub(:t).and_return("translation")
150
- t.translation_value("key","value","ru").should eq("translation")
151
- ::I18n.stub(:t).and_return([1,2])
152
- t.translation_value("key",[2,3],"ru").should eq([1,2])
145
+ allow(::I18n).to receive(:t).and_return([])
146
+ expect(t.translation_value("key",[1,2],"ru")).to eq([])
147
+ allow(::I18n).to receive(:t).and_return({})
148
+ expect(t.translation_value("key",{:a=>1},"ru")).to eq({})
149
+ allow(::I18n).to receive(:t).and_return("translation")
150
+ expect(t.translation_value("key","value","ru")).to eq("translation")
151
+ allow(::I18n).to receive(:t).and_return([1,2])
152
+ expect(t.translation_value("key",[2,3],"ru")).to eq([1,2])
153
153
  end
154
154
 
155
155
  it "should flatten keys until final value is found" do
@@ -164,7 +164,7 @@ describe Lolita::I18n::Request do
164
164
  [:inter, {}, {:one => "one", :other => "other"}],
165
165
  [:"hsh.key","-no-translation-", "value"]
166
166
  ]
167
- result.should eq(valid_results)
167
+ expect(result).to eq(valid_results)
168
168
  end
169
169
 
170
170
  it "should normalize for locale" do
@@ -175,11 +175,11 @@ describe Lolita::I18n::Request do
175
175
  :inter => {:translation => {}, :original_translation => {:one => "one", :other => "other"}, :url => nil},
176
176
  :"hsh.key" => {:translation => "-no-translation-", :original_translation => "value", :url => nil}
177
177
  }
178
- t.normalized(:lv).should eq(valid_results)
178
+ expect(t.normalized(:lv)).to eq(valid_results)
179
179
  end
180
180
 
181
181
  it "should normalize for locale end retur registerd URL" do
182
- Redis.any_instance.stub(:[]).and_return '/kekss'
182
+ allow_any_instance_of(Redis).to receive(:[]).and_return '/kekss'
183
183
  t = klass.new(translations)
184
184
  valid_results = {
185
185
  :arr => {:translation => [], :original_translation => [1,2], :url => '/kekss'},
@@ -187,7 +187,7 @@ describe Lolita::I18n::Request do
187
187
  :inter => {:translation => {}, :original_translation => {:one => "one", :other => "other"}, :url => '/kekss'},
188
188
  :"hsh.key" => {:translation => "-no-translation-", :original_translation => "value", :url => '/kekss'}
189
189
  }
190
- t.normalized(:lv).should eq(valid_results)
190
+ expect(t.normalized(:lv)).to eq(valid_results)
191
191
  end
192
192
  end
193
193
 
@@ -196,15 +196,15 @@ describe Lolita::I18n::Request do
196
196
  it "should create new request with params" do
197
197
  expect{
198
198
  request = request_klass.new({:a => 1})
199
- request.params.should eq({:a => 1})
199
+ expect(request.params).to eq({:a => 1})
200
200
  }.not_to raise_error
201
201
  end
202
202
 
203
203
  it "should return translations" do
204
204
  r = request_klass.new({})
205
- Lolita.i18n.should_receive(:load_translations).and_return(true)
206
- Lolita.i18n.stub(:yaml_backend).and_return(stub(:translations => {:en => {}}))
207
- Lolita::I18n::Request::Translations.any_instance.should_receive(:normalized).once
205
+ expect(Lolita.i18n).to receive(:load_translations).and_return(true)
206
+ allow(Lolita.i18n).to receive(:yaml_backend).and_return(double(:translations => {:en => {}}))
207
+ expect_any_instance_of(Lolita::I18n::Request::Translations).to receive(:normalized).once
208
208
  r.translations(:en)
209
209
  end
210
210
 
@@ -228,21 +228,21 @@ describe Lolita::I18n::Request do
228
228
  [:"key4", {:original_translation => true}],
229
229
  [:"key9", {:original_translation => "ZZZ"}]
230
230
  ]
231
- r.sort_translations(unsorted_translations).should eq(sorted_translations)
231
+ expect(r.sort_translations(unsorted_translations)).to eq(sorted_translations)
232
232
  end
233
233
 
234
234
  it "should update key" do
235
235
  r = request_klass.new({:translation => "translation", :id => Base64.encode64("ru.key")})
236
- ::I18n.stub(:t).and_return("original")
236
+ allow(::I18n).to receive(:t).and_return("original")
237
237
  backend = double("backend")
238
238
  Lolita.i18n.stub(:backend => backend)
239
- backend.should_receive(:store_translations).with(:"ru", { "key" => "translation" }, :escape => false).and_return(true)
239
+ expect(backend).to receive(:store_translations).with(:"ru", { "key" => "translation" }, :escape => false).and_return(true)
240
240
  r.update_key
241
241
  end
242
242
 
243
243
  it "should have validator" do
244
244
  r = request_klass.new({})
245
- r.validator.should be_a_kind_of(Lolita::I18n::Request::Validator)
245
+ expect(r.validator).to be_a_kind_of(Lolita::I18n::Request::Validator)
246
246
  end
247
247
 
248
248
 
@@ -3,6 +3,6 @@ require 'spec_helper'
3
3
 
4
4
  describe Lolita::I18n::Version do
5
5
  it "should return current version of gem" do
6
- Lolita::I18n::Version.to_s.should match(/\d+\.\d+\.\d+/)
6
+ expect(Lolita::I18n::Version.to_s).to match(/\d+\.\d+\.\d+/)
7
7
  end
8
8
  end
@@ -4,18 +4,18 @@ describe Lolita::I18n do
4
4
  describe "loaded" do
5
5
 
6
6
  it "should check Redis connection after Lolita.setup" do
7
- Lolita.i18n.should_receive(:init)
7
+ expect(Lolita.i18n).to receive(:init)
8
8
  Lolita.setup{}
9
9
  end
10
10
 
11
11
  it "should add #i18n to Lolita configuration" do
12
- Lolita.configuration.should respond_to(:i18n)
12
+ expect(Lolita.configuration).to respond_to(:i18n)
13
13
  end
14
14
 
15
15
  it "should have Request,Configuration,Exceptions constants in module" do
16
- Lolita::I18n::Request.should be_kind_of(Class)
17
- Lolita::I18n::Configuration.should be_kind_of(Class)
18
- Lolita::I18n::Exceptions.should be_kind_of(Module)
16
+ expect(Lolita::I18n::Request).to be_kind_of(Class)
17
+ expect(Lolita::I18n::Configuration).to be_kind_of(Class)
18
+ expect(Lolita::I18n::Exceptions).to be_kind_of(Module)
19
19
  end
20
20
  end
21
21
  end
@@ -2,10 +2,10 @@ require "spec_helper"
2
2
 
3
3
  describe "Lolita I18n routes", :rails => true do
4
4
  it "has route for update with key" do
5
- {:put => "/lolita/i18n/my_id"}.should route_to(:controller => "lolita/i18n", :action => "update", :id => "my_id")
5
+ expect({:put => "/lolita/i18n/my_id"}).to route_to(:controller => "lolita/i18n", :action => "update", :id => "my_id")
6
6
  end
7
7
 
8
8
  it "has route for list of all translations" do
9
- {:get => "/lolita/i18n"}.should route_to(:controller => "lolita/i18n", :action => "index")
9
+ expect({:get => "/lolita/i18n"}).to route_to(:controller => "lolita/i18n", :action => "index")
10
10
  end
11
11
  end
data/spec/spec_helper.rb CHANGED
@@ -29,4 +29,15 @@ RSpec.configure do |config|
29
29
  config.before(:each, :redis) do
30
30
  Lolita.i18n.store.flushdb
31
31
  end
32
+
33
+ # rspec-rails 3 will no longer automatically infer an example group's spec type
34
+ # from the file location. You can explicitly opt-in to the feature using this
35
+ # config option.
36
+ # To explicitly tag specs without using automatic inference, set the `:type`
37
+ # metadata manually:
38
+ #
39
+ # describe ThingsController, :type => :controller do
40
+ # # Equivalent to being in spec/controllers
41
+ # end
42
+ config.infer_spec_type_from_file_location!
32
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolita-i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITHouse (Latvia)
@@ -10,20 +10,20 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-07-23 00:00:00.000000000 Z
13
+ date: 2015-01-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: lolita
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
21
  version: '3.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - "~>"
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  version: '3.2'
29
29
  - !ruby/object:Gem::Dependency
@@ -46,70 +46,70 @@ dependencies:
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: 0.4.5
49
+ version: '0.4'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: 0.4.5
56
+ version: '0.4'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: redis
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: 3.0.3
63
+ version: '3.0'
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: 3.0.3
70
+ version: '3.0'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: yajl-ruby
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: 1.1.0
77
+ version: '1.1'
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: 1.1.0
84
+ version: '1.1'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: unicode_utils
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - "~>"
90
90
  - !ruby/object:Gem::Version
91
- version: 1.4.0
91
+ version: '1.4'
92
92
  type: :runtime
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
- version: 1.4.0
98
+ version: '1.4'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: axlsx
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
103
  - - "~>"
104
104
  - !ruby/object:Gem::Version
105
- version: 2.0.1
105
+ version: '2.0'
106
106
  type: :runtime
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - "~>"
111
111
  - !ruby/object:Gem::Version
112
- version: 2.0.1
112
+ version: '2.0'
113
113
  description: Lolita plugin, that enables .yml files management from administrative
114
114
  interface. Also faster access to translations, that DB store
115
115
  email: support@ithouse.lv
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  version: '0'
196
196
  requirements: []
197
197
  rubyforge_project:
198
- rubygems_version: 2.2.1
198
+ rubygems_version: 2.2.0
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: Lolita plugin, that enables .yml management
@@ -225,3 +225,4 @@ test_files:
225
225
  - spec/test_app/config/mongoid.yml
226
226
  - spec/test_app/config/routes.rb
227
227
  - spec/test_app/log/.gitkeep
228
+ has_rdoc: