Add tests
parent
f443c28fc8
commit
476c6045c4
5
Rakefile
5
Rakefile
|
@ -1,2 +1,7 @@
|
||||||
require "bundler/gem_tasks"
|
require "bundler/gem_tasks"
|
||||||
|
require 'rake/testtask'
|
||||||
|
|
||||||
|
Rake::TestTask.new do |t|
|
||||||
|
t.libs << "test"
|
||||||
|
t.test_files = Dir['test/**/*_test.rb']
|
||||||
|
end
|
||||||
|
|
|
@ -20,4 +20,8 @@ Gem::Specification.new do |spec|
|
||||||
|
|
||||||
spec.add_development_dependency 'bundler', '~> 1.6'
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
||||||
spec.add_development_dependency 'rake'
|
spec.add_development_dependency 'rake'
|
||||||
|
|
||||||
|
spec.add_development_dependency 'minitest', '~> 5.4'
|
||||||
|
spec.add_development_dependency 'minitest-reporters'
|
||||||
|
spec.add_development_dependency 'fakeredis'
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class Flop::FeatureTest < Minitest::Test
|
||||||
|
def setup
|
||||||
|
@feature = Flop::Feature.new(:test)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_it_is_inactive_by_default
|
||||||
|
assert Flop::Feature.new(:inactive_feature).inactive?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_that_name_is_symbol
|
||||||
|
assert_equal :string, Flop::Feature.new('string').name
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_set_specified_value
|
||||||
|
@feature.set true
|
||||||
|
assert @feature.active?
|
||||||
|
|
||||||
|
@feature.set false
|
||||||
|
assert @feature.inactive?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_toggle
|
||||||
|
@feature.deactivate
|
||||||
|
|
||||||
|
@feature.toggle
|
||||||
|
assert @feature.active?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_activate
|
||||||
|
@feature.activate
|
||||||
|
assert @feature.active?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_deactivate
|
||||||
|
@feature.deactivate
|
||||||
|
assert @feature.inactive?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_with_executes_block
|
||||||
|
@feature.deactivate
|
||||||
|
assert_nil @feature.with { true }
|
||||||
|
|
||||||
|
@feature.activate
|
||||||
|
assert @feature.with { true }
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_without_executes_block
|
||||||
|
@feature.deactivate
|
||||||
|
assert @feature.without { true }
|
||||||
|
|
||||||
|
@feature.activate
|
||||||
|
assert_nil @feature.without { true }
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,13 @@
|
||||||
|
module Flop::Repository::GenericRepoExample
|
||||||
|
def test_default_value_is_false
|
||||||
|
refute @repo.get(:unknown_key), 'default value is not false'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_get_value
|
||||||
|
@repo.set(:test, true)
|
||||||
|
@repo.set(:test2, false)
|
||||||
|
|
||||||
|
assert_equal true, @repo.get(:test)
|
||||||
|
assert_equal false, @repo.get(:test2)
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,10 @@
|
||||||
|
require 'test_helper'
|
||||||
|
require 'flop/repository/generic_repo_example'
|
||||||
|
|
||||||
|
class Flop::Repository::MemoryTest < Minitest::Test
|
||||||
|
def setup
|
||||||
|
@repo = Flop::Repository::Memory.new
|
||||||
|
end
|
||||||
|
|
||||||
|
include Flop::Repository::GenericRepoExample
|
||||||
|
end
|
|
@ -0,0 +1,11 @@
|
||||||
|
require 'test_helper'
|
||||||
|
require 'flop/repository/generic_repo_example'
|
||||||
|
require 'fakeredis'
|
||||||
|
|
||||||
|
class Flop::Repository::RedisTest < Minitest::Test
|
||||||
|
def setup
|
||||||
|
@repo = Flop::Repository::Redis.new(Redis.new)
|
||||||
|
end
|
||||||
|
|
||||||
|
include Flop::Repository::GenericRepoExample
|
||||||
|
end
|
|
@ -0,0 +1,7 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class FlopTest < Minitest::Test
|
||||||
|
def test_that_return_feature
|
||||||
|
assert_instance_of Flop::Feature, Flop[:test]
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'minitest/autorun'
|
||||||
|
require 'minitest/reporters'
|
||||||
|
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
|
||||||
|
|
||||||
|
require 'flop'
|
Loading…
Reference in New Issue