This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 204
/
Copy pathconfig_test.rb
67 lines (55 loc) · 2.2 KB
/
config_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require 'test_helper'
module ShopifyCli
module Commands
class ConfigTest < MiniTest::Test
include TestHelpers::FakeFS
TEST_FEATURE = :feature_flag_test
def setup
super
ShopifyCli::Core::Monorail.stubs(:log).yields
end
def test_help_argument_calls_help
@context.expects(:puts).with(ShopifyCli::Commands::Config.help)
run_cmd('config help')
end
def test_feature_help_argument_calls_help
@context.expects(:puts).with(ShopifyCli::Commands::Config::Feature.help)
run_cmd('config feature --help')
end
def test_analytics_help_argument_calls_help
@context.expects(:puts).with(ShopifyCli::Commands::Config::Analytics.help)
run_cmd('config analytics --help')
end
def test_no_arguments_calls_help
@context.expects(:puts).with(ShopifyCli::Commands::Config.help)
run_cmd('config')
end
def test_no_feature_calls_help
@context.expects(:puts).with(ShopifyCli::Commands::Config.help)
run_cmd('config feature')
end
def test_will_enable_a_feature_that_is_disabled
ShopifyCli::Feature.disable(TEST_FEATURE)
@context.expects(:puts).with(@context.message('core.config.feature.enabled', TEST_FEATURE))
run_cmd("config feature #{TEST_FEATURE} --enable")
assert ShopifyCli::Feature.enabled?(TEST_FEATURE)
end
def test_will_disable_a_feature_that_is_enabled
ShopifyCli::Feature.enable(TEST_FEATURE)
@context.expects(:puts).with(@context.message('core.config.feature.disabled', TEST_FEATURE))
run_cmd("config feature #{TEST_FEATURE} --disable")
refute ShopifyCli::Feature.enabled?(TEST_FEATURE)
end
def test_will_enable_analytics_that_is_disabled
ShopifyCli::Config.set('analytics', 'enabled', false)
run_cmd("config analytics --enable")
assert ShopifyCli::Config.get_bool('analytics', 'enabled')
end
def test_will_disable_analytics_that_is_enabled
ShopifyCli::Config.set('analytics', 'enabled', true)
run_cmd("config analytics --disable")
refute ShopifyCli::Config.get_bool('analytics', 'enabled')
end
end
end
end