metasploit-model 1.0.0.pre.rails.pre.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -4
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.md +9 -49
- data/Gemfile +1 -6
- data/RELEASING.md +89 -0
- data/UPGRADING.md +1 -0
- data/lib/metasploit/model/version.rb +23 -11
- data/metasploit-model.gemspec +3 -1
- data/spec/app/models/metasploit/model/association/reflection_spec.rb +5 -7
- data/spec/app/models/metasploit/model/search/group/base_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/group/intersection_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/group/union_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/operation/association_spec.rb +7 -9
- data/spec/app/models/metasploit/model/search/operation/base_spec.rb +5 -7
- data/spec/app/models/metasploit/model/search/operation/boolean_spec.rb +14 -11
- data/spec/app/models/metasploit/model/search/operation/date_spec.rb +6 -8
- data/spec/app/models/metasploit/model/search/operation/group/base_spec.rb +12 -14
- data/spec/app/models/metasploit/model/search/operation/group/intersection_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/operation/group/union_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/operation/integer_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/operation/null_spec.rb +4 -6
- data/spec/app/models/metasploit/model/search/operation/set/integer_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/operation/set/string_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/operation/set_spec.rb +4 -6
- data/spec/app/models/metasploit/model/search/operation/string_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/operator/association_spec.rb +6 -8
- data/spec/app/models/metasploit/model/search/operator/attribute_spec.rb +13 -15
- data/spec/app/models/metasploit/model/search/operator/base_spec.rb +3 -5
- data/spec/app/models/metasploit/model/search/operator/delegation_spec.rb +13 -11
- data/spec/app/models/metasploit/model/search/operator/group/base_spec.rb +5 -7
- data/spec/app/models/metasploit/model/search/operator/group/intersection_spec.rb +3 -5
- data/spec/app/models/metasploit/model/search/operator/group/union_spec.rb +3 -5
- data/spec/app/models/metasploit/model/search/operator/null_spec.rb +5 -7
- data/spec/app/models/metasploit/model/search/operator/single_spec.rb +26 -28
- data/spec/app/models/metasploit/model/search/query_spec.rb +48 -50
- data/spec/app/models/metasploit/model/visitation/visitor_spec.rb +7 -9
- data/spec/app/validators/ip_format_validator_spec.rb +7 -9
- data/spec/app/validators/nil_validator_spec.rb +3 -5
- data/spec/app/validators/parameters_validator_spec.rb +29 -29
- data/spec/app/validators/password_is_strong_validator_spec.rb +17 -19
- data/spec/lib/metasploit/model/association/error_spec.rb +1 -3
- data/spec/lib/metasploit/model/association_spec.rb +8 -10
- data/spec/lib/metasploit/model/base_spec.rb +3 -5
- data/spec/lib/metasploit/model/engine_spec.rb +48 -11
- data/spec/lib/metasploit/model/file_spec.rb +3 -5
- data/spec/lib/metasploit/model/invalid_spec.rb +7 -9
- data/spec/lib/metasploit/model/login/status_spec.rb +1 -3
- data/spec/lib/metasploit/model/nilify_blanks_spec.rb +11 -13
- data/spec/lib/metasploit/model/realm/key_spec.rb +15 -17
- data/spec/lib/metasploit/model/search/association/tree_spec.rb +3 -5
- data/spec/lib/metasploit/model/search/association_spec.rb +2 -4
- data/spec/lib/metasploit/model/search/attribute_spec.rb +6 -8
- data/spec/lib/metasploit/model/search/operation/value/integer_spec.rb +1 -3
- data/spec/lib/metasploit/model/search/operation/value/string_spec.rb +1 -3
- data/spec/lib/metasploit/model/search/operation_spec.rb +11 -13
- data/spec/lib/metasploit/model/search/operator/help_spec.rb +1 -3
- data/spec/lib/metasploit/model/search/with_spec.rb +7 -9
- data/spec/lib/metasploit/model/search_spec.rb +11 -13
- data/spec/lib/metasploit/model/spec/error_spec.rb +2 -4
- data/spec/lib/metasploit/model/spec/i18n_exception_handler_spec.rb +5 -7
- data/spec/lib/metasploit/model/spec/pathname_collision_spec.rb +4 -6
- data/spec/lib/metasploit/model/spec_spec.rb +9 -7
- data/spec/lib/metasploit/model/translation_spec.rb +10 -12
- data/spec/lib/metasploit/model/version_spec.rb +3 -139
- data/spec/lib/metasploit/model/visitation/visit_spec.rb +28 -26
- data/spec/lib/metasploit/model_spec.rb +4 -0
- data/spec/matchers/validate_nilness_of_spec.rb +0 -2
- data/spec/spec_helper.rb +80 -10
- data/spec/support/shared/contexts/metasploit/model/search/operator/union/children.rb +1 -1
- data/spec/support/shared/examples/metasploit/model/search/operation/value/integer.rb +8 -8
- data/spec/support/shared/examples/metasploit/model/search/operation/value/string.rb +5 -5
- data/spec/support/shared/examples/metasploit/model/search/operator/help.rb +18 -16
- data/spec/support/shared/examples/metasploit/model/translation.rb +4 -4
- data/spec/support/shared/examples/search/query.rb +3 -3
- data/spec/support/shared/examples/search_association.rb +2 -2
- data/spec/support/shared/examples/search_attribute.rb +3 -3
- data/spec/support/shared/examples/search_with.rb +3 -3
- metadata +43 -4
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Metasploit::Model::Visitation::Visit do
|
1
|
+
RSpec.describe Metasploit::Model::Visitation::Visit do
|
4
2
|
let(:base_class) do
|
5
3
|
described_class = self.described_class
|
6
4
|
|
@@ -54,15 +52,15 @@ describe Metasploit::Model::Visitation::Visit do
|
|
54
52
|
end
|
55
53
|
|
56
54
|
it 'should return Array(Metasploit::Model::Visitation::Visitor)' do
|
57
|
-
visit.
|
58
|
-
visit.length.
|
59
|
-
visit.first.
|
55
|
+
expect(visit).to be_an Array
|
56
|
+
expect(visit.length).to eq(1)
|
57
|
+
expect(visit.first).to be_a Metasploit::Model::Visitation::Visitor
|
60
58
|
end
|
61
59
|
|
62
60
|
it 'should add Metasploit::Model::Visitation::Visitor to visitor_by_module_name' do
|
63
61
|
visitor = visit.first
|
64
62
|
|
65
|
-
base_class.visitor_by_module_name[mod.name].
|
63
|
+
expect(base_class.visitor_by_module_name[mod.name]).to eq(visitor)
|
66
64
|
end
|
67
65
|
end
|
68
66
|
|
@@ -88,18 +86,22 @@ describe Metasploit::Model::Visitation::Visit do
|
|
88
86
|
end
|
89
87
|
|
90
88
|
it 'should return Array<Metasploit::Model::Visitation::Visitor>' do
|
91
|
-
visit.
|
92
|
-
visit.length.
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
89
|
+
expect(visit).to be_an Array
|
90
|
+
expect(visit.length).to eq(module_names.length)
|
91
|
+
|
92
|
+
expect(
|
93
|
+
visit.all? { |visitor|
|
94
|
+
visitor.is_a? Metasploit::Model::Visitation::Visitor
|
95
|
+
}
|
96
|
+
).to eq(true)
|
97
97
|
end
|
98
98
|
|
99
99
|
it 'should each Metasploit::Model::Visitation::Visitor to visitor_by_module_name' do
|
100
|
-
|
101
|
-
|
102
|
-
|
100
|
+
expect(
|
101
|
+
module_names.all? { |module_name|
|
102
|
+
visit.include? base_class.visitor_by_module_name[module_name]
|
103
|
+
}
|
104
|
+
).to eq(true)
|
103
105
|
end
|
104
106
|
end
|
105
107
|
end
|
@@ -158,7 +160,7 @@ describe Metasploit::Model::Visitation::Visit do
|
|
158
160
|
end
|
159
161
|
|
160
162
|
it 'should return visitor from visitor_by_module' do
|
161
|
-
visitor.
|
163
|
+
expect(visitor).to eq(klass_visitor)
|
162
164
|
end
|
163
165
|
end
|
164
166
|
|
@@ -187,13 +189,13 @@ describe Metasploit::Model::Visitation::Visit do
|
|
187
189
|
end
|
188
190
|
|
189
191
|
it 'should return ancestor visitor' do
|
190
|
-
visitor.
|
192
|
+
expect(visitor).to eq(ancestor_visitor)
|
191
193
|
end
|
192
194
|
|
193
195
|
it 'should cache ancestor visitor as visitor for klass in visitor_by_module' do
|
194
196
|
visitor
|
195
197
|
|
196
|
-
base_class.visitor_by_module[klass].
|
198
|
+
expect(base_class.visitor_by_module[klass]).to eq(ancestor_visitor)
|
197
199
|
end
|
198
200
|
end
|
199
201
|
|
@@ -203,13 +205,13 @@ describe Metasploit::Model::Visitation::Visit do
|
|
203
205
|
end
|
204
206
|
|
205
207
|
it 'should return ancestor visitor' do
|
206
|
-
visitor.
|
208
|
+
expect(visitor).to eq(ancestor_visitor)
|
207
209
|
end
|
208
210
|
|
209
211
|
it 'should cache ancestor visitor as visitor for klass in visitor_by_module' do
|
210
212
|
visitor
|
211
213
|
|
212
|
-
base_class.visitor_by_module[klass].
|
214
|
+
expect(base_class.visitor_by_module[klass]).to eq(ancestor_visitor)
|
213
215
|
end
|
214
216
|
end
|
215
217
|
|
@@ -229,7 +231,7 @@ describe Metasploit::Model::Visitation::Visit do
|
|
229
231
|
end
|
230
232
|
|
231
233
|
it 'should default to empty Hash' do
|
232
|
-
visitor_by_module.
|
234
|
+
expect(visitor_by_module).to eq({})
|
233
235
|
end
|
234
236
|
end
|
235
237
|
|
@@ -239,7 +241,7 @@ describe Metasploit::Model::Visitation::Visit do
|
|
239
241
|
end
|
240
242
|
|
241
243
|
it 'should default to empty Hash' do
|
242
|
-
visitor_by_module_name.
|
244
|
+
expect(visitor_by_module_name).to eq({})
|
243
245
|
end
|
244
246
|
end
|
245
247
|
|
@@ -274,13 +276,13 @@ describe Metasploit::Model::Visitation::Visit do
|
|
274
276
|
end
|
275
277
|
|
276
278
|
it 'should find visitor for node.class' do
|
277
|
-
base_class.
|
279
|
+
expect(base_class).to receive(:visitor).with(node.class).and_call_original
|
278
280
|
|
279
281
|
visit
|
280
282
|
end
|
281
283
|
|
282
284
|
it 'should visit on visitor' do
|
283
|
-
@visitor.
|
285
|
+
expect(@visitor).to receive(:visit).with(base_instance, node)
|
284
286
|
|
285
287
|
visit
|
286
288
|
end
|
@@ -309,7 +311,7 @@ describe Metasploit::Model::Visitation::Visit do
|
|
309
311
|
end
|
310
312
|
|
311
313
|
it "should be able to call visit from inside a visitor's block" do
|
312
|
-
visit.
|
314
|
+
expect(visit).to eq(leaf_node)
|
313
315
|
end
|
314
316
|
end
|
315
317
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -14,22 +14,95 @@ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
|
14
14
|
|
15
15
|
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
16
16
|
require 'rspec/rails'
|
17
|
-
require 'rspec/autorun'
|
18
17
|
|
19
|
-
#
|
20
|
-
|
18
|
+
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
19
|
+
gem_specification = Gem::Specification.find_all_by_name('metasploit-version').first
|
21
20
|
|
22
|
-
|
21
|
+
roots = [
|
22
|
+
Metasploit::Model::Engine.root.to_path,
|
23
|
+
gem_specification.gem_dir
|
24
|
+
]
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
roots.each do |root|
|
27
|
+
Dir[File.join(root, 'spec', 'support', '**', '*.rb')].each do |f|
|
28
|
+
require f
|
29
|
+
end
|
26
30
|
end
|
27
31
|
|
32
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
28
33
|
RSpec.configure do |config|
|
34
|
+
# rspec-expectations config goes here. You can use an alternate
|
35
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
36
|
+
# assertions if you prefer.
|
37
|
+
config.expect_with :rspec do |expectations|
|
38
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
39
|
+
# and `failure_message` of custom matchers include text for helper methods
|
40
|
+
# defined using `chain`, e.g.:
|
41
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
42
|
+
# # => "be bigger than 2 and smaller than 4"
|
43
|
+
# ...rather than:
|
44
|
+
# # => "be bigger than 2"
|
45
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
46
|
+
end
|
47
|
+
|
48
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
49
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
50
|
+
config.mock_with :rspec do |mocks|
|
51
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
52
|
+
# a real object. This is generally recommended, and will default to
|
53
|
+
# `true` in RSpec 4.
|
54
|
+
mocks.verify_partial_doubles = true
|
55
|
+
end
|
56
|
+
|
57
|
+
# These two settings work together to allow you to limit a spec run
|
58
|
+
# to individual examples or groups you care about by tagging them with
|
59
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
60
|
+
# get run.
|
61
|
+
config.filter_run :focus
|
62
|
+
config.run_all_when_everything_filtered = true
|
63
|
+
|
64
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
65
|
+
# recommended. For more details, see:
|
66
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
67
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
68
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
69
|
+
config.disable_monkey_patching!
|
70
|
+
|
71
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
72
|
+
# be too noisy due to issues in dependencies.
|
73
|
+
config.warnings = true
|
74
|
+
|
75
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
76
|
+
# file, and it's useful to allow more verbose output when running an
|
77
|
+
# individual spec file.
|
78
|
+
if config.files_to_run.one?
|
79
|
+
# Use the documentation formatter for detailed output,
|
80
|
+
# unless a formatter has already been configured
|
81
|
+
# (e.g. via a command-line flag).
|
82
|
+
config.default_formatter = 'doc'
|
83
|
+
end
|
84
|
+
|
85
|
+
# Print the 10 slowest examples and example groups at the
|
86
|
+
# end of the spec run, to help surface which specs are running
|
87
|
+
# particularly slow.
|
88
|
+
config.profile_examples = 10
|
89
|
+
|
90
|
+
# Run specs in random order to surface order dependencies. If you find an
|
91
|
+
# order dependency and want to debug it, you can fix the order by providing
|
92
|
+
# the seed, which is printed after each run.
|
93
|
+
# --seed 1234
|
94
|
+
config.order = :random
|
95
|
+
|
96
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
97
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
98
|
+
# test failures related to randomization by passing the same `--seed` value
|
99
|
+
# as the one that triggered the failure.
|
100
|
+
Kernel.srand config.seed
|
101
|
+
|
29
102
|
config.before(:suite) do
|
30
103
|
# this must be explicitly set here because it should always be spec/tmp for w/e project is using
|
31
104
|
# Metasploit::Model::Spec to handle file system clean up.
|
32
|
-
Metasploit::Model::Spec.temporary_pathname =
|
105
|
+
Metasploit::Model::Spec.temporary_pathname = Metasploit::Model::Engine.root.join('spec', 'tmp')
|
33
106
|
# Clean up any left over files from a previously aborted suite
|
34
107
|
Metasploit::Model::Spec.remove_temporary_pathname
|
35
108
|
|
@@ -40,7 +113,4 @@ RSpec.configure do |config|
|
|
40
113
|
config.after(:each) do
|
41
114
|
Metasploit::Model::Spec.remove_temporary_pathname
|
42
115
|
end
|
43
|
-
|
44
|
-
config.mock_with :rspec
|
45
|
-
config.order = :random
|
46
116
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
shared_examples_for 'Metasploit::Model::Search::Operation::Value::Integer' do
|
1
|
+
RSpec.shared_examples_for 'Metasploit::Model::Search::Operation::Value::Integer' do
|
2
2
|
let(:operation_class) do
|
3
3
|
described_class
|
4
4
|
end
|
@@ -8,7 +8,7 @@ shared_examples_for 'Metasploit::Model::Search::Operation::Value::Integer' do
|
|
8
8
|
operation_class
|
9
9
|
end
|
10
10
|
|
11
|
-
it {
|
11
|
+
it { is_expected.to include Metasploit::Model::Search::Operation::Value::Integer }
|
12
12
|
end
|
13
13
|
|
14
14
|
context '#value' do
|
@@ -26,7 +26,7 @@ shared_examples_for 'Metasploit::Model::Search::Operation::Value::Integer' do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'should pass through Integer' do
|
29
|
-
value.
|
29
|
+
expect(value).to eq(formatted_value)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -40,7 +40,7 @@ shared_examples_for 'Metasploit::Model::Search::Operation::Value::Integer' do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should convert String to Integer' do
|
43
|
-
value.
|
43
|
+
expect(value).to eq(integer)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -54,11 +54,11 @@ shared_examples_for 'Metasploit::Model::Search::Operation::Value::Integer' do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'should not extract the number' do
|
57
|
-
value.
|
57
|
+
expect(value).not_to eq(integer)
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'should pass through the full value' do
|
61
|
-
value.
|
61
|
+
expect(value).to eq(formatted_value)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -68,11 +68,11 @@ shared_examples_for 'Metasploit::Model::Search::Operation::Value::Integer' do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'should not truncate Float to Integer' do
|
71
|
-
value.
|
71
|
+
expect(value).not_to eq(formatted_value.to_i)
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'should pass through Float' do
|
75
|
-
value.
|
75
|
+
expect(value).to eq(formatted_value)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
shared_examples_for 'Metasploit::Model::Search::Operation::Value::String' do
|
1
|
+
RSpec.shared_examples_for 'Metasploit::Model::Search::Operation::Value::String' do
|
2
2
|
let(:operation_class) do
|
3
3
|
described_class
|
4
4
|
end
|
@@ -8,7 +8,7 @@ shared_examples_for 'Metasploit::Model::Search::Operation::Value::String' do
|
|
8
8
|
operation_class
|
9
9
|
end
|
10
10
|
|
11
|
-
it {
|
11
|
+
it { is_expected.to include Metasploit::Model::Search::Operation::Value::String }
|
12
12
|
end
|
13
13
|
|
14
14
|
context '#value' do
|
@@ -26,7 +26,7 @@ shared_examples_for 'Metasploit::Model::Search::Operation::Value::String' do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'should convert to String' do
|
29
|
-
value.
|
29
|
+
expect(value).to eq('5')
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -36,7 +36,7 @@ shared_examples_for 'Metasploit::Model::Search::Operation::Value::String' do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should pass through String' do
|
39
|
-
value.
|
39
|
+
expect(value).to eq(formatted_value)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -46,7 +46,7 @@ shared_examples_for 'Metasploit::Model::Search::Operation::Value::String' do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'should convert to String' do
|
49
|
-
value.
|
49
|
+
expect(value).to eq('a_symbol')
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
shared_examples_for 'Metasploit::Model::Search::Operator::Help' do
|
1
|
+
RSpec.shared_examples_for 'Metasploit::Model::Search::Operator::Help' do
|
2
2
|
context '#help' do
|
3
3
|
subject(:help) do
|
4
4
|
operator.help
|
@@ -24,7 +24,7 @@ shared_examples_for 'Metasploit::Model::Search::Operator::Help' do
|
|
24
24
|
# klass needs to be named or model_name will fail.
|
25
25
|
stub_const('Klass', klass)
|
26
26
|
# since missing translations raise exceptions, and there is no translation for klass, have to stub out.
|
27
|
-
klass.model_name.
|
27
|
+
allow(klass.model_name).to receive(:human).and_return(model)
|
28
28
|
|
29
29
|
backend = I18n.backend
|
30
30
|
|
@@ -59,31 +59,31 @@ shared_examples_for 'Metasploit::Model::Search::Operator::Help' do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'should use #klass #i18n_scope to lookup translations specific to the #klass or one of its ancestors' do
|
62
|
-
klass.
|
62
|
+
expect(klass).to receive(:i18n_scope).and_call_original
|
63
63
|
|
64
64
|
help
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'should lookup ancestors of #klass to find translations specific to #klass or its ancestors' do
|
68
|
-
klass.
|
68
|
+
expect(klass).to receive(:lookup_ancestors).and_call_original
|
69
69
|
|
70
70
|
help
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'should use #class #i18n_scope to lookup translations specific to the operator class or one of its ancestors' do
|
74
|
-
operator.class.
|
74
|
+
expect(operator.class).to receive(:i18n_scope)
|
75
75
|
|
76
76
|
help
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'should lookup ancestors of the operator class to find translations specific to the operator class or one of its ancestors' do
|
80
|
-
operator.class.
|
80
|
+
expect(operator.class).to receive(:lookup_ancestors).and_return([])
|
81
81
|
|
82
82
|
help
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should pass #klass translation key for operator with the given name as the primary translation key" do
|
86
|
-
I18n.
|
86
|
+
expect(I18n).to receive(:translate).with(
|
87
87
|
:"#{klass.i18n_scope}.ancestors.#{klass.model_name.i18n_key}.search.operator.names.#{name}.help",
|
88
88
|
anything
|
89
89
|
)
|
@@ -92,23 +92,25 @@ shared_examples_for 'Metasploit::Model::Search::Operator::Help' do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'should pass other translation keys as default option' do
|
95
|
-
I18n.
|
96
|
-
options.
|
95
|
+
expect(I18n).to receive(:translate) do |_key, options|
|
96
|
+
expect(options).to be_a Hash
|
97
97
|
|
98
98
|
default = options[:default]
|
99
99
|
|
100
|
-
default.
|
100
|
+
expect(default).to be_an Array
|
101
101
|
|
102
|
-
|
103
|
-
|
104
|
-
|
102
|
+
expect(
|
103
|
+
default.all? { |key|
|
104
|
+
key.is_a? Symbol
|
105
|
+
}
|
106
|
+
).to eq(true)
|
105
107
|
end
|
106
108
|
|
107
109
|
help
|
108
110
|
end
|
109
111
|
|
110
112
|
it 'should pass #name of operator as name option' do
|
111
|
-
I18n.
|
113
|
+
expect(I18n).to receive(:translate).with(
|
112
114
|
anything,
|
113
115
|
hash_including(name: name)
|
114
116
|
)
|
@@ -117,7 +119,7 @@ shared_examples_for 'Metasploit::Model::Search::Operator::Help' do
|
|
117
119
|
end
|
118
120
|
|
119
121
|
it 'should pass the human model name of #klass as model option' do
|
120
|
-
I18n.
|
122
|
+
expect(I18n).to receive(:translate).with(
|
121
123
|
anything,
|
122
124
|
hash_including(model: klass.model_name.human)
|
123
125
|
)
|
@@ -126,7 +128,7 @@ shared_examples_for 'Metasploit::Model::Search::Operator::Help' do
|
|
126
128
|
end
|
127
129
|
|
128
130
|
it 'should be translated correctly' do
|
129
|
-
help.
|
131
|
+
expect(help).to eq(help_template % { model: model, name: name })
|
130
132
|
end
|
131
133
|
end
|
132
134
|
end
|