metasploit-model 0.30.0-java → 0.30.1-java
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/Gemfile +1 -6
- data/lib/metasploit/model/version.rb +1 -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 +12 -14
- 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 -5
- data/spec/lib/metasploit/model/visitation/visit_spec.rb +28 -26
- data/spec/matchers/validate_nilness_of_spec.rb +0 -2
- data/spec/spec_helper.rb +69 -7
- 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 +2 -2
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Metasploit::Model::Search::Operation::Value::Integer do
|
1
|
+
RSpec.describe Metasploit::Model::Search::Operation::Value::Integer do
|
4
2
|
it_should_behave_like 'Metasploit::Model::Search::Operation::Value::Integer' do
|
5
3
|
let(:operation_class) do
|
6
4
|
described_class = self.described_class
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Metasploit::Model::Search::Operation::Value::String do
|
1
|
+
RSpec.describe Metasploit::Model::Search::Operation::Value::String do
|
4
2
|
it_should_behave_like 'Metasploit::Model::Search::Operation::Value::String' do
|
5
3
|
let(:operation_class) do
|
6
4
|
described_class = self.described_class
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Metasploit::Model::Search::Operation do
|
1
|
+
RSpec.describe Metasploit::Model::Search::Operation do
|
4
2
|
context 'parse' do
|
5
3
|
subject(:parse) do
|
6
4
|
described_class.parse(options)
|
@@ -48,8 +46,8 @@ describe Metasploit::Model::Search::Operation do
|
|
48
46
|
|
49
47
|
context "with at least one ':' in :formatted_operation" do
|
50
48
|
before(:each) do
|
51
|
-
query.
|
52
|
-
operator.
|
49
|
+
allow(query).to receive(:parse_operator).with(formatted_operator).and_return(operator)
|
50
|
+
allow(operator).to receive(:operate_on).with(formatted_value).and_return(operation)
|
53
51
|
end
|
54
52
|
|
55
53
|
context "with multiple ':' in :formatted_operation" do
|
@@ -58,13 +56,13 @@ describe Metasploit::Model::Search::Operation do
|
|
58
56
|
end
|
59
57
|
|
60
58
|
it "should treat portion before first ':' as formatted operator" do
|
61
|
-
query.
|
59
|
+
expect(query).to receive(:parse_operator).with(formatted_operator)
|
62
60
|
|
63
61
|
parse
|
64
62
|
end
|
65
63
|
|
66
64
|
it "should treat portion after first ':' as formatted value including later ':'" do
|
67
|
-
operator.
|
65
|
+
expect(operator).to receive(:operate_on).with(formatted_value)
|
68
66
|
|
69
67
|
parse
|
70
68
|
end
|
@@ -76,13 +74,13 @@ describe Metasploit::Model::Search::Operation do
|
|
76
74
|
end
|
77
75
|
|
78
76
|
it "should use portion before ':' as formatted operator" do
|
79
|
-
query.
|
77
|
+
expect(query).to receive(:parse_operator).with(formatted_operator)
|
80
78
|
|
81
79
|
parse
|
82
80
|
end
|
83
81
|
|
84
82
|
it "should use portion after ':' as formatted value" do
|
85
|
-
operator.
|
83
|
+
expect(operator).to receive(:operate_on).with(formatted_value)
|
86
84
|
|
87
85
|
parse
|
88
86
|
end
|
@@ -103,17 +101,17 @@ describe Metasploit::Model::Search::Operation do
|
|
103
101
|
end
|
104
102
|
|
105
103
|
it "should use entirety as formatted operator" do
|
106
|
-
operator.
|
104
|
+
allow(operator).to receive(:operate_on).and_return(operation)
|
107
105
|
|
108
|
-
query.
|
106
|
+
expect(query).to receive(:parse_operator).with(formatted_operator).and_return(operator)
|
109
107
|
|
110
108
|
parse
|
111
109
|
end
|
112
110
|
|
113
111
|
it "should use '' as formatted value instead of nil" do
|
114
|
-
query.
|
112
|
+
allow(query).to receive(:parse_operator).and_return(operator)
|
115
113
|
|
116
|
-
operator.
|
114
|
+
expect(operator).to receive(:operate_on).with('')
|
117
115
|
|
118
116
|
parse
|
119
117
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Metasploit::Model::Search::With do
|
1
|
+
RSpec.describe Metasploit::Model::Search::With do
|
4
2
|
let(:base_class) do
|
5
3
|
described_class = self.described_class
|
6
4
|
|
@@ -37,7 +35,7 @@ describe Metasploit::Model::Search::With do
|
|
37
35
|
end
|
38
36
|
|
39
37
|
it 'should pass given options to operator_class.new' do
|
40
|
-
operator_class.
|
38
|
+
expect(operator_class).to receive(:new).with(
|
41
39
|
hash_including(options)
|
42
40
|
).and_return(operator)
|
43
41
|
|
@@ -45,7 +43,7 @@ describe Metasploit::Model::Search::With do
|
|
45
43
|
end
|
46
44
|
|
47
45
|
it 'should merge :klass into options passed to operator.new' do
|
48
|
-
operator_class.
|
46
|
+
expect(operator_class).to receive(:new).with(
|
49
47
|
hash_including(
|
50
48
|
:klass => base_class
|
51
49
|
)
|
@@ -55,9 +53,9 @@ describe Metasploit::Model::Search::With do
|
|
55
53
|
end
|
56
54
|
|
57
55
|
it 'should validate operator' do
|
58
|
-
operator_class.
|
56
|
+
allow(operator_class).to receive(:new).and_return(operator)
|
59
57
|
|
60
|
-
operator.
|
58
|
+
expect(operator).to receive(:valid!)
|
61
59
|
|
62
60
|
search_with_operator
|
63
61
|
end
|
@@ -65,7 +63,7 @@ describe Metasploit::Model::Search::With do
|
|
65
63
|
it 'should add operator to search_with_operator_by_name' do
|
66
64
|
search_with_operator
|
67
65
|
|
68
|
-
base_class.search_with_operator_by_name[operator.name].
|
66
|
+
expect(base_class.search_with_operator_by_name[operator.name]).to eq(operator)
|
69
67
|
end
|
70
68
|
end
|
71
69
|
|
@@ -75,7 +73,7 @@ describe Metasploit::Model::Search::With do
|
|
75
73
|
end
|
76
74
|
|
77
75
|
it 'should default to empty Hash' do
|
78
|
-
search_with_operator_by_name.
|
76
|
+
expect(search_with_operator_by_name).to eq({})
|
79
77
|
end
|
80
78
|
end
|
81
79
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Metasploit::Model::Search do
|
1
|
+
RSpec.describe Metasploit::Model::Search do
|
4
2
|
subject(:base_instance) do
|
5
3
|
base_class.new
|
6
4
|
end
|
@@ -16,9 +14,9 @@ describe Metasploit::Model::Search do
|
|
16
14
|
base_class.send(:include, described_class)
|
17
15
|
end
|
18
16
|
|
19
|
-
it {
|
20
|
-
it {
|
21
|
-
it {
|
17
|
+
it { is_expected.to be_a Metasploit::Model::Search::Association }
|
18
|
+
it { is_expected.to be_a Metasploit::Model::Search::Attribute }
|
19
|
+
it { is_expected.to be_a Metasploit::Model::Search::With }
|
22
20
|
|
23
21
|
context 'search_operator_by_name' do
|
24
22
|
subject(:search_operator_by_name) do
|
@@ -45,7 +43,7 @@ describe Metasploit::Model::Search do
|
|
45
43
|
end
|
46
44
|
|
47
45
|
it 'should be same as the attribute' do
|
48
|
-
name.
|
46
|
+
expect(name).to eq(attribute)
|
49
47
|
end
|
50
48
|
end
|
51
49
|
end
|
@@ -90,7 +88,7 @@ describe Metasploit::Model::Search do
|
|
90
88
|
"#{association}.#{associated_attribute}".to_sym
|
91
89
|
end
|
92
90
|
|
93
|
-
it {
|
91
|
+
it { is_expected.to be_a Metasploit::Model::Search::Operator::Association }
|
94
92
|
|
95
93
|
context 'association' do
|
96
94
|
subject(:operator_association) do
|
@@ -98,7 +96,7 @@ describe Metasploit::Model::Search do
|
|
98
96
|
end
|
99
97
|
|
100
98
|
it 'should be the registered association' do
|
101
|
-
operator_association.
|
99
|
+
expect(operator_association).to eq(association)
|
102
100
|
end
|
103
101
|
end
|
104
102
|
|
@@ -112,7 +110,7 @@ describe Metasploit::Model::Search do
|
|
112
110
|
end
|
113
111
|
|
114
112
|
it 'should be operator from associated class' do
|
115
|
-
source_operator.
|
113
|
+
expect(source_operator).to eq(direct_attribute_operator)
|
116
114
|
end
|
117
115
|
end
|
118
116
|
|
@@ -122,7 +120,7 @@ describe Metasploit::Model::Search do
|
|
122
120
|
end
|
123
121
|
|
124
122
|
it 'should be class that called search_operator_by_name' do
|
125
|
-
klass.
|
123
|
+
expect(klass).to eq(base_class)
|
126
124
|
end
|
127
125
|
end
|
128
126
|
end
|
@@ -155,7 +153,7 @@ describe Metasploit::Model::Search do
|
|
155
153
|
end
|
156
154
|
|
157
155
|
it 'should be in search_operator_by_name' do
|
158
|
-
named_operator.
|
156
|
+
expect(named_operator).to eq(operator)
|
159
157
|
end
|
160
158
|
end
|
161
159
|
end
|
@@ -163,7 +161,7 @@ describe Metasploit::Model::Search do
|
|
163
161
|
context 'without search attribute' do
|
164
162
|
context 'without search association' do
|
165
163
|
context 'without search with' do
|
166
|
-
it {
|
164
|
+
it { is_expected.to be_empty }
|
167
165
|
end
|
168
166
|
end
|
169
167
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Metasploit::Model::Spec::I18nExceptionHandler do
|
1
|
+
RSpec.describe Metasploit::Model::Spec::I18nExceptionHandler do
|
4
2
|
subject(:i18n_exception_handler) do
|
5
3
|
described_class.new
|
6
4
|
end
|
@@ -32,10 +30,10 @@ describe Metasploit::Model::Spec::I18nExceptionHandler do
|
|
32
30
|
expect {
|
33
31
|
call
|
34
32
|
}.to raise_error(converted_exception.class) do |actual_exception|
|
35
|
-
actual_exception.class
|
36
|
-
actual_exception.key.
|
37
|
-
actual_exception.locale.
|
38
|
-
actual_exception.options.
|
33
|
+
expect(actual_exception.class).to eq(converted_exception.class)
|
34
|
+
expect(actual_exception.key).to eq(converted_exception.key)
|
35
|
+
expect(actual_exception.locale).to eq(converted_exception.locale)
|
36
|
+
expect(actual_exception.options).to eq(converted_exception.options)
|
39
37
|
end
|
40
38
|
end
|
41
39
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Metasploit::Model::Spec::PathnameCollision do
|
1
|
+
RSpec.describe Metasploit::Model::Spec::PathnameCollision do
|
4
2
|
let(:pathname) do
|
5
3
|
Metasploit::Model::Spec.temporary_pathname.join('pathname')
|
6
4
|
end
|
@@ -9,7 +7,7 @@ describe Metasploit::Model::Spec::PathnameCollision do
|
|
9
7
|
described_class.new(pathname)
|
10
8
|
end
|
11
9
|
|
12
|
-
it {
|
10
|
+
it { is_expected.to be_a Metasploit::Model::Spec::Error }
|
13
11
|
|
14
12
|
context 'check!' do
|
15
13
|
subject(:check!) do
|
@@ -44,11 +42,11 @@ describe Metasploit::Model::Spec::PathnameCollision do
|
|
44
42
|
end
|
45
43
|
|
46
44
|
it 'should include pathname' do
|
47
|
-
message.
|
45
|
+
expect(message).to include("#{pathname} already exists.")
|
48
46
|
end
|
49
47
|
|
50
48
|
it 'should include potential cause' do
|
51
|
-
message.
|
49
|
+
expect(message).to include('Metasploit::Model::Spec.remove_temporary_pathname was not called after the previous spec.')
|
52
50
|
end
|
53
51
|
end
|
54
52
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Metasploit::Model::Spec do
|
1
|
+
RSpec.describe Metasploit::Model::Spec do
|
4
2
|
before(:each) do
|
5
3
|
@before_temporary_pathname = described_class.send(:remove_instance_variable, :@temporary_pathname)
|
6
4
|
end
|
@@ -35,11 +33,11 @@ describe Metasploit::Model::Spec do
|
|
35
33
|
end
|
36
34
|
|
37
35
|
it 'should remove file tree' do
|
38
|
-
pathname.exist
|
36
|
+
expect(pathname.exist?).to eq(true)
|
39
37
|
|
40
38
|
remove_temporary_pathname
|
41
39
|
|
42
|
-
pathname.exist
|
40
|
+
expect(pathname.exist?).to eq(false)
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
@@ -82,7 +80,7 @@ describe Metasploit::Model::Spec do
|
|
82
80
|
end
|
83
81
|
|
84
82
|
it 'should return set pathname' do
|
85
|
-
temporary_pathname.
|
83
|
+
expect(temporary_pathname).to eq(pathname)
|
86
84
|
end
|
87
85
|
end
|
88
86
|
|
@@ -107,7 +105,11 @@ describe Metasploit::Model::Spec do
|
|
107
105
|
expect {
|
108
106
|
described_class.temporary_pathname = temporary_pathname
|
109
107
|
}.to change {
|
110
|
-
|
108
|
+
if described_class.instance_variable_defined? :@temporary_pathname
|
109
|
+
described_class.instance_variable_get(:@temporary_pathname)
|
110
|
+
else
|
111
|
+
nil
|
112
|
+
end
|
111
113
|
}.to(temporary_pathname)
|
112
114
|
end
|
113
115
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Metasploit::Model::Translation do
|
1
|
+
RSpec.describe Metasploit::Model::Translation do
|
4
2
|
let(:base_class) do
|
5
3
|
described_class = self.described_class
|
6
4
|
|
@@ -56,21 +54,21 @@ describe Metasploit::Model::Translation do
|
|
56
54
|
end
|
57
55
|
|
58
56
|
it 'should have named and unnamed ancestors' do
|
59
|
-
base_class.ancestors.
|
60
|
-
base_class.ancestors.
|
61
|
-
base_class.ancestors.
|
62
|
-
base_class.ancestors.
|
57
|
+
expect(base_class.ancestors).to include(named_class)
|
58
|
+
expect(base_class.ancestors).to include(named_module)
|
59
|
+
expect(base_class.ancestors).to include(unnamed_class)
|
60
|
+
expect(base_class.ancestors).to include(unnamed_module)
|
63
61
|
end
|
64
62
|
|
65
63
|
it 'should return all ancestors that respond to model_name' do
|
66
|
-
lookup_ancestors.
|
67
|
-
lookup_ancestors.
|
68
|
-
lookup_ancestors.
|
64
|
+
expect(lookup_ancestors).to include(base_class)
|
65
|
+
expect(lookup_ancestors).to include(named_class)
|
66
|
+
expect(lookup_ancestors).to include(named_module)
|
69
67
|
end
|
70
68
|
|
71
69
|
it 'should not return ancestors that do not respond to model_name' do
|
72
|
-
lookup_ancestors.
|
73
|
-
lookup_ancestors.
|
70
|
+
expect(lookup_ancestors).not_to include(unnamed_class)
|
71
|
+
expect(lookup_ancestors).not_to include(unnamed_module)
|
74
72
|
end
|
75
73
|
end
|
76
74
|
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Metasploit::Model::Version do
|
1
|
+
RSpec.describe Metasploit::Model::Version do
|
4
2
|
context 'CONSTANTS' do
|
5
3
|
context 'MAJOR' do
|
6
4
|
subject(:major) do
|
@@ -17,7 +15,7 @@ describe Metasploit::Model::Version do
|
|
17
15
|
described_class::MINOR
|
18
16
|
end
|
19
17
|
|
20
|
-
it {
|
18
|
+
it { is_expected.to be_a Integer }
|
21
19
|
end
|
22
20
|
|
23
21
|
context 'PATCH' do
|
@@ -25,7 +23,7 @@ describe Metasploit::Model::Version do
|
|
25
23
|
described_class::PATCH
|
26
24
|
end
|
27
25
|
|
28
|
-
it {
|
26
|
+
it { is_expected.to be_a Integer }
|
29
27
|
end
|
30
28
|
|
31
29
|
pull_request = ENV['TRAVIS_PULL_REQUEST']
|
@@ -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
|