stack_master 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/stack_master/commands/terminal_helper.rb +14 -1
- data/lib/stack_master/parameter_resolvers/secret.rb +7 -2
- data/lib/stack_master/version.rb +1 -1
- metadata +21 -216
- data/.gitignore +0 -18
- data/.rspec +0 -2
- data/.travis.yml +0 -12
- data/CODE_OF_CONDUCT.md +0 -73
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/Rakefile +0 -27
- data/apply_demo.gif +0 -0
- data/example/simple/Gemfile +0 -3
- data/example/simple/parameters/myapp_vpc.yml +0 -1
- data/example/simple/parameters/myapp_web.yml +0 -2
- data/example/simple/stack_master.yml +0 -13
- data/example/simple/templates/myapp_vpc.rb +0 -39
- data/example/simple/templates/myapp_web.rb +0 -16
- data/features/apply.feature +0 -392
- data/features/apply_with_compile_time_parameters.feature +0 -93
- data/features/apply_with_env_parameters.feature +0 -49
- data/features/apply_with_parameter_store_parameters.feature +0 -47
- data/features/apply_with_s3.feature +0 -106
- data/features/delete.feature +0 -29
- data/features/diff.feature +0 -179
- data/features/events.feature +0 -33
- data/features/init.feature +0 -6
- data/features/outputs.feature +0 -45
- data/features/region_aliases.feature +0 -62
- data/features/resources.feature +0 -42
- data/features/stack_defaults.feature +0 -82
- data/features/status.feature +0 -118
- data/features/step_definitions/parameter_store_steps.rb +0 -14
- data/features/step_definitions/stack_steps.rb +0 -71
- data/features/support/env.rb +0 -16
- data/features/validate.feature +0 -46
- data/logo.png +0 -0
- data/script/buildkite/bundle.sh +0 -5
- data/script/buildkite/clean.sh +0 -3
- data/script/buildkite_rspec.sh +0 -27
- data/spec/fixtures/parameters/myapp_vpc.yml +0 -1
- data/spec/fixtures/parameters/myapp_vpc_with_secrets.yml +0 -3
- data/spec/fixtures/sparkle_pack_integration/my_sparkle_pack/lib/my_sparkle_pack.rb +0 -1
- data/spec/fixtures/sparkle_pack_integration/my_sparkle_pack/lib/sparkleformation/dynamics/my_dynamic.rb +0 -5
- data/spec/fixtures/sparkle_pack_integration/templates/dynamics/local_dynamic.rb +0 -5
- data/spec/fixtures/sparkle_pack_integration/templates/template_with_dynamic.rb +0 -3
- data/spec/fixtures/sparkle_pack_integration/templates/template_with_dynamic_from_pack.rb +0 -3
- data/spec/fixtures/stack_master.yml +0 -49
- data/spec/fixtures/templates/json/valid_myapp_vpc.json +0 -53
- data/spec/fixtures/templates/myapp_vpc.json +0 -1
- data/spec/fixtures/templates/rb/cfndsl/sample.json +0 -28
- data/spec/fixtures/templates/rb/cfndsl/sample.rb +0 -16
- data/spec/fixtures/templates/yml/valid_myapp_vpc.yml +0 -35
- data/spec/fixtures/test/.gitkeep +0 -0
- data/spec/spec_helper.rb +0 -102
- data/spec/stack_master/aws_driver/s3_spec.rb +0 -130
- data/spec/stack_master/change_set_spec.rb +0 -70
- data/spec/stack_master/command_spec.rb +0 -66
- data/spec/stack_master/commands/apply_spec.rb +0 -259
- data/spec/stack_master/commands/delete_spec.rb +0 -40
- data/spec/stack_master/commands/init_spec.rb +0 -17
- data/spec/stack_master/commands/status_spec.rb +0 -44
- data/spec/stack_master/commands/validate_spec.rb +0 -27
- data/spec/stack_master/config_spec.rb +0 -153
- data/spec/stack_master/paged_response_accumulator_spec.rb +0 -39
- data/spec/stack_master/parameter_loader_spec.rb +0 -110
- data/spec/stack_master/parameter_resolver_spec.rb +0 -148
- data/spec/stack_master/parameter_resolvers/ami_finder_spec.rb +0 -68
- data/spec/stack_master/parameter_resolvers/env_spec.rb +0 -35
- data/spec/stack_master/parameter_resolvers/latest_ami_by_tags_spec.rb +0 -33
- data/spec/stack_master/parameter_resolvers/latest_ami_spec.rb +0 -46
- data/spec/stack_master/parameter_resolvers/parameter_store_spec.rb +0 -50
- data/spec/stack_master/parameter_resolvers/secret_spec.rb +0 -66
- data/spec/stack_master/parameter_resolvers/security_group_spec.rb +0 -19
- data/spec/stack_master/parameter_resolvers/security_groups_spec.rb +0 -32
- data/spec/stack_master/parameter_resolvers/sns_topic_name_spec.rb +0 -43
- data/spec/stack_master/parameter_resolvers/stack_output_spec.rb +0 -127
- data/spec/stack_master/prompter_spec.rb +0 -23
- data/spec/stack_master/resolver_array_spec.rb +0 -42
- data/spec/stack_master/security_group_finder_spec.rb +0 -49
- data/spec/stack_master/sns_topic_finder_spec.rb +0 -25
- data/spec/stack_master/sparkle_formation/compile_time/allowed_pattern_validator_spec.rb +0 -47
- data/spec/stack_master/sparkle_formation/compile_time/allowed_values_validator_spec.rb +0 -47
- data/spec/stack_master/sparkle_formation/compile_time/definitions_validator_spec.rb +0 -36
- data/spec/stack_master/sparkle_formation/compile_time/empty_validator_spec.rb +0 -47
- data/spec/stack_master/sparkle_formation/compile_time/max_length_validator_spec.rb +0 -37
- data/spec/stack_master/sparkle_formation/compile_time/max_size_validator_spec.rb +0 -27
- data/spec/stack_master/sparkle_formation/compile_time/min_length_validator_spec.rb +0 -36
- data/spec/stack_master/sparkle_formation/compile_time/min_size_validator_spec.rb +0 -28
- data/spec/stack_master/sparkle_formation/compile_time/number_validator_spec.rb +0 -41
- data/spec/stack_master/sparkle_formation/compile_time/parameters_validator_spec.rb +0 -65
- data/spec/stack_master/sparkle_formation/compile_time/state_builder_spec.rb +0 -28
- data/spec/stack_master/sparkle_formation/compile_time/string_validator_spec.rb +0 -35
- data/spec/stack_master/sparkle_formation/compile_time/value_build_spec.rb +0 -52
- data/spec/stack_master/sparkle_formation/compile_time/value_validator_factory_spec.rb +0 -40
- data/spec/stack_master/sparkle_formation/template_file_spec.rb +0 -147
- data/spec/stack_master/stack_definition_spec.rb +0 -70
- data/spec/stack_master/stack_differ_spec.rb +0 -46
- data/spec/stack_master/stack_events/fetcher_spec.rb +0 -40
- data/spec/stack_master/stack_events/presenter_spec.rb +0 -18
- data/spec/stack_master/stack_events/streamer_spec.rb +0 -47
- data/spec/stack_master/stack_spec.rb +0 -184
- data/spec/stack_master/template_compiler_spec.rb +0 -39
- data/spec/stack_master/template_compilers/cfndsl_spec.rb +0 -22
- data/spec/stack_master/template_compilers/json_spec.rb +0 -32
- data/spec/stack_master/template_compilers/sparkle_formation_spec.rb +0 -116
- data/spec/stack_master/template_compilers/yaml_spec.rb +0 -20
- data/spec/stack_master/template_utils_spec.rb +0 -21
- data/spec/stack_master/test_driver/cloud_formation_spec.rb +0 -64
- data/spec/stack_master/test_driver/s3_spec.rb +0 -17
- data/spec/stack_master/utils_spec.rb +0 -30
- data/spec/stack_master/validator_spec.rb +0 -56
- data/spec/stack_master_spec.rb +0 -81
- data/spec/support/gemfiles/Gemfile.activesupport-4.0.0 +0 -5
- data/spec/support/validator_spec.rb +0 -23
- data/stack_master.gemspec +0 -46
- data/stacktemplates/parameter_region.yml +0 -3
- data/stacktemplates/parameter_stack_name.yml +0 -3
- data/stacktemplates/stack.json.erb +0 -20
- data/stacktemplates/stack_master.yml.erb +0 -6
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
RSpec.describe StackMaster::Prompter do
|
|
2
|
-
include StackMaster::Prompter
|
|
3
|
-
|
|
4
|
-
context 'when STDIN is not a TTY' do
|
|
5
|
-
before do
|
|
6
|
-
allow(StackMaster.stdin).to receive(:tty?).and_return(false)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it 'defaults to no and outputs info about -y' do
|
|
10
|
-
expect { ask?('blah') }.to output(/To force yes use -y/).to_stdout
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
context 'when STDOUT is not a TTY' do
|
|
15
|
-
before do
|
|
16
|
-
allow(StackMaster.stdout).to receive(:tty?).and_return(false)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'defaults to no and outputs info about -y' do
|
|
20
|
-
expect { ask?('blah') }.to output(/To force yes use -y/).to_stdout
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
require 'stack_master/resolver_array'
|
|
2
|
-
|
|
3
|
-
RSpec.shared_examples_for 'a resolver' do
|
|
4
|
-
it 'should create a TestResolvers class' do
|
|
5
|
-
expect(array_resolver_class).to be_a Class
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it 'should have TestResolver as a resolver class' do
|
|
9
|
-
expect(array_resolver_instance).to respond_to :resolver_class
|
|
10
|
-
expect(array_resolver_instance.resolver_class).to be TestResolver
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
RSpec.describe 'StackMaster::ParameterResolvers::Resolver' do
|
|
15
|
-
let(:array_resolver_instance) { array_resolver_class.new(nil, nil) }
|
|
16
|
-
|
|
17
|
-
describe '.array_resolver' do
|
|
18
|
-
context 'when using a default name' do
|
|
19
|
-
before do
|
|
20
|
-
class TestResolver < StackMaster::ParameterResolvers::Resolver
|
|
21
|
-
array_resolver
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
let(:array_resolver_class) { StackMaster::ParameterResolvers::TestResolvers }
|
|
26
|
-
|
|
27
|
-
it_behaves_like 'a resolver'
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context 'when using a specific name' do
|
|
31
|
-
before do
|
|
32
|
-
class TestResolver < StackMaster::ParameterResolvers::Resolver
|
|
33
|
-
array_resolver class_name: 'SpecificResolver'
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
let(:array_resolver_class) { StackMaster::ParameterResolvers::SpecificResolver }
|
|
38
|
-
|
|
39
|
-
it_behaves_like 'a resolver'
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
RSpec.describe StackMaster::SecurityGroupFinder do
|
|
2
|
-
subject(:finder) { described_class.new(region) }
|
|
3
|
-
let(:region) { 'us-east-1' }
|
|
4
|
-
let(:group_name) { "our-api-BeanstalkSg-T4RKD99YOY2F" }
|
|
5
|
-
let(:filter) do
|
|
6
|
-
{
|
|
7
|
-
filters: [
|
|
8
|
-
{
|
|
9
|
-
name: "group-name",
|
|
10
|
-
values: [group_name],
|
|
11
|
-
},
|
|
12
|
-
],
|
|
13
|
-
}
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
describe "#find" do
|
|
17
|
-
before do
|
|
18
|
-
allow_any_instance_of(Aws::EC2::Resource).to receive(:security_groups).with(filter).and_return(security_groups)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
context "one sg match" do
|
|
22
|
-
let(:security_groups) { [
|
|
23
|
-
double(id: 'sg-a7d2ccc0')
|
|
24
|
-
] }
|
|
25
|
-
it "returns the id" do
|
|
26
|
-
expect(finder.find(group_name)).to eq 'sg-a7d2ccc0'
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context "more than one sg matches" do
|
|
31
|
-
let(:security_groups) { [
|
|
32
|
-
double(id: 'sg-a7d2ccc0'),
|
|
33
|
-
double(id: 'sg-a7d2ccc2'),
|
|
34
|
-
] }
|
|
35
|
-
it "returns the id" do
|
|
36
|
-
err = StackMaster::SecurityGroupFinder::MultipleSecurityGroupsFound
|
|
37
|
-
expect { finder.find(group_name) }.to raise_error(err)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
context "no matches" do
|
|
42
|
-
let(:security_groups) { [] }
|
|
43
|
-
it "returns the id" do
|
|
44
|
-
err = StackMaster::SecurityGroupFinder::SecurityGroupNotFound
|
|
45
|
-
expect { finder.find(group_name) }.to raise_error(err)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
RSpec.describe StackMaster::SnsTopicFinder do
|
|
2
|
-
|
|
3
|
-
subject(:finder) { described_class.new(region) }
|
|
4
|
-
let(:region) { 'us-east-1' }
|
|
5
|
-
let(:topics) do
|
|
6
|
-
[
|
|
7
|
-
double(arn: 'arn:aws:sns:us-east-1:581634149801:topic1name'),
|
|
8
|
-
double(arn: 'arn:aws:sns:us-east-1:581634149801:topic2name'),
|
|
9
|
-
]
|
|
10
|
-
end
|
|
11
|
-
before do
|
|
12
|
-
allow_any_instance_of(Aws::SNS::Resource).to receive(:topics).and_return topics
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
describe '#find' do
|
|
16
|
-
it 'finds the topics that exist' do
|
|
17
|
-
expect(finder.find('topic1name')).to eq 'arn:aws:sns:us-east-1:581634149801:topic1name'
|
|
18
|
-
expect(finder.find('topic2name')).to eq 'arn:aws:sns:us-east-1:581634149801:topic2name'
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'raises an exception for topics that do not exist' do
|
|
22
|
-
expect { finder.find('unknowntopics') }.to raise_error StackMaster::SnsTopicFinder::TopicNotFound
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
RSpec.describe StackMaster::SparkleFormation::CompileTime::AllowedPatternValidator do
|
|
2
|
-
|
|
3
|
-
describe '#validate' do
|
|
4
|
-
let(:name) { 'name' }
|
|
5
|
-
let(:error_message) { -> (error, definition) { "#{name}:#{error} does not match allowed_pattern:#{definition[:allowed_pattern]}" } }
|
|
6
|
-
|
|
7
|
-
context 'string validation' do
|
|
8
|
-
let(:definition) { {type: :string, allowed_pattern: '^a'} }
|
|
9
|
-
validate_valid_parameter('a')
|
|
10
|
-
validate_valid_parameter(['a'])
|
|
11
|
-
validate_invalid_parameter('b', ['b'])
|
|
12
|
-
validate_invalid_parameter(['b'], ['b'])
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
context 'string validation with default' do
|
|
16
|
-
let(:definition) { {type: :string, allowed_pattern: '^a', default: 'a'} }
|
|
17
|
-
validate_valid_parameter(nil)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context 'string validation with multiple' do
|
|
21
|
-
let(:definition) { {type: :string, allowed_pattern: '^a', multiple: true} }
|
|
22
|
-
validate_valid_parameter('a,ab')
|
|
23
|
-
validate_invalid_parameter('a,,ab', [''])
|
|
24
|
-
validate_invalid_parameter('a, ,ab', [''])
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
context 'string validation with multiple default values' do
|
|
28
|
-
let(:definition) { {type: :string, allowed_pattern: '^a', multiple: true, default:'a,a'} }
|
|
29
|
-
validate_valid_parameter(nil)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
context 'numerical validation' do
|
|
33
|
-
let(:definition) { {type: :number, allowed_pattern: '^1'} }
|
|
34
|
-
validate_valid_parameter(1)
|
|
35
|
-
validate_valid_parameter('1')
|
|
36
|
-
validate_valid_parameter([1])
|
|
37
|
-
validate_valid_parameter(['1'])
|
|
38
|
-
validate_invalid_parameter(2, [2])
|
|
39
|
-
validate_invalid_parameter('2', ['2'])
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context 'validation with default value' do
|
|
43
|
-
let(:definition) { {type: :number, allowed_pattern: '^1', default: '1'} }
|
|
44
|
-
validate_valid_parameter(nil)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
RSpec.describe StackMaster::SparkleFormation::CompileTime::AllowedValuesValidator do
|
|
2
|
-
|
|
3
|
-
describe '#validate' do
|
|
4
|
-
let(:name) { 'name' }
|
|
5
|
-
let(:error_message) { -> (error, definition) { "#{name}:#{error} is not in allowed_values:#{definition[:allowed_values]}" } }
|
|
6
|
-
|
|
7
|
-
context 'string validation' do
|
|
8
|
-
let(:definition) { {type: :string, allowed_values: ['a']} }
|
|
9
|
-
validate_valid_parameter('a')
|
|
10
|
-
validate_valid_parameter(['a'])
|
|
11
|
-
validate_invalid_parameter('b', ['b'])
|
|
12
|
-
validate_invalid_parameter(['b'], ['b'])
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
context 'string validation with default' do
|
|
16
|
-
let(:definition) { {type: :string, allowed_values: ['a'], default:'a'} }
|
|
17
|
-
validate_valid_parameter(nil)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context 'string validation with multiple' do
|
|
21
|
-
let(:definition) { {type: :string, allowed_values: ['a'], multiple: true} }
|
|
22
|
-
validate_valid_parameter('a,a')
|
|
23
|
-
validate_invalid_parameter( 'a,, a', [''])
|
|
24
|
-
validate_invalid_parameter( 'a,,b', ['', 'b'])
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
context 'string validation with multiple default values' do
|
|
28
|
-
let(:definition) { {type: :string, allowed_values: ['a'], multiple: true, default: 'a,a'} }
|
|
29
|
-
validate_valid_parameter(nil)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
context 'numerical validation' do
|
|
33
|
-
let(:definition) { {type: :number, allowed_values: [1]} }
|
|
34
|
-
validate_valid_parameter(1)
|
|
35
|
-
validate_valid_parameter('1')
|
|
36
|
-
validate_valid_parameter([1])
|
|
37
|
-
validate_valid_parameter(['1'])
|
|
38
|
-
validate_invalid_parameter(2, [2])
|
|
39
|
-
validate_invalid_parameter('2', ['2'])
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context 'numerical validation with default value' do
|
|
43
|
-
let(:definition) { {type: :number, allowed_values: [1], default: 1} }
|
|
44
|
-
validate_valid_parameter(nil)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
RSpec.describe StackMaster::SparkleFormation::CompileTime::DefinitionsValidator do
|
|
2
|
-
|
|
3
|
-
describe '#validate' do
|
|
4
|
-
|
|
5
|
-
let(:key) {:key}
|
|
6
|
-
let(:definition){ {key: {type: type}} }
|
|
7
|
-
|
|
8
|
-
subject {described_class.new(definition)}
|
|
9
|
-
|
|
10
|
-
[:string, :number].each do |type|
|
|
11
|
-
|
|
12
|
-
context "with :#{type} type definition" do
|
|
13
|
-
|
|
14
|
-
let(:type) {type}
|
|
15
|
-
|
|
16
|
-
it 'should not raise an exception' do
|
|
17
|
-
expect {subject.validate}.to_not raise_error
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
context 'with other type definition' do
|
|
25
|
-
|
|
26
|
-
let(:type) {:other}
|
|
27
|
-
|
|
28
|
-
it 'should not raise an exception' do
|
|
29
|
-
expect {subject.validate}.to raise_error(ArgumentError, "Unknown compile time parameter type: #{key}:#{type} valid types are #{[:string, :number]}")
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
RSpec.describe StackMaster::SparkleFormation::CompileTime::EmptyValidator do
|
|
2
|
-
|
|
3
|
-
describe '#validate' do
|
|
4
|
-
let(:name) { 'name' }
|
|
5
|
-
let(:error_message) { -> (error, _definition) { "#{name} cannot contain empty parameters:#{error.inspect}" } }
|
|
6
|
-
|
|
7
|
-
context 'string validation' do
|
|
8
|
-
let(:definition) { {type: :string} }
|
|
9
|
-
validate_valid_parameter('a')
|
|
10
|
-
validate_valid_parameter(['a'])
|
|
11
|
-
validate_invalid_parameter(nil, nil)
|
|
12
|
-
validate_invalid_parameter(['a', nil], ['a', nil])
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
context 'string validation with default' do
|
|
16
|
-
let(:definition) { {type: :string, default: 'a'} }
|
|
17
|
-
validate_valid_parameter(nil)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context 'string validation with multiples' do
|
|
21
|
-
let(:definition) { {type: :string, multiple: true} }
|
|
22
|
-
validate_valid_parameter('a,b')
|
|
23
|
-
validate_invalid_parameter('a,,b', 'a,,b')
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
context 'string validation with multiples and defaults' do
|
|
27
|
-
let(:definition) { {type: :string, multiple: true, default: 'a,b'} }
|
|
28
|
-
validate_valid_parameter(nil)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context 'numerical validation' do
|
|
32
|
-
let(:definition) { {type: :number} }
|
|
33
|
-
validate_valid_parameter(1)
|
|
34
|
-
validate_valid_parameter('1')
|
|
35
|
-
validate_valid_parameter([1])
|
|
36
|
-
validate_valid_parameter(['1'])
|
|
37
|
-
validate_invalid_parameter(nil, nil)
|
|
38
|
-
validate_invalid_parameter([1, nil], [1, nil])
|
|
39
|
-
validate_invalid_parameter(['1', nil], ['1', nil])
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context 'numerical validation with default' do
|
|
43
|
-
let(:definition) { {type: :number, default: '1'} }
|
|
44
|
-
validate_valid_parameter(nil)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
RSpec.describe StackMaster::SparkleFormation::CompileTime::MaxLengthValidator do
|
|
2
|
-
|
|
3
|
-
describe '#validate' do
|
|
4
|
-
let(:name) { 'name' }
|
|
5
|
-
let(:error_message) { -> (error, definition) { "#{name}:#{error} must not exceed max_length:#{definition[:max_length]} characters" } }
|
|
6
|
-
|
|
7
|
-
context 'string validation' do
|
|
8
|
-
let(:definition) { {type: :string, max_length: 1} }
|
|
9
|
-
validate_valid_parameter('a')
|
|
10
|
-
validate_valid_parameter(['a'])
|
|
11
|
-
validate_invalid_parameter('ab', ['ab'])
|
|
12
|
-
validate_invalid_parameter(['ab'], ['ab'])
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
context 'string validation with default value' do
|
|
16
|
-
let(:definition) { {type: :string, max_length: 1, default: 'a'} }
|
|
17
|
-
validate_valid_parameter(nil)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context 'string validation with multiples' do
|
|
21
|
-
let(:definition) { {type: :string, max_length: 1, multiple: true} }
|
|
22
|
-
validate_valid_parameter('a,a')
|
|
23
|
-
validate_valid_parameter('a,,a')
|
|
24
|
-
validate_invalid_parameter('a,, ab', ['ab'])
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
context 'string validation wtih multiples and default' do
|
|
28
|
-
let(:definition) { {type: :string, max_length: 1, multiple: true, default: 'a,a'} }
|
|
29
|
-
validate_valid_parameter(nil)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
context 'numerical validation' do
|
|
33
|
-
let(:definition) { {type: :number, max_length: 1} }
|
|
34
|
-
validate_valid_parameter('ab')
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
RSpec.describe StackMaster::SparkleFormation::CompileTime::MaxSizeValidator do
|
|
2
|
-
|
|
3
|
-
describe '#validate' do
|
|
4
|
-
let(:name) { 'name' }
|
|
5
|
-
let(:error_message) { -> (error, definition) { "#{name}:#{error} must not be greater than max_size:#{definition[:max_size]}" } }
|
|
6
|
-
|
|
7
|
-
context 'numerical validation' do
|
|
8
|
-
let(:definition) { {type: :number, max_size: 1} }
|
|
9
|
-
validate_valid_parameter(1)
|
|
10
|
-
validate_valid_parameter('1')
|
|
11
|
-
validate_valid_parameter([1])
|
|
12
|
-
validate_valid_parameter(['1'])
|
|
13
|
-
validate_invalid_parameter(2, [2])
|
|
14
|
-
validate_invalid_parameter('2', ['2'])
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
context 'numerical validation with default' do
|
|
18
|
-
let(:definition) { {type: :number, max_size: 1, default: 1} }
|
|
19
|
-
validate_valid_parameter(nil)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
context 'string validation' do
|
|
23
|
-
let(:definition) { {type: :string, max_size: 1} }
|
|
24
|
-
validate_valid_parameter(2)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
RSpec.describe StackMaster::SparkleFormation::CompileTime::MinLengthValidator do
|
|
2
|
-
|
|
3
|
-
describe '#validate' do
|
|
4
|
-
let(:name) { 'name' }
|
|
5
|
-
let(:error_message) { -> (error, definition) { "#{name}:#{error} must be at least min_length:#{definition[:min_length]} characters" } }
|
|
6
|
-
|
|
7
|
-
context 'string validation' do
|
|
8
|
-
let(:definition) { {type: :string, min_length: 2} }
|
|
9
|
-
validate_valid_parameter('ab')
|
|
10
|
-
validate_valid_parameter(['ab'])
|
|
11
|
-
validate_invalid_parameter('a', ['a'])
|
|
12
|
-
validate_invalid_parameter(['a'], ['a'])
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
context 'string validation with default value' do
|
|
16
|
-
let(:definition) { {type: :string, min_length: 2, default: 'ab'} }
|
|
17
|
-
validate_valid_parameter(nil)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context 'string validation with multiples' do
|
|
21
|
-
let(:definition) { {type: :string, min_length: 2, multiple: true} }
|
|
22
|
-
validate_valid_parameter('ab,cd')
|
|
23
|
-
validate_invalid_parameter('a,, cd', ['a', ''])
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
context 'string validation with multiples and default' do
|
|
27
|
-
let(:definition) { {type: :string, min_length: 2, multiple: true, default: 'ab,cd'} }
|
|
28
|
-
validate_valid_parameter(nil)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context 'numerical validation' do
|
|
32
|
-
let(:definition) { {type: :number, min_length: 2} }
|
|
33
|
-
validate_valid_parameter('a')
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
RSpec.describe StackMaster::SparkleFormation::CompileTime::MinSizeValidator do
|
|
2
|
-
|
|
3
|
-
describe '#validate' do
|
|
4
|
-
let(:name) { 'name' }
|
|
5
|
-
let(:error_message) { -> (error, definition) { "#{name}:#{error} must not be lesser than min_size:#{definition[:min_size]}" } }
|
|
6
|
-
|
|
7
|
-
context 'numerical validation' do
|
|
8
|
-
let(:definition) { {type: :number, min_size: 1} }
|
|
9
|
-
validate_valid_parameter(1)
|
|
10
|
-
validate_valid_parameter('1')
|
|
11
|
-
validate_valid_parameter([1])
|
|
12
|
-
validate_valid_parameter(['1'])
|
|
13
|
-
validate_invalid_parameter(0, [0])
|
|
14
|
-
validate_invalid_parameter('0', ['0'])
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
context 'numerical validation with default value' do
|
|
18
|
-
let(:definition) { {type: :number, min_size: 1, default: 1} }
|
|
19
|
-
validate_valid_parameter(nil)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
context 'string validation' do
|
|
23
|
-
let(:definition) { {type: :string, min_size: 1} }
|
|
24
|
-
validate_valid_parameter(0)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
end
|
|
28
|
-
end
|