sensu-settings 0.0.7 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 690063711717849124c05c9309e8de85ff2acb18
4
- data.tar.gz: d428097e014e10a55908740b4e674845ca3f629c
3
+ metadata.gz: ef6d260f3a69448e3a303ce08ce763250d7b7d19
4
+ data.tar.gz: 014d25fbb63da7810ca2ad80172d9712e6912906
5
5
  SHA512:
6
- metadata.gz: bd127578469e2dfd40ba961e7a5424ac4d226fab9de7fe5648675070817a4929f400ff3edf9735543827ae665732e18c350c09cd6fe8a40ea2331618213090a9
7
- data.tar.gz: eb0d64cedec2802613cc59b9f7d00146f83b0904c03b830c51c230e385974baa157118a8c069328bf7554fddbe73ccef9407b9a36f9abd015e3fa3b4d25d6b6c
6
+ metadata.gz: 500751d2e63b018ae29ac8d93fc1dfe2452df2175271a48e50a98c65eb2d236fe1a0946aa79520f17b1780bd18e6da3eb664e8a894562c5928ec68a986026961
7
+ data.tar.gz: 57bc19aa368477c6dd317538fdefb12ad67ab4818bb7cd7832e838c46e2f0f35356e8b913474b8b83ac9edb5211b3f3eaf1608bb68ea5f38b309b6dc34325b8d
@@ -89,7 +89,7 @@ module Sensu
89
89
  # @param value [Object] to check if matches pattern.
90
90
  # @return [TrueClass, FalseClass]
91
91
  def must_match_regex(regex, value)
92
- value =~ regex
92
+ (value =~ regex) == 0
93
93
  end
94
94
 
95
95
  # Check if a value is boolean, if set (no nil).
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sensu-settings"
5
- spec.version = "0.0.7"
5
+ spec.version = "1.0.0"
6
6
  spec.authors = ["Sean Porter"]
7
7
  spec.email = ["portertech@gmail.com"]
8
8
  spec.summary = "The Sensu settings library, loader and validator"
data/spec/loader_spec.rb CHANGED
@@ -12,37 +12,37 @@ describe "Sensu::Settings::Loader" do
12
12
  end
13
13
 
14
14
  it "can provide a loader API" do
15
- @loader.should respond_to(:load_env, :load_file, :load_directory, :set_env!, :validate)
15
+ expect(@loader).to respond_to(:load_env, :load_file, :load_directory, :set_env!, :validate)
16
16
  end
17
17
 
18
18
  it "can provide indifferent access to settings" do
19
- @loader[:checks].should be_kind_of(Hash)
20
- @loader["checks"].should be_kind_of(Hash)
19
+ expect(@loader[:checks]).to be_kind_of(Hash)
20
+ expect(@loader["checks"]).to be_kind_of(Hash)
21
21
  end
22
22
 
23
23
  it "can validate loaded settings" do
24
24
  failures = @loader.validate
25
- failures.size.should eq(0)
25
+ expect(failures.size).to eq(0)
26
26
  end
27
27
 
28
28
  it "can load RabbitMQ settings from the environment" do
29
29
  ENV["RABBITMQ_URL"] = "amqp://guest:guest@localhost:5672/"
30
30
  @loader.load_env
31
- @loader.warnings.size.should eq(1)
31
+ expect(@loader.warnings.size).to eq(1)
32
32
  ENV["RABBITMQ_URL"] = nil
33
33
  end
34
34
 
35
35
  it "can load Redis settings from the environment" do
36
36
  ENV["REDIS_URL"] = "redis://username:password@localhost:6789"
37
37
  @loader.load_env
38
- @loader.warnings.size.should eq(1)
38
+ expect(@loader.warnings.size).to eq(1)
39
39
  ENV["REDIS_URL"] = nil
40
40
  end
41
41
 
42
42
  it "can load Sensu API settings from the environment" do
43
43
  ENV["API_PORT"] = "4567"
44
44
  @loader.load_env
45
- @loader.warnings.size.should eq(1)
45
+ expect(@loader.warnings.size).to eq(1)
46
46
  ENV["API_PORT"] = nil
47
47
  end
48
48
 
@@ -50,19 +50,19 @@ describe "Sensu::Settings::Loader" do
50
50
  ENV["REDISTOGO_URL"] = "redis://username:password@localhost:6789"
51
51
  ENV["PORT"] = "4567"
52
52
  @loader.load_env
53
- @loader.warnings.size.should eq(2)
53
+ expect(@loader.warnings.size).to eq(2)
54
54
  ENV["REDISTOGO_URL"] = nil
55
55
  ENV["PORT"] = nil
56
56
  end
57
57
 
58
58
  it "can load settings from a file" do
59
59
  @loader.load_file(@config_file)
60
- @loader.warnings.size.should eq(1)
60
+ expect(@loader.warnings.size).to eq(1)
61
61
  warning = @loader.warnings.first
62
- warning[:file].should eq(File.expand_path(@config_file))
63
- warning[:message].should eq("loading config file")
64
- @loader[:api][:port].should eq(4567)
65
- @loader["api"]["port"].should eq(4567)
62
+ expect(warning[:file]).to eq(File.expand_path(@config_file))
63
+ expect(warning[:message]).to eq("loading config file")
64
+ expect(@loader[:api][:port]).to eq(4567)
65
+ expect(@loader["api"]["port"]).to eq(4567)
66
66
  end
67
67
 
68
68
  it "can load settings from a file and validate them" do
@@ -71,99 +71,99 @@ describe "Sensu::Settings::Loader" do
71
71
  reasons = failures.map do |failure|
72
72
  failure[:message]
73
73
  end
74
- reasons.should include("check interval must be an integer")
74
+ expect(reasons).to include("check interval must be an integer")
75
75
  end
76
76
 
77
77
  it "can attempt to load settings from a nonexistent file" do
78
78
  @loader.load_file("/tmp/bananaphone")
79
79
  warnings = @loader.warnings
80
- warnings.size.should eq(2)
80
+ expect(warnings.size).to eq(2)
81
81
  messages = warnings.map do |warning|
82
82
  warning[:message]
83
83
  end
84
- messages.should include("config file does not exist or is not readable")
85
- messages.should include("ignoring config file")
84
+ expect(messages).to include("config file does not exist or is not readable")
85
+ expect(messages).to include("ignoring config file")
86
86
  end
87
87
 
88
88
  it "can attempt to load settings from a file with invalid JSON" do
89
89
  @loader.load_file(File.join(@assets_dir, "invalid.json"))
90
90
  warnings = @loader.warnings
91
- warnings.size.should eq(3)
91
+ expect(warnings.size).to eq(3)
92
92
  messages = warnings.map do |warning|
93
93
  warning[:message]
94
94
  end
95
- messages.should include("loading config file")
96
- messages.should include("config file must be valid json")
97
- messages.should include("ignoring config file")
95
+ expect(messages).to include("loading config file")
96
+ expect(messages).to include("config file must be valid json")
97
+ expect(messages).to include("ignoring config file")
98
98
  end
99
99
 
100
100
  it "can load settings from files in a directory" do
101
101
  @loader.load_directory(@config_dir)
102
102
  warnings = @loader.warnings
103
- warnings.size.should eq(4)
103
+ expect(warnings.size).to eq(4)
104
104
  messages = warnings.map do |warning|
105
105
  warning[:message]
106
106
  end
107
- messages.should include("loading config files from directory")
108
- messages.should include("loading config file")
109
- messages.should include("config file applied changes")
110
- @loader[:checks][:nested][:command].should eq("true")
107
+ expect(messages).to include("loading config files from directory")
108
+ expect(messages).to include("loading config file")
109
+ expect(messages).to include("config file applied changes")
110
+ expect(@loader[:checks][:nested][:command]).to eq("true")
111
111
  end
112
112
 
113
113
  it "can attempt to load settings from files in a nonexistent directory" do
114
114
  @loader.load_directory("/tmp/rottentomatos")
115
- @loader.warnings.size.should eq(1)
115
+ expect(@loader.warnings.size).to eq(1)
116
116
  warning = @loader.warnings.first
117
- warning[:message].should eq("loading config files from directory")
117
+ expect(warning[:message]).to eq("loading config files from directory")
118
118
  end
119
119
 
120
120
  it "can set environment variables for child processes" do
121
121
  @loader.load_file(@config_file)
122
122
  @loader.load_directory(@config_dir)
123
- @loader.loaded_files.size.should eq(3)
123
+ expect(@loader.loaded_files.size).to eq(3)
124
124
  @loader.set_env!
125
- ENV["SENSU_CONFIG_FILES"].split(":").should eq(@loader.loaded_files)
125
+ expect(ENV["SENSU_CONFIG_FILES"].split(":")).to eq(@loader.loaded_files)
126
126
  end
127
127
 
128
128
  it "can load settings and determine if certain definitions exist" do
129
129
  @loader.load_file(@config_file)
130
130
  @loader.load_directory(@config_dir)
131
- @loader.check_exists?("nonexistent").should be_false
132
- @loader.check_exists?("tokens").should be_true
133
- @loader.filter_exists?("nonexistent").should be_false
134
- @loader.filter_exists?("development").should be_true
135
- @loader.mutator_exists?("nonexistent").should be_false
136
- @loader.mutator_exists?("noop").should be_true
137
- @loader.handler_exists?("nonexistent").should be_false
138
- @loader.handler_exists?("default").should be_true
131
+ expect(@loader.check_exists?("nonexistent")).to be(false)
132
+ expect(@loader.check_exists?("tokens")).to be(true)
133
+ expect(@loader.filter_exists?("nonexistent")).to be(false)
134
+ expect(@loader.filter_exists?("development")).to be(true)
135
+ expect(@loader.mutator_exists?("nonexistent")).to be(false)
136
+ expect(@loader.mutator_exists?("noop")).to be(true)
137
+ expect(@loader.handler_exists?("nonexistent")).to be(false)
138
+ expect(@loader.handler_exists?("default")).to be(true)
139
139
  end
140
140
 
141
141
  it "can load settings and provide setting category accessors" do
142
142
  @loader.load_file(@config_file)
143
143
  @loader.load_directory(@config_dir)
144
- @loader.checks.should be_kind_of(Array)
145
- @loader.checks.should_not be_empty
144
+ expect(@loader.checks).to be_kind_of(Array)
145
+ expect(@loader.checks).to_not be_empty
146
146
  check = @loader.checks.detect do |check|
147
147
  check[:name] == "tokens"
148
148
  end
149
- check[:interval].should eq(1)
150
- @loader.filters.should be_kind_of(Array)
151
- @loader.filters.should_not be_empty
149
+ expect(check[:interval]).to eq(1)
150
+ expect(@loader.filters).to be_kind_of(Array)
151
+ expect(@loader.filters).to_not be_empty
152
152
  filter = @loader.filters.detect do |filter|
153
153
  filter[:name] == "development"
154
154
  end
155
- filter[:negate].should be_true
156
- @loader.mutators.should be_kind_of(Array)
157
- @loader.mutators.should_not be_empty
155
+ expect(filter[:negate]).to be(true)
156
+ expect(@loader.mutators).to be_kind_of(Array)
157
+ expect(@loader.mutators).to_not be_empty
158
158
  mutator = @loader.mutators.detect do |mutator|
159
159
  mutator[:name] == "noop"
160
160
  end
161
- mutator[:command].should eq("cat")
162
- @loader.handlers.should be_kind_of(Array)
163
- @loader.handlers.should_not be_empty
161
+ expect(mutator[:command]).to eq("cat")
162
+ expect(@loader.handlers).to be_kind_of(Array)
163
+ expect(@loader.handlers).to_not be_empty
164
164
  handler = @loader.handlers.detect do |handler|
165
165
  handler[:name] == "default"
166
166
  end
167
- handler[:type].should eq("set")
167
+ expect(handler[:type]).to eq("set")
168
168
  end
169
169
  end
data/spec/rules_spec.rb CHANGED
@@ -6,60 +6,61 @@ describe "Sensu::Settings::Rules" do
6
6
  include Sensu::Settings::Rules
7
7
 
8
8
  it "can provide validation rules" do
9
- must_be_a_hash({}).should be_true
10
- must_be_a_hash("").should be_false
11
- must_be_a_hash_if_set({}).should be_true
12
- must_be_a_hash_if_set(nil).should be_true
13
- must_be_a_hash_if_set("").should be_false
14
- must_be_an_array([]).should be_true
15
- must_be_an_array("").should be_false
16
- must_be_an_array_if_set([]).should be_true
17
- must_be_an_array_if_set(nil).should be_true
18
- must_be_an_array_if_set("").should be_false
19
- must_be_a_string("").should be_true
20
- must_be_a_string(1).should be_false
21
- must_be_a_string_if_set("").should be_true
22
- must_be_a_string_if_set(nil).should be_true
23
- must_be_a_string_if_set(1).should be_false
24
- must_be_an_integer(1).should be_true
25
- must_be_an_integer("").should be_false
26
- must_be_a_numeric(1.5).should be_true
27
- must_be_a_numeric("").should be_false
28
- must_match_regex(/^foo$/, "foo").should be_true
29
- must_match_regex(/^foo$/, "bar").should be_false
30
- must_be_boolean_if_set(true).should be_true
31
- must_be_boolean_if_set(false).should be_true
32
- must_be_boolean_if_set(nil).should be_true
33
- must_be_boolean_if_set("").should be_false
34
- items_must_be_strings([]).should be_true
35
- items_must_be_strings(["test"]).should be_true
36
- items_must_be_strings([1]).should be_false
37
- items_must_be_strings([""]).should be_false
38
- either_are_set?(1).should be_true
39
- either_are_set?(1, nil).should be_true
40
- either_are_set?(nil, nil, 1).should be_true
41
- either_are_set?(1, 1).should be_true
42
- either_are_set?.should be_false
43
- either_are_set?(nil).should be_false
44
- either_are_set?(nil, nil).should be_false
45
- must_be_time("16:30").should be_true
46
- must_be_time("16:30", "21:00").should be_true
47
- must_be_time(false).should be_false
48
- must_be_time(false, "21:00").should be_false
9
+ expect(must_be_a_hash({})).to be(true)
10
+ expect(must_be_a_hash("")).to be(false)
11
+ expect(must_be_a_hash_if_set({})).to be(true)
12
+ expect(must_be_a_hash_if_set(nil)).to be(true)
13
+ expect(must_be_a_hash_if_set("")).to be(false)
14
+ expect(must_be_an_array([])).to be(true)
15
+ expect(must_be_an_array("")).to be(false)
16
+ expect(must_be_an_array_if_set([])).to be(true)
17
+ expect(must_be_an_array_if_set(nil)).to be(true)
18
+ expect(must_be_an_array_if_set("")).to be(false)
19
+ expect(must_be_a_string("")).to be(true)
20
+ expect(must_be_a_string(1)).to be(false)
21
+ expect(must_be_a_string_if_set("")).to be(true)
22
+ expect(must_be_a_string_if_set(nil)).to be(true)
23
+ expect(must_be_a_string_if_set(1)).to be(false)
24
+ expect(must_be_an_integer(1)).to be(true)
25
+ expect(must_be_an_integer("")).to be(false)
26
+ expect(must_be_a_numeric(1.5)).to be(true)
27
+ expect(must_be_a_numeric("")).to be(false)
28
+ expect(must_match_regex(/^foo$/, "foo")).to be(true)
29
+ expect(must_match_regex(/^foo$/, "bar")).to be(false)
30
+ expect(must_match_regex(/^\w+$/, "baz$")).to be(false)
31
+ expect(must_be_boolean_if_set(true)).to be(true)
32
+ expect(must_be_boolean_if_set(false)).to be(true)
33
+ expect(must_be_boolean_if_set(nil)).to be(true)
34
+ expect(must_be_boolean_if_set("")).to be(false)
35
+ expect(items_must_be_strings([])).to be(true)
36
+ expect(items_must_be_strings(["test"])).to be(true)
37
+ expect(items_must_be_strings([1])).to be(false)
38
+ expect(items_must_be_strings([""])).to be(false)
39
+ expect(either_are_set?(1)).to be(true)
40
+ expect(either_are_set?(1, nil)).to be(true)
41
+ expect(either_are_set?(nil, nil, 1)).to be(true)
42
+ expect(either_are_set?(1, 1)).to be(true)
43
+ expect(either_are_set?).to be(false)
44
+ expect(either_are_set?(nil)).to be(false)
45
+ expect(either_are_set?(nil, nil)).to be(false)
46
+ expect(must_be_time("16:30")).to be(true)
47
+ expect(must_be_time("16:30", "21:00")).to be(true)
48
+ expect(must_be_time(false)).to be(false)
49
+ expect(must_be_time(false, "21:00")).to be(false)
49
50
  unless RUBY_VERSION < "1.9"
50
- must_be_time("false").should be_false
51
- must_be_time("false", "21:00").should be_false
51
+ expect(must_be_time("false")).to be(false)
52
+ expect(must_be_time("false", "21:00")).to be(false)
52
53
  end
53
- must_be_time(1).should be_false
54
- must_be_either(%w[foo bar], "foo").should be_true
55
- must_be_either(%w[foo bar], "bar").should be_true
56
- must_be_either(%w[foo bar], ["foo", "bar"]).should be_true
57
- must_be_either(%w[foo bar], "baz").should be_false
58
- must_be_either(%w[foo bar], 1).should be_false
59
- must_be_either(%w[foo bar], nil).should be_false
60
- must_be_either(%w[foo bar], ["foo", nil]).should be_false
61
- must_be_either_if_set(%w[foo bar], "foo").should be_true
62
- must_be_either_if_set(%w[foo bar], nil).should be_true
63
- must_be_either_if_set(%w[foo bar], "baz").should be_false
54
+ expect(must_be_time(1)).to be(false)
55
+ expect(must_be_either(%w[foo bar], "foo")).to be(true)
56
+ expect(must_be_either(%w[foo bar], "bar")).to be(true)
57
+ expect(must_be_either(%w[foo bar], ["foo", "bar"])).to be(true)
58
+ expect(must_be_either(%w[foo bar], "baz")).to be(false)
59
+ expect(must_be_either(%w[foo bar], 1)).to be(false)
60
+ expect(must_be_either(%w[foo bar], nil)).to be(false)
61
+ expect(must_be_either(%w[foo bar], ["foo", nil])).to be(false)
62
+ expect(must_be_either_if_set(%w[foo bar], "foo")).to be(true)
63
+ expect(must_be_either_if_set(%w[foo bar], nil)).to be(true)
64
+ expect(must_be_either_if_set(%w[foo bar], "baz")).to be(false)
64
65
  end
65
66
  end
@@ -12,39 +12,39 @@ describe "Sensu::Settings" do
12
12
  end
13
13
 
14
14
  it "can provide a loader" do
15
- Sensu::Settings.should respond_to(:load)
16
- Sensu::Settings.load.should be_an_instance_of(Sensu::Settings::Loader)
15
+ expect(Sensu::Settings).to respond_to(:load)
16
+ expect(Sensu::Settings.load).to be_an_instance_of(Sensu::Settings::Loader)
17
17
  settings = Sensu::Settings.load
18
- settings.should respond_to(:validate)
18
+ expect(settings).to respond_to(:validate)
19
19
  end
20
20
 
21
21
  it "can retrive the current loaded loader" do
22
22
  settings = Sensu::Settings.load
23
- Sensu::Settings.get.should eq(settings)
24
- Sensu::Settings.get.should eq(settings)
23
+ expect(Sensu::Settings.get).to eq(settings)
24
+ expect(Sensu::Settings.get).to eq(settings)
25
25
  end
26
26
 
27
27
  it "can load up a loader if one doesn't exist" do
28
28
  settings = Sensu::Settings.get
29
- settings.should be_an_instance_of(Sensu::Settings::Loader)
30
- Sensu::Settings.get.should eq(settings)
29
+ expect(settings).to be_an_instance_of(Sensu::Settings::Loader)
30
+ expect(Sensu::Settings.get).to eq(settings)
31
31
  end
32
32
 
33
33
  it "can load settings from the environment, a file, and a directory" do
34
34
  ENV["RABBITMQ_URL"] = "amqp://guest:guest@localhost:5672/"
35
35
  settings = Sensu::Settings.load(:config_file => @config_file, :config_dir => @config_dir)
36
- settings[:rabbitmq].should eq(ENV["RABBITMQ_URL"])
37
- settings[:api][:port].should eq(4567)
38
- settings[:checks][:merger][:command].should eq("echo -n merger")
39
- settings[:checks][:merger][:subscribers].should eq(["foo", "bar"])
40
- settings[:checks][:nested][:command].should eq("true")
41
- ENV["SENSU_CONFIG_FILES"].split(":").should eq(settings.loaded_files)
36
+ expect(settings[:rabbitmq]).to eq(ENV["RABBITMQ_URL"])
37
+ expect(settings[:api][:port]).to eq(4567)
38
+ expect(settings[:checks][:merger][:command]).to eq("echo -n merger")
39
+ expect(settings[:checks][:merger][:subscribers]).to eq(["foo", "bar"])
40
+ expect(settings[:checks][:nested][:command]).to eq("true")
41
+ expect(ENV["SENSU_CONFIG_FILES"].split(":")).to eq(settings.loaded_files)
42
42
  ENV["RABBITMQ_URL"] = nil
43
43
  end
44
44
 
45
45
  it "can load settings from files in multiple directories" do
46
46
  settings = Sensu::Settings.load(:config_dirs => [@config_dir, @app_dir])
47
- settings[:checks][:merger][:command].should eq("echo -n merger")
48
- settings[:checks][:app_http_endpoint][:command].should eq("check-http.rb -u https://localhost/ping -q pong")
47
+ expect(settings[:checks][:merger][:command]).to eq("echo -n merger")
48
+ expect(settings[:checks][:app_http_endpoint][:command]).to eq("check-http.rb -u https://localhost/ping -q pong")
49
49
  end
50
50
  end
@@ -10,33 +10,33 @@ describe "Sensu::Settings::Validator" do
10
10
 
11
11
  it "can run, validating setting categories" do
12
12
  failures = @validator.run({})
13
- failures.should be_kind_of(Array)
13
+ expect(failures).to be_kind_of(Array)
14
14
  failures.each do |failure|
15
- failure[:object].should be_nil
15
+ expect(failure[:object]).to be(nil)
16
16
  end
17
17
  reasons = failures.map do |failure|
18
18
  failure[:message]
19
19
  end
20
- reasons.should include("checks must be a hash")
21
- reasons.should include("filters must be a hash")
22
- reasons.should include("mutators must be a hash")
23
- reasons.should include("handlers must be a hash")
24
- reasons.size.should eq(5)
20
+ expect(reasons).to include("checks must be a hash")
21
+ expect(reasons).to include("filters must be a hash")
22
+ expect(reasons).to include("mutators must be a hash")
23
+ expect(reasons).to include("handlers must be a hash")
24
+ expect(reasons.size).to eq(5)
25
25
  end
26
26
 
27
27
  it "can validate a transport definition" do
28
28
  transport = nil
29
29
  @validator.validate_transport(transport)
30
- @validator.reset.should eq(1)
30
+ expect(@validator.reset).to eq(1)
31
31
  transport = {}
32
32
  @validator.validate_transport(transport)
33
- @validator.reset.should eq(0)
33
+ expect(@validator.reset).to eq(0)
34
34
  transport[:name] = 1
35
35
  @validator.validate_transport(transport)
36
- @validator.reset.should eq(1)
36
+ expect(@validator.reset).to eq(1)
37
37
  transport[:name] = "rabbitmq"
38
38
  @validator.validate_transport(transport)
39
- @validator.reset.should eq(0)
39
+ expect(@validator.reset).to eq(0)
40
40
  end
41
41
 
42
42
  it "can run, validating transport" do
@@ -46,10 +46,10 @@ describe "Sensu::Settings::Validator" do
46
46
  }
47
47
  }
48
48
  @validator.run(settings)
49
- @validator.reset.should eq(5)
49
+ expect(@validator.reset).to eq(5)
50
50
  settings[:transport][:name] = "rabbitmq"
51
51
  @validator.run(settings)
52
- @validator.reset.should eq(4)
52
+ expect(@validator.reset).to eq(4)
53
53
  end
54
54
 
55
55
  it "can validate an empty check definition" do
@@ -57,90 +57,90 @@ describe "Sensu::Settings::Validator" do
57
57
  reasons = @validator.failures.map do |failure|
58
58
  failure[:message]
59
59
  end
60
- reasons.should include("check name must be a string")
61
- reasons.should include("check name cannot contain spaces or special characters")
62
- reasons.should include("check command must be a string")
63
- reasons.should include("check interval must be an integer")
64
- reasons.should include("check subscribers must be an array")
65
- reasons.size.should eq(5)
60
+ expect(reasons).to include("check name must be a string")
61
+ expect(reasons).to include("check name cannot contain spaces or special characters")
62
+ expect(reasons).to include("check command must be a string")
63
+ expect(reasons).to include("check interval must be an integer")
64
+ expect(reasons).to include("check subscribers must be an array")
65
+ expect(reasons.size).to eq(5)
66
66
  end
67
67
 
68
68
  it "can validate a check definition" do
69
69
  check = {:name => "foo bar"}
70
70
  @validator.validate_check(check)
71
- @validator.reset.should eq(4)
71
+ expect(@validator.reset).to eq(4)
72
72
  check[:name] = "foo"
73
73
  @validator.validate_check(check)
74
- @validator.reset.should eq(3)
74
+ expect(@validator.reset).to eq(3)
75
75
  check[:command] = 1
76
76
  @validator.validate_check(check)
77
- @validator.reset.should eq(3)
77
+ expect(@validator.reset).to eq(3)
78
78
  check[:command] = "true"
79
79
  @validator.validate_check(check)
80
- @validator.reset.should eq(2)
80
+ expect(@validator.reset).to eq(2)
81
81
  check[:timeout] = "foo"
82
82
  @validator.validate_check(check)
83
- @validator.reset.should eq(3)
83
+ expect(@validator.reset).to eq(3)
84
84
  check[:timeout] = 1.5
85
85
  @validator.validate_check(check)
86
- @validator.reset.should eq(2)
86
+ expect(@validator.reset).to eq(2)
87
87
  check[:timeout] = 1
88
88
  @validator.validate_check(check)
89
- @validator.reset.should eq(2)
89
+ expect(@validator.reset).to eq(2)
90
90
  check[:publish] = "false"
91
91
  @validator.validate_check(check)
92
- @validator.reset.should eq(3)
92
+ expect(@validator.reset).to eq(3)
93
93
  check[:publish] = false
94
94
  @validator.validate_check(check)
95
- @validator.reset.should eq(1)
95
+ expect(@validator.reset).to eq(1)
96
96
  check[:publish] = true
97
97
  @validator.validate_check(check)
98
- @validator.reset.should eq(2)
98
+ expect(@validator.reset).to eq(2)
99
99
  check[:interval] = "1"
100
100
  @validator.validate_check(check)
101
- @validator.reset.should eq(2)
101
+ expect(@validator.reset).to eq(2)
102
102
  check[:interval] = 1
103
103
  @validator.validate_check(check)
104
- @validator.reset.should eq(1)
104
+ expect(@validator.reset).to eq(1)
105
105
  check[:subscribers] = 1
106
106
  @validator.validate_check(check)
107
- @validator.reset.should eq(1)
107
+ expect(@validator.reset).to eq(1)
108
108
  check[:subscribers] = [1]
109
109
  @validator.validate_check(check)
110
- @validator.reset.should eq(1)
110
+ expect(@validator.reset).to eq(1)
111
111
  check[:subscribers] = []
112
112
  @validator.validate_check(check)
113
- @validator.reset.should eq(0)
113
+ expect(@validator.reset).to eq(0)
114
114
  check[:standalone] = "true"
115
115
  @validator.validate_check(check)
116
- @validator.reset.should eq(1)
116
+ expect(@validator.reset).to eq(1)
117
117
  check[:standalone] = true
118
118
  @validator.validate_check(check)
119
- @validator.reset.should eq(0)
119
+ expect(@validator.reset).to eq(0)
120
120
  check[:handler] = 1
121
121
  @validator.validate_check(check)
122
- @validator.reset.should eq(1)
122
+ expect(@validator.reset).to eq(1)
123
123
  check[:handler] = "cat"
124
124
  @validator.validate_check(check)
125
- @validator.reset.should eq(0)
125
+ expect(@validator.reset).to eq(0)
126
126
  check[:handlers] = "cat"
127
127
  @validator.validate_check(check)
128
- @validator.reset.should eq(1)
128
+ expect(@validator.reset).to eq(1)
129
129
  check[:handlers] = ["cat"]
130
130
  @validator.validate_check(check)
131
- @validator.reset.should eq(0)
131
+ expect(@validator.reset).to eq(0)
132
132
  check[:low_flap_threshold] = "25"
133
133
  @validator.validate_check(check)
134
- @validator.reset.should eq(2)
134
+ expect(@validator.reset).to eq(2)
135
135
  check[:low_flap_threshold] = 25
136
136
  @validator.validate_check(check)
137
- @validator.reset.should eq(1)
137
+ expect(@validator.reset).to eq(1)
138
138
  check[:high_flap_threshold] = "55"
139
139
  @validator.validate_check(check)
140
- @validator.reset.should eq(1)
140
+ expect(@validator.reset).to eq(1)
141
141
  check[:high_flap_threshold] = 55
142
142
  @validator.validate_check(check)
143
- @validator.reset.should eq(0)
143
+ expect(@validator.reset).to eq(0)
144
144
  end
145
145
 
146
146
  it "can validate check subdue" do
@@ -151,63 +151,63 @@ describe "Sensu::Settings::Validator" do
151
151
  :standalone => true
152
152
  }
153
153
  @validator.validate_check(check)
154
- @validator.reset.should eq(0)
154
+ expect(@validator.reset).to eq(0)
155
155
  check[:subdue] = true
156
156
  @validator.validate_check(check)
157
- @validator.reset.should eq(1)
157
+ expect(@validator.reset).to eq(1)
158
158
  check[:subdue] = {
159
159
  :at => "unknown"
160
160
  }
161
161
  @validator.validate_check(check)
162
- @validator.reset.should eq(1)
162
+ expect(@validator.reset).to eq(1)
163
163
  check[:subdue][:at] = "publisher"
164
164
  @validator.validate_check(check)
165
- @validator.reset.should eq(0)
165
+ expect(@validator.reset).to eq(0)
166
166
  check[:subdue][:at] = "handler"
167
167
  @validator.validate_check(check)
168
- @validator.reset.should eq(0)
168
+ expect(@validator.reset).to eq(0)
169
169
  check[:subdue][:begin] = "14:30"
170
170
  check[:subdue][:end] = 1
171
171
  @validator.validate_check(check)
172
- @validator.reset.should eq(1)
172
+ expect(@validator.reset).to eq(1)
173
173
  check[:subdue][:begin] = 1
174
174
  check[:subdue][:end] = "14:30"
175
175
  @validator.validate_check(check)
176
- @validator.reset.should eq(1)
176
+ expect(@validator.reset).to eq(1)
177
177
  check[:subdue][:begin] = "14:30"
178
178
  check[:subdue][:end] = "16:30"
179
179
  @validator.validate_check(check)
180
- @validator.reset.should eq(0)
180
+ expect(@validator.reset).to eq(0)
181
181
  check[:subdue][:days] = 1
182
182
  @validator.validate_check(check)
183
- @validator.reset.should eq(1)
183
+ expect(@validator.reset).to eq(1)
184
184
  check[:subdue][:days] = ["unknown"]
185
185
  @validator.validate_check(check)
186
- @validator.reset.should eq(1)
186
+ expect(@validator.reset).to eq(1)
187
187
  check[:subdue][:days] = [true]
188
188
  @validator.validate_check(check)
189
- @validator.reset.should eq(1)
189
+ expect(@validator.reset).to eq(1)
190
190
  check[:subdue][:days] = ["monday"]
191
191
  @validator.validate_check(check)
192
- @validator.reset.should eq(0)
192
+ expect(@validator.reset).to eq(0)
193
193
  check[:subdue][:exceptions] = 1
194
194
  @validator.validate_check(check)
195
- @validator.reset.should eq(1)
195
+ expect(@validator.reset).to eq(1)
196
196
  check[:subdue][:exceptions] = []
197
197
  @validator.validate_check(check)
198
- @validator.reset.should eq(0)
198
+ expect(@validator.reset).to eq(0)
199
199
  check[:subdue][:exceptions] = [1]
200
200
  @validator.validate_check(check)
201
- @validator.reset.should eq(1)
201
+ expect(@validator.reset).to eq(1)
202
202
  check[:subdue][:exceptions] = [{}]
203
203
  @validator.validate_check(check)
204
- @validator.reset.should eq(0)
204
+ expect(@validator.reset).to eq(0)
205
205
  check[:subdue][:exceptions] = [{:begin => "15:00"}]
206
206
  @validator.validate_check(check)
207
- @validator.reset.should eq(1)
207
+ expect(@validator.reset).to eq(1)
208
208
  check[:subdue][:exceptions] = [{:begin => "15:00", :end => "15:30"}]
209
209
  @validator.validate_check(check)
210
- @validator.reset.should eq(0)
210
+ expect(@validator.reset).to eq(0)
211
211
  end
212
212
 
213
213
  it "can run, validating checks" do
@@ -220,118 +220,118 @@ describe "Sensu::Settings::Validator" do
220
220
  }
221
221
  }
222
222
  @validator.run(settings)
223
- @validator.reset.should eq(5)
223
+ expect(@validator.reset).to eq(5)
224
224
  settings[:checks][:foo][:interval] = 1
225
225
  @validator.run(settings)
226
- @validator.reset.should eq(4)
226
+ expect(@validator.reset).to eq(4)
227
227
  end
228
228
 
229
229
  it "can validate a filter definition" do
230
230
  filter = {}
231
231
  @validator.validate_filter(filter)
232
- @validator.reset.should eq(1)
232
+ expect(@validator.reset).to eq(1)
233
233
  filter[:attributes] = 1
234
234
  @validator.validate_filter(filter)
235
- @validator.reset.should eq(1)
235
+ expect(@validator.reset).to eq(1)
236
236
  filter[:attributes] = {}
237
237
  @validator.validate_filter(filter)
238
- @validator.reset.should eq(0)
238
+ expect(@validator.reset).to eq(0)
239
239
  filter[:negate] = "true"
240
240
  @validator.validate_filter(filter)
241
- @validator.reset.should eq(1)
241
+ expect(@validator.reset).to eq(1)
242
242
  filter[:negate] = true
243
243
  @validator.validate_filter(filter)
244
- @validator.reset.should eq(0)
244
+ expect(@validator.reset).to eq(0)
245
245
  end
246
246
 
247
247
  it "can validate a mutator definition" do
248
248
  mutator = {}
249
249
  @validator.validate_mutator(mutator)
250
- @validator.reset.should eq(1)
250
+ expect(@validator.reset).to eq(1)
251
251
  mutator[:command] = "cat"
252
252
  @validator.validate_mutator(mutator)
253
- @validator.reset.should eq(0)
253
+ expect(@validator.reset).to eq(0)
254
254
  mutator[:timeout] = "foo"
255
255
  @validator.validate_mutator(mutator)
256
- @validator.reset.should eq(1)
256
+ expect(@validator.reset).to eq(1)
257
257
  mutator[:timeout] = 1.5
258
258
  @validator.validate_mutator(mutator)
259
- @validator.reset.should eq(0)
259
+ expect(@validator.reset).to eq(0)
260
260
  mutator[:timeout] = 1
261
261
  @validator.validate_mutator(mutator)
262
- @validator.reset.should eq(0)
262
+ expect(@validator.reset).to eq(0)
263
263
  end
264
264
 
265
265
  it "can validate a handler definition" do
266
266
  handler = {}
267
267
  @validator.validate_handler(handler)
268
- @validator.reset.should eq(2)
268
+ expect(@validator.reset).to eq(2)
269
269
  handler[:type] = 1
270
270
  @validator.validate_handler(handler)
271
- @validator.reset.should eq(2)
271
+ expect(@validator.reset).to eq(2)
272
272
  handler[:type] = "unknown"
273
273
  @validator.validate_handler(handler)
274
- @validator.reset.should eq(1)
274
+ expect(@validator.reset).to eq(1)
275
275
  handler[:type] = "pipe"
276
276
  @validator.validate_handler(handler)
277
- @validator.reset.should eq(1)
277
+ expect(@validator.reset).to eq(1)
278
278
  handler[:command] = 1
279
279
  @validator.validate_handler(handler)
280
- @validator.reset.should eq(1)
280
+ expect(@validator.reset).to eq(1)
281
281
  handler[:command] = "cat"
282
282
  @validator.validate_handler(handler)
283
- @validator.reset.should eq(0)
283
+ expect(@validator.reset).to eq(0)
284
284
  handler[:timeout] = "foo"
285
285
  @validator.validate_handler(handler)
286
- @validator.reset.should eq(1)
286
+ expect(@validator.reset).to eq(1)
287
287
  handler[:timeout] = 1
288
288
  @validator.validate_handler(handler)
289
- @validator.reset.should eq(0)
289
+ expect(@validator.reset).to eq(0)
290
290
  handler[:mutator] = 1
291
291
  @validator.validate_handler(handler)
292
- @validator.reset.should eq(1)
292
+ expect(@validator.reset).to eq(1)
293
293
  handler[:mutator] = "foo"
294
294
  @validator.validate_handler(handler)
295
- @validator.reset.should eq(0)
295
+ expect(@validator.reset).to eq(0)
296
296
  handler[:handle_flapping] = "true"
297
297
  @validator.validate_handler(handler)
298
- @validator.reset.should eq(1)
298
+ expect(@validator.reset).to eq(1)
299
299
  handler[:handle_flapping] = true
300
300
  @validator.validate_handler(handler)
301
- @validator.reset.should eq(0)
301
+ expect(@validator.reset).to eq(0)
302
302
  handler[:handle_flapping] = false
303
303
  @validator.validate_handler(handler)
304
- @validator.reset.should eq(0)
304
+ expect(@validator.reset).to eq(0)
305
305
  handler[:filter] = 1
306
306
  @validator.validate_handler(handler)
307
- @validator.reset.should eq(1)
307
+ expect(@validator.reset).to eq(1)
308
308
  handler[:filter] = "foo"
309
309
  @validator.validate_handler(handler)
310
- @validator.reset.should eq(0)
310
+ expect(@validator.reset).to eq(0)
311
311
  handler[:filters] = "foo"
312
312
  @validator.validate_handler(handler)
313
- @validator.reset.should eq(1)
313
+ expect(@validator.reset).to eq(1)
314
314
  handler[:filters] = []
315
315
  @validator.validate_handler(handler)
316
- @validator.reset.should eq(0)
316
+ expect(@validator.reset).to eq(0)
317
317
  handler[:filters] = [1]
318
318
  @validator.validate_handler(handler)
319
- @validator.reset.should eq(1)
319
+ expect(@validator.reset).to eq(1)
320
320
  handler[:filters] = ["foo"]
321
321
  @validator.validate_handler(handler)
322
- @validator.reset.should eq(0)
322
+ expect(@validator.reset).to eq(0)
323
323
  handler[:severities] = "foo"
324
324
  @validator.validate_handler(handler)
325
- @validator.reset.should eq(1)
325
+ expect(@validator.reset).to eq(1)
326
326
  handler[:severities] = []
327
327
  @validator.validate_handler(handler)
328
- @validator.reset.should eq(0)
328
+ expect(@validator.reset).to eq(0)
329
329
  handler[:severities] = ["foo"]
330
330
  @validator.validate_handler(handler)
331
- @validator.reset.should eq(1)
331
+ expect(@validator.reset).to eq(1)
332
332
  handler[:severities] = ["warning", "unknown"]
333
333
  @validator.validate_handler(handler)
334
- @validator.reset.should eq(0)
334
+ expect(@validator.reset).to eq(0)
335
335
  end
336
336
 
337
337
  it "can validate a tcp/udp handler definition" do
@@ -339,22 +339,22 @@ describe "Sensu::Settings::Validator" do
339
339
  :type => "tcp"
340
340
  }
341
341
  @validator.validate_handler(handler)
342
- @validator.reset.should eq(1)
342
+ expect(@validator.reset).to eq(1)
343
343
  handler[:socket] = {}
344
344
  @validator.validate_handler(handler)
345
- @validator.reset.should eq(2)
345
+ expect(@validator.reset).to eq(2)
346
346
  handler[:socket][:host] = 1
347
347
  @validator.validate_handler(handler)
348
- @validator.reset.should eq(2)
348
+ expect(@validator.reset).to eq(2)
349
349
  handler[:socket][:host] = "127.0.0.1"
350
350
  @validator.validate_handler(handler)
351
- @validator.reset.should eq(1)
351
+ expect(@validator.reset).to eq(1)
352
352
  handler[:socket][:port] = "foo"
353
353
  @validator.validate_handler(handler)
354
- @validator.reset.should eq(1)
354
+ expect(@validator.reset).to eq(1)
355
355
  handler[:socket][:port] = 2003
356
356
  @validator.validate_handler(handler)
357
- @validator.reset.should eq(0)
357
+ expect(@validator.reset).to eq(0)
358
358
  end
359
359
 
360
360
  it "can validate a transport handler definition" do
@@ -362,34 +362,34 @@ describe "Sensu::Settings::Validator" do
362
362
  :type => "transport"
363
363
  }
364
364
  @validator.validate_handler(handler)
365
- @validator.reset.should eq(1)
365
+ expect(@validator.reset).to eq(1)
366
366
  handler[:pipe] = 1
367
367
  @validator.validate_handler(handler)
368
- @validator.reset.should eq(1)
368
+ expect(@validator.reset).to eq(1)
369
369
  handler[:pipe] = {}
370
370
  @validator.validate_handler(handler)
371
- @validator.reset.should eq(3)
371
+ expect(@validator.reset).to eq(3)
372
372
  handler[:pipe][:type] = 1
373
373
  @validator.validate_handler(handler)
374
- @validator.reset.should eq(3)
374
+ expect(@validator.reset).to eq(3)
375
375
  handler[:pipe][:type] = "unknown"
376
376
  @validator.validate_handler(handler)
377
- @validator.reset.should eq(2)
377
+ expect(@validator.reset).to eq(2)
378
378
  handler[:pipe][:type] = "direct"
379
379
  @validator.validate_handler(handler)
380
- @validator.reset.should eq(1)
380
+ expect(@validator.reset).to eq(1)
381
381
  handler[:pipe][:name] = 1
382
382
  @validator.validate_handler(handler)
383
- @validator.reset.should eq(1)
383
+ expect(@validator.reset).to eq(1)
384
384
  handler[:pipe][:name] = "foo"
385
385
  @validator.validate_handler(handler)
386
- @validator.reset.should eq(0)
386
+ expect(@validator.reset).to eq(0)
387
387
  handler[:pipe][:options] = 1
388
388
  @validator.validate_handler(handler)
389
- @validator.reset.should eq(1)
389
+ expect(@validator.reset).to eq(1)
390
390
  handler[:pipe][:options] = {}
391
391
  @validator.validate_handler(handler)
392
- @validator.reset.should eq(0)
392
+ expect(@validator.reset).to eq(0)
393
393
  end
394
394
 
395
395
  it "can validate a handler set definition" do
@@ -397,19 +397,19 @@ describe "Sensu::Settings::Validator" do
397
397
  :type => "set"
398
398
  }
399
399
  @validator.validate_handler(handler)
400
- @validator.reset.should eq(1)
400
+ expect(@validator.reset).to eq(1)
401
401
  handler[:handlers] = 1
402
402
  @validator.validate_handler(handler)
403
- @validator.reset.should eq(1)
403
+ expect(@validator.reset).to eq(1)
404
404
  handler[:handlers] = "default"
405
405
  @validator.validate_handler(handler)
406
- @validator.reset.should eq(1)
406
+ expect(@validator.reset).to eq(1)
407
407
  handler[:handlers] = [1]
408
408
  @validator.validate_handler(handler)
409
- @validator.reset.should eq(1)
409
+ expect(@validator.reset).to eq(1)
410
410
  handler[:handlers] = ["default"]
411
411
  @validator.validate_handler(handler)
412
- @validator.reset.should eq(0)
412
+ expect(@validator.reset).to eq(0)
413
413
  end
414
414
 
415
415
  it "can validate handler subdue" do
@@ -419,71 +419,71 @@ describe "Sensu::Settings::Validator" do
419
419
  :command => "cat"
420
420
  }
421
421
  @validator.validate_handler(handler)
422
- @validator.reset.should eq(0)
422
+ expect(@validator.reset).to eq(0)
423
423
  handler[:subdue] = true
424
424
  @validator.validate_handler(handler)
425
- @validator.reset.should eq(1)
425
+ expect(@validator.reset).to eq(1)
426
426
  handler[:subdue] = {
427
427
  :at => "handler",
428
428
  :begin => "14:30",
429
429
  :end => "15:45"
430
430
  }
431
431
  @validator.validate_handler(handler)
432
- @validator.reset.should eq(0)
432
+ expect(@validator.reset).to eq(0)
433
433
  end
434
434
 
435
435
  it "can validate a client definition" do
436
436
  client = true
437
437
  @validator.validate_client(client)
438
- @validator.reset.should eq(1)
438
+ expect(@validator.reset).to eq(1)
439
439
  client = {}
440
440
  @validator.validate_client(client)
441
- @validator.reset.should eq(4)
441
+ expect(@validator.reset).to eq(4)
442
442
  client[:name] = 1
443
443
  @validator.validate_client(client)
444
- @validator.reset.should eq(4)
444
+ expect(@validator.reset).to eq(4)
445
445
  client[:name] = "foo bar"
446
446
  @validator.validate_client(client)
447
- @validator.reset.should eq(3)
447
+ expect(@validator.reset).to eq(3)
448
448
  client[:name] = "foo"
449
449
  @validator.validate_client(client)
450
- @validator.reset.should eq(2)
450
+ expect(@validator.reset).to eq(2)
451
451
  client[:address] = 1
452
452
  @validator.validate_client(client)
453
- @validator.reset.should eq(2)
453
+ expect(@validator.reset).to eq(2)
454
454
  client[:address] = "127.0.0.1"
455
455
  @validator.validate_client(client)
456
- @validator.reset.should eq(1)
456
+ expect(@validator.reset).to eq(1)
457
457
  client[:subscriptions] = true
458
458
  @validator.validate_client(client)
459
- @validator.reset.should eq(1)
459
+ expect(@validator.reset).to eq(1)
460
460
  client[:subscriptions] = []
461
461
  @validator.validate_client(client)
462
- @validator.reset.should eq(0)
462
+ expect(@validator.reset).to eq(0)
463
463
  client[:subscriptions] = [1]
464
464
  @validator.validate_client(client)
465
- @validator.reset.should eq(1)
465
+ expect(@validator.reset).to eq(1)
466
466
  client[:subscriptions] = ["bar"]
467
467
  @validator.validate_client(client)
468
- @validator.reset.should eq(0)
468
+ expect(@validator.reset).to eq(0)
469
469
  client[:redact] = true
470
470
  @validator.validate_client(client)
471
- @validator.reset.should eq(1)
471
+ expect(@validator.reset).to eq(1)
472
472
  client[:redact] = []
473
473
  @validator.validate_client(client)
474
- @validator.reset.should eq(0)
474
+ expect(@validator.reset).to eq(0)
475
475
  client[:redact] = [1]
476
476
  @validator.validate_client(client)
477
- @validator.reset.should eq(1)
477
+ expect(@validator.reset).to eq(1)
478
478
  client[:redact] = ["secret"]
479
479
  @validator.validate_client(client)
480
- @validator.reset.should eq(0)
480
+ expect(@validator.reset).to eq(0)
481
481
  client[:safe_mode] = 1
482
482
  @validator.validate_client(client)
483
- @validator.reset.should eq(1)
483
+ expect(@validator.reset).to eq(1)
484
484
  client[:safe_mode] = false
485
485
  @validator.validate_client(client)
486
- @validator.reset.should eq(0)
486
+ expect(@validator.reset).to eq(0)
487
487
  end
488
488
 
489
489
  it "can validate client socket" do
@@ -493,25 +493,25 @@ describe "Sensu::Settings::Validator" do
493
493
  :subscriptions => ["bar"]
494
494
  }
495
495
  @validator.validate_client(client)
496
- @validator.reset.should eq(0)
496
+ expect(@validator.reset).to eq(0)
497
497
  client[:socket] = true
498
498
  @validator.validate_client(client)
499
- @validator.reset.should eq(1)
499
+ expect(@validator.reset).to eq(1)
500
500
  client[:socket] = {}
501
501
  @validator.validate_client(client)
502
- @validator.reset.should eq(0)
502
+ expect(@validator.reset).to eq(0)
503
503
  client[:socket][:bind] = true
504
504
  @validator.validate_client(client)
505
- @validator.reset.should eq(1)
505
+ expect(@validator.reset).to eq(1)
506
506
  client[:socket][:bind] = "127.0.0.1"
507
507
  @validator.validate_client(client)
508
- @validator.reset.should eq(0)
508
+ expect(@validator.reset).to eq(0)
509
509
  client[:socket][:port] = "2012"
510
510
  @validator.validate_client(client)
511
- @validator.reset.should eq(1)
511
+ expect(@validator.reset).to eq(1)
512
512
  client[:socket][:port] = 2012
513
513
  @validator.validate_client(client)
514
- @validator.reset.should eq(0)
514
+ expect(@validator.reset).to eq(0)
515
515
  end
516
516
 
517
517
  it "can validate client keepalive" do
@@ -521,46 +521,46 @@ describe "Sensu::Settings::Validator" do
521
521
  :subscriptions => ["bar"]
522
522
  }
523
523
  @validator.validate_client(client)
524
- @validator.reset.should eq(0)
524
+ expect(@validator.reset).to eq(0)
525
525
  client[:keepalive] = true
526
526
  @validator.validate_client(client)
527
- @validator.reset.should eq(1)
527
+ expect(@validator.reset).to eq(1)
528
528
  client[:keepalive] = {}
529
529
  @validator.validate_client(client)
530
- @validator.reset.should eq(0)
530
+ expect(@validator.reset).to eq(0)
531
531
  client[:keepalive][:handler] = 1
532
532
  @validator.validate_client(client)
533
- @validator.reset.should eq(1)
533
+ expect(@validator.reset).to eq(1)
534
534
  client[:keepalive][:handler] = "foo"
535
535
  @validator.validate_client(client)
536
- @validator.reset.should eq(0)
536
+ expect(@validator.reset).to eq(0)
537
537
  client[:keepalive][:handlers] = 1
538
538
  @validator.validate_client(client)
539
- @validator.reset.should eq(1)
539
+ expect(@validator.reset).to eq(1)
540
540
  client[:keepalive][:handlers] = [1]
541
541
  @validator.validate_client(client)
542
- @validator.reset.should eq(1)
542
+ expect(@validator.reset).to eq(1)
543
543
  client[:keepalive][:handlers] = ["foo"]
544
544
  @validator.validate_client(client)
545
- @validator.reset.should eq(0)
545
+ expect(@validator.reset).to eq(0)
546
546
  client[:keepalive][:thresholds] = true
547
547
  @validator.validate_client(client)
548
- @validator.reset.should eq(1)
548
+ expect(@validator.reset).to eq(1)
549
549
  client[:keepalive][:thresholds] = {}
550
550
  @validator.validate_client(client)
551
- @validator.reset.should eq(0)
551
+ expect(@validator.reset).to eq(0)
552
552
  client[:keepalive][:thresholds][:warning] = "60"
553
553
  @validator.validate_client(client)
554
- @validator.reset.should eq(1)
554
+ expect(@validator.reset).to eq(1)
555
555
  client[:keepalive][:thresholds][:warning] = 60
556
556
  @validator.validate_client(client)
557
- @validator.reset.should eq(0)
557
+ expect(@validator.reset).to eq(0)
558
558
  client[:keepalive][:thresholds][:critical] = "90"
559
559
  @validator.validate_client(client)
560
- @validator.reset.should eq(1)
560
+ expect(@validator.reset).to eq(1)
561
561
  client[:keepalive][:thresholds][:critical] = 90
562
562
  @validator.validate_client(client)
563
- @validator.reset.should eq(0)
563
+ expect(@validator.reset).to eq(0)
564
564
  end
565
565
 
566
566
  it "can run, validating client" do
@@ -571,43 +571,43 @@ describe "Sensu::Settings::Validator" do
571
571
  }
572
572
  }
573
573
  @validator.run(settings, "client")
574
- @validator.reset.should eq(6)
574
+ expect(@validator.reset).to eq(6)
575
575
  settings[:client][:subscriptions] = ["bar"]
576
576
  @validator.run(settings, "client")
577
- @validator.reset.should eq(5)
577
+ expect(@validator.reset).to eq(5)
578
578
  end
579
579
 
580
580
  it "can validate an api definition" do
581
581
  api = true
582
582
  @validator.validate_api(api)
583
- @validator.reset.should eq(1)
583
+ expect(@validator.reset).to eq(1)
584
584
  api = {}
585
585
  @validator.validate_api(api)
586
- @validator.reset.should eq(1)
586
+ expect(@validator.reset).to eq(1)
587
587
  api[:port] = true
588
588
  @validator.validate_api(api)
589
- @validator.reset.should eq(1)
589
+ expect(@validator.reset).to eq(1)
590
590
  api[:port] = 4567
591
591
  @validator.validate_api(api)
592
- @validator.reset.should eq(0)
592
+ expect(@validator.reset).to eq(0)
593
593
  api[:bind] = true
594
594
  @validator.validate_api(api)
595
- @validator.reset.should eq(1)
595
+ expect(@validator.reset).to eq(1)
596
596
  api[:bind] = "127.0.0.1"
597
597
  @validator.validate_api(api)
598
- @validator.reset.should eq(0)
598
+ expect(@validator.reset).to eq(0)
599
599
  api[:user] = 1
600
600
  @validator.validate_api(api)
601
- @validator.reset.should eq(2)
601
+ expect(@validator.reset).to eq(2)
602
602
  api[:user] = "foo"
603
603
  @validator.validate_api(api)
604
- @validator.reset.should eq(1)
604
+ expect(@validator.reset).to eq(1)
605
605
  api[:password] = 1
606
606
  @validator.validate_api(api)
607
- @validator.reset.should eq(1)
607
+ expect(@validator.reset).to eq(1)
608
608
  api[:password] = "bar"
609
609
  @validator.validate_api(api)
610
- @validator.reset.should eq(0)
610
+ expect(@validator.reset).to eq(0)
611
611
  end
612
612
 
613
613
  it "can run, validating api" do
@@ -617,9 +617,9 @@ describe "Sensu::Settings::Validator" do
617
617
  }
618
618
  }
619
619
  @validator.run(settings, "api")
620
- @validator.reset.should eq(6)
620
+ expect(@validator.reset).to eq(6)
621
621
  settings[:api][:port] = 4567
622
622
  @validator.run(settings, "api")
623
- @validator.reset.should eq(5)
623
+ expect(@validator.reset).to eq(5)
624
624
  end
625
625
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Porter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-28 00:00:00.000000000 Z
11
+ date: 2014-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json