2015-03-10 01:00:37 -04:00
|
|
|
require 'abstract_unit'
|
2015-03-30 12:55:20 -04:00
|
|
|
require 'active_support/core_ext/array'
|
2015-03-10 01:00:37 -04:00
|
|
|
|
|
|
|
class ArrayInquirerTest < ActiveSupport::TestCase
|
|
|
|
def setup
|
|
|
|
@array_inquirer = ActiveSupport::ArrayInquirer.new([:mobile, :tablet])
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_individual
|
|
|
|
assert @array_inquirer.mobile?
|
|
|
|
assert @array_inquirer.tablet?
|
|
|
|
assert_not @array_inquirer.desktop?
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_any
|
|
|
|
assert @array_inquirer.any?(:mobile, :desktop)
|
|
|
|
assert @array_inquirer.any?(:watch, :tablet)
|
|
|
|
assert_not @array_inquirer.any?(:desktop, :watch)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_any_with_block
|
|
|
|
assert @array_inquirer.any? { |v| v == :mobile }
|
|
|
|
assert_not @array_inquirer.any? { |v| v == :desktop }
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_respond_to
|
|
|
|
assert_respond_to @array_inquirer, :development?
|
|
|
|
end
|
2015-03-30 12:38:13 -04:00
|
|
|
|
|
|
|
def test_inquiry
|
|
|
|
result = [:mobile, :tablet].inquiry
|
|
|
|
|
|
|
|
assert_instance_of ActiveSupport::ArrayInquirer, result
|
|
|
|
assert_equal @array_inquirer, result
|
|
|
|
end
|
2015-03-10 01:00:37 -04:00
|
|
|
end
|