Skip to content

Commit

Permalink
Remove the need for TokyoCabinet and Rufus dependency to run the tests
Browse files Browse the repository at this point in the history
The key-value store requires a very specific API from the store, and we
can use a simple hash object to match that contract on our tests, so
there's no need for yet another dependency on top of it.
  • Loading branch information
carlosantoniodasilva committed Jul 16, 2014
1 parent 1b83b16 commit 10c07ff
Show file tree
Hide file tree
Showing 12 changed files with 8 additions and 42 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
@@ -1,5 +1,3 @@
before_install: "sudo apt-get install ruby-tokyocabinet -y"

rvm:
- 1.9.3
- 2.0.0
Expand Down
2 changes: 0 additions & 2 deletions gemfiles/Gemfile.rails-3.2.x
Expand Up @@ -5,6 +5,4 @@ gemspec :path => '..'
gem 'activesupport', '~> 3.2.0'
gem 'mocha'
gem 'test_declarative'
gem 'rufus-tokyo'
gem 'ffi'
gem 'rake'
4 changes: 0 additions & 4 deletions gemfiles/Gemfile.rails-3.2.x.lock
Expand Up @@ -9,23 +9,19 @@ GEM
activesupport (3.2.18)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
ffi (1.9.3)
metaclass (0.0.4)
mocha (1.0.0)
metaclass (~> 0.0.1)
multi_json (1.10.0)
rake (10.3.1)
rufus-tokyo (1.0.7)
test_declarative (0.0.5)

PLATFORMS
ruby

DEPENDENCIES
activesupport (~> 3.2.0)
ffi
i18n!
mocha
rake
rufus-tokyo
test_declarative
2 changes: 0 additions & 2 deletions gemfiles/Gemfile.rails-4.0.x
Expand Up @@ -5,6 +5,4 @@ gemspec :path => '..'
gem 'activesupport', '~> 4.0.0'
gem 'mocha'
gem 'test_declarative'
gem 'rufus-tokyo'
gem 'ffi'
gem 'rake'
4 changes: 0 additions & 4 deletions gemfiles/Gemfile.rails-4.0.x.lock
Expand Up @@ -12,14 +12,12 @@ GEM
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
ffi (1.9.3)
metaclass (0.0.4)
minitest (4.7.5)
mocha (1.0.0)
metaclass (~> 0.0.1)
multi_json (1.10.0)
rake (10.3.1)
rufus-tokyo (1.0.7)
test_declarative (0.0.5)
thread_safe (0.3.3)
tzinfo (0.3.39)
Expand All @@ -29,9 +27,7 @@ PLATFORMS

DEPENDENCIES
activesupport (~> 4.0.0)
ffi
i18n!
mocha
rake
rufus-tokyo
test_declarative
2 changes: 0 additions & 2 deletions gemfiles/Gemfile.rails-4.1.x
Expand Up @@ -5,6 +5,4 @@ gemspec :path => '..'
gem 'activesupport', '~> 4.1.0'
gem 'mocha'
gem 'test_declarative'
gem 'rufus-tokyo'
gem 'ffi'
gem 'rake'
4 changes: 0 additions & 4 deletions gemfiles/Gemfile.rails-4.1.x.lock
Expand Up @@ -12,14 +12,12 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
ffi (1.9.3)
json (1.8.1)
metaclass (0.0.4)
minitest (5.3.3)
mocha (1.0.0)
metaclass (~> 0.0.1)
rake (10.3.1)
rufus-tokyo (1.0.7)
test_declarative (0.0.5)
thread_safe (0.3.3)
tzinfo (1.1.0)
Expand All @@ -30,9 +28,7 @@ PLATFORMS

DEPENDENCIES
activesupport (~> 4.1.0)
ffi
i18n!
mocha
rake
rufus-tokyo
test_declarative
1 change: 0 additions & 1 deletion lib/i18n/backend/key_value.rb
@@ -1,6 +1,5 @@
require 'i18n/backend/base'
require 'active_support/json'
require 'active_support/ordered_hash' # active_support/json/encoding uses ActiveSupport::OrderedHash but does not require it

module I18n
module Backend
Expand Down
8 changes: 2 additions & 6 deletions test/api/key_value_test.rb
@@ -1,7 +1,5 @@
require 'test_helper'

I18n::TestCase.setup_rufus_tokyo

class I18nKeyValueApiTest < I18n::TestCase
include I18n::Tests::Basics
include I18n::Tests::Defaults
Expand All @@ -15,14 +13,12 @@ class I18nKeyValueApiTest < I18n::TestCase
include I18n::Tests::Localization::Time
# include Tests::Api::Localization::Procs

STORE = Rufus::Tokyo::Cabinet.new('*')

def setup
I18n.backend = I18n::Backend::KeyValue.new(STORE)
I18n.backend = I18n::Backend::KeyValue.new({})
super
end

test "make sure we use the KeyValue backend" do
assert_equal I18n::Backend::KeyValue, I18n.backend.class
end
end if defined?(Rufus::Tokyo::Cabinet)
end if I18n::TestCase.key_value?
8 changes: 2 additions & 6 deletions test/api/memoize_test.rb
Expand Up @@ -27,8 +27,6 @@ def setup
end
end

I18n::TestCase.setup_rufus_tokyo

class I18nMemoizeBackendWithKeyValueApiTest < I18n::TestCase
include I18n::Tests::Basics
include I18n::Tests::Defaults
Expand All @@ -47,14 +45,12 @@ class MemoizeBackend < I18n::Backend::KeyValue
include I18n::Backend::Memoize
end

STORE = Rufus::Tokyo::Cabinet.new('*')

def setup
I18n.backend = MemoizeBackend.new(STORE)
I18n.backend = MemoizeBackend.new({})
super
end

test "make sure we use the MemoizeBackend backend" do
assert_equal MemoizeBackend, I18n.backend.class
end
end if defined?(Rufus::Tokyo::Cabinet)
end if I18n::TestCase.key_value?
7 changes: 2 additions & 5 deletions test/backend/key_value_test.rb
@@ -1,10 +1,8 @@
require 'test_helper'

I18n::TestCase.setup_rufus_tokyo

class I18nBackendKeyValueTest < I18n::TestCase
def setup_backend!(subtree=true)
I18n.backend = I18n::Backend::KeyValue.new(Rufus::Tokyo::Cabinet.new('*'), subtree)
I18n.backend = I18n::Backend::KeyValue.new({}, subtree)
store_translations(:en, :foo => { :bar => 'bar', :baz => 'baz' })
end

Expand Down Expand Up @@ -42,5 +40,4 @@ def assert_flattens(expected, nested, escape=true, subtree=true)
I18n.t("foo", :raise => true)
end
end

end if defined?(Rufus::Tokyo::Cabinet)
end if I18n::TestCase.key_value?
6 changes: 2 additions & 4 deletions test/test_helper.rb
Expand Up @@ -34,10 +34,8 @@ def gem(gem_name, *version_requirements)
require 'test_declarative'

class I18n::TestCase < TEST_CASE
def self.setup_rufus_tokyo
require 'rufus/tokyo'
rescue LoadError => e
puts "can't use KeyValue backend because: #{e.message}"
def self.key_value?
defined?(ActiveSupport)
end

def setup
Expand Down

0 comments on commit 10c07ff

Please sign in to comment.