metasploit_data_models 0.24.0 → 0.24.1.pre.rspec.pre.3.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +3 -3
  3. data/Gemfile +1 -3
  4. data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +1 -1
  5. data/app/models/metasploit_data_models/search/visitor/where.rb +1 -1
  6. data/app/validators/password_is_strong_validator.rb +1 -1
  7. data/lib/mdm/host/operating_system_normalization.rb +0 -10
  8. data/lib/metasploit_data_models/version.rb +2 -2
  9. data/metasploit_data_models.gemspec +1 -1
  10. data/spec/app/models/mdm/api_key_spec.rb +1 -3
  11. data/spec/app/models/mdm/client_spec.rb +9 -11
  12. data/spec/app/models/mdm/cred_spec.rb +42 -54
  13. data/spec/app/models/mdm/event_spec.rb +21 -23
  14. data/spec/app/models/mdm/exploit_attempt_spec.rb +19 -21
  15. data/spec/app/models/mdm/exploited_host_spec.rb +11 -13
  16. data/spec/app/models/mdm/host_detail_spec.rb +15 -17
  17. data/spec/app/models/mdm/host_spec.rb +261 -260
  18. data/spec/app/models/mdm/host_tag_spec.rb +6 -8
  19. data/spec/app/models/mdm/listener_spec.rb +30 -32
  20. data/spec/app/models/mdm/loot_spec.rb +21 -23
  21. data/spec/app/models/mdm/macro_spec.rb +1 -3
  22. data/spec/app/models/mdm/mod_ref_spec.rb +1 -3
  23. data/spec/app/models/mdm/module/action_spec.rb +10 -12
  24. data/spec/app/models/mdm/module/arch_spec.rb +10 -12
  25. data/spec/app/models/mdm/module/author_spec.rb +22 -17
  26. data/spec/app/models/mdm/module/detail_spec.rb +184 -75
  27. data/spec/app/models/mdm/module/mixin_spec.rb +10 -12
  28. data/spec/app/models/mdm/module/platform_spec.rb +10 -12
  29. data/spec/app/models/mdm/module/ref_spec.rb +10 -12
  30. data/spec/app/models/mdm/module/target_spec.rb +13 -15
  31. data/spec/app/models/mdm/nexpose_console_spec.rb +35 -37
  32. data/spec/app/models/mdm/note_spec.rb +23 -25
  33. data/spec/app/models/mdm/profile_spec.rb +1 -3
  34. data/spec/app/models/mdm/ref_spec.rb +10 -12
  35. data/spec/app/models/mdm/route_spec.rb +6 -8
  36. data/spec/app/models/mdm/service_spec.rb +38 -40
  37. data/spec/app/models/mdm/session_event_spec.rb +10 -12
  38. data/spec/app/models/mdm/session_spec.rb +13 -15
  39. data/spec/app/models/mdm/tag_spec.rb +29 -29
  40. data/spec/app/models/mdm/task_cred_spec.rb +9 -11
  41. data/spec/app/models/mdm/task_host_spec.rb +9 -11
  42. data/spec/app/models/mdm/task_service_spec.rb +9 -11
  43. data/spec/app/models/mdm/task_session_spec.rb +7 -9
  44. data/spec/app/models/mdm/task_spec.rb +27 -29
  45. data/spec/app/models/mdm/user_spec.rb +17 -19
  46. data/spec/app/models/mdm/vuln_attempt_spec.rb +14 -16
  47. data/spec/app/models/mdm/vuln_detail_spec.rb +26 -28
  48. data/spec/app/models/mdm/vuln_ref_spec.rb +8 -10
  49. data/spec/app/models/mdm/vuln_spec.rb +24 -26
  50. data/spec/app/models/mdm/web_form_spec.rb +11 -13
  51. data/spec/app/models/mdm/web_page_spec.rb +19 -21
  52. data/spec/app/models/mdm/web_site_spec.rb +21 -23
  53. data/spec/app/models/mdm/web_vuln_spec.rb +63 -65
  54. data/spec/app/models/mdm/wmap_request_spec.rb +1 -3
  55. data/spec/app/models/mdm/wmap_target_spec.rb +1 -3
  56. data/spec/app/models/mdm/workspace_spec.rb +97 -100
  57. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +3 -5
  58. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +13 -15
  59. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +1 -3
  60. data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +1 -3
  61. data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +10 -12
  62. data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +4 -6
  63. data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +21 -23
  64. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +9 -11
  65. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +21 -23
  66. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +4 -6
  67. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +22 -15
  68. data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +4 -6
  69. data/spec/app/models/metasploit_data_models/module_run_spec.rb +1 -3
  70. data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +18 -20
  71. data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +6 -8
  72. data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +8 -10
  73. data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +8 -10
  74. data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +2 -4
  75. data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +8 -10
  76. data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +6 -8
  77. data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +9 -11
  78. data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +5 -7
  79. data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +17 -19
  80. data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +5 -7
  81. data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +61 -23
  82. data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +8 -10
  83. data/spec/app/validators/parameters_validator_spec.rb +29 -29
  84. data/spec/app/validators/password_is_strong_validator_spec.rb +54 -46
  85. data/spec/dummy/db/structure.sql +1 -0
  86. data/spec/lib/base64_serializer_spec.rb +19 -19
  87. data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +18 -12
  88. data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +4 -6
  89. data/spec/lib/metasploit_data_models/match/child_spec.rb +2 -4
  90. data/spec/lib/metasploit_data_models/match/parent_spec.rb +4 -6
  91. data/spec/lib/metasploit_data_models/version_spec.rb +3 -5
  92. data/spec/spec_helper.rb +72 -6
  93. data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +2 -2
  94. data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +4 -4
  95. data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +2 -2
  96. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +5 -5
  97. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +5 -5
  98. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +3 -3
  99. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +7 -6
  100. metadata +6 -6
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::Search::Operator::IPAddress do
1
+ RSpec.describe MetasploitDataModels::Search::Operator::IPAddress, type: :model do
4
2
  subject(:operator) {
5
3
  described_class.new
6
4
  }
@@ -14,6 +12,6 @@ describe MetasploitDataModels::Search::Operator::IPAddress do
14
12
  nil
15
13
  }
16
14
 
17
- it { should be_a MetasploitDataModels::Search::Operation::IPAddress }
15
+ it { is_expected.to be_a MetasploitDataModels::Search::Operation::IPAddress }
18
16
  end
19
17
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::Search::Operator::Multitext do
1
+ RSpec.describe MetasploitDataModels::Search::Operator::Multitext, type: :model do
4
2
  subject(:multitext_operator) {
5
3
  described_class.new(
6
4
  attributes
@@ -12,8 +10,8 @@ describe MetasploitDataModels::Search::Operator::Multitext do
12
10
  }
13
11
 
14
12
  context 'validations' do
15
- it { should ensure_length_of(:operator_names).is_at_least(2) }
16
- it { should validate_presence_of :name }
13
+ it { is_expected.to ensure_length_of(:operator_names).is_at_least(2) }
14
+ it { is_expected.to validate_presence_of :name }
17
15
  end
18
16
 
19
17
  context '#children' do
@@ -45,7 +43,7 @@ describe MetasploitDataModels::Search::Operator::Multitext do
45
43
  nil
46
44
  }
47
45
 
48
- it { should == [] }
46
+ it { is_expected.to eq([]) }
49
47
  end
50
48
 
51
49
  context 'with empty String' do
@@ -53,7 +51,7 @@ describe MetasploitDataModels::Search::Operator::Multitext do
53
51
  ''
54
52
  }
55
53
 
56
- it { should == [] }
54
+ it { is_expected.to eq([]) }
57
55
  end
58
56
 
59
57
  context 'without quotes' do
@@ -82,7 +80,7 @@ describe MetasploitDataModels::Search::Operator::Multitext do
82
80
  }
83
81
 
84
82
  it 'generates a single union for quoted words as a single argument' do
85
- expect(children).to have(1).items
83
+ expect(children.length).to eq(1)
86
84
 
87
85
  child = children.first
88
86
 
@@ -101,7 +99,7 @@ describe MetasploitDataModels::Search::Operator::Multitext do
101
99
  }
102
100
 
103
101
  context 'default' do
104
- it { should be_nil }
102
+ it { is_expected.to be_nil }
105
103
  end
106
104
 
107
105
  context 'setter' do
@@ -123,7 +121,7 @@ describe MetasploitDataModels::Search::Operator::Multitext do
123
121
  }
124
122
 
125
123
  context 'default' do
126
- it { should == [] }
124
+ it { is_expected.to eq([]) }
127
125
  end
128
126
  end
129
127
 
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::Search::Operator::Port::List do
1
+ RSpec.describe MetasploitDataModels::Search::Operator::Port::List, type: :model do
4
2
  subject(:port_list_operator) {
5
3
  described_class.new(
6
4
  klass: klass
@@ -17,7 +15,7 @@ describe MetasploitDataModels::Search::Operator::Port::List do
17
15
  described_class::SEPARATOR
18
16
  }
19
17
 
20
- it { should == ',' }
18
+ it { is_expected.to eq(',') }
21
19
  end
22
20
  end
23
21
 
@@ -27,7 +25,7 @@ describe MetasploitDataModels::Search::Operator::Port::List do
27
25
  }
28
26
 
29
27
  context 'default' do
30
- it { should == :port }
28
+ it { is_expected.to eq(:port) }
31
29
  end
32
30
 
33
31
  context 'setter' do
@@ -87,7 +85,7 @@ describe MetasploitDataModels::Search::Operator::Port::List do
87
85
  operation_range.value
88
86
  }
89
87
 
90
- it { should be_a Range }
88
+ it { is_expected.to be_a Range }
91
89
  end
92
90
  end
93
91
  end
@@ -121,7 +119,7 @@ describe MetasploitDataModels::Search::Operator::Port::List do
121
119
  operation_range.value
122
120
  }
123
121
 
124
- it { should be_an Integer }
122
+ it { is_expected.to be_an Integer }
125
123
  end
126
124
  end
127
125
  end
@@ -159,6 +157,6 @@ describe MetasploitDataModels::Search::Operator::Port::List do
159
157
  described_class.operator_name
160
158
  }
161
159
 
162
- it { should == 'port_list' }
160
+ it { is_expected.to eq('port_list') }
163
161
  end
164
162
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::Search::Visitor::Attribute do
1
+ RSpec.describe MetasploitDataModels::Search::Visitor::Attribute, type: :model do
4
2
  subject(:visitor) do
5
3
  described_class.new
6
4
  end
@@ -22,7 +20,7 @@ describe MetasploitDataModels::Search::Visitor::Attribute do
22
20
  node_class = options.fetch(:node_class)
23
21
 
24
22
  context "with #{node_class}" do
25
- it { should be_a Arel::Attributes::Attribute }
23
+ it { is_expected.to be_a Arel::Attributes::Attribute }
26
24
 
27
25
  context '#name' do
28
26
  subject(:name) do
@@ -30,7 +28,7 @@ describe MetasploitDataModels::Search::Visitor::Attribute do
30
28
  end
31
29
 
32
30
  it "should be #{node_class}#attribute" do
33
- name.should == node.attribute
31
+ expect(name).to eq(node.attribute)
34
32
  end
35
33
  end
36
34
 
@@ -40,7 +38,7 @@ describe MetasploitDataModels::Search::Visitor::Attribute do
40
38
  end
41
39
 
42
40
  it "should be Class#arel_table for #{node_class}#klass" do
43
- relation.should == node.klass.arel_table
41
+ expect(relation).to eq(node.klass.arel_table)
44
42
  end
45
43
  end
46
44
  end
@@ -58,19 +56,19 @@ describe MetasploitDataModels::Search::Visitor::Attribute do
58
56
  end
59
57
 
60
58
  it 'should visit Metasploit::Model::Search::Operator::Association#source_operator' do
61
- visitor.should_receive(:visit).with(node).and_call_original
62
- visitor.should_receive(:visit).with(source_operator)
59
+ expect(visitor).to receive(:visit).with(node).and_call_original
60
+ expect(visitor).to receive(:visit).with(source_operator)
63
61
 
64
62
  visit
65
63
  end
66
64
 
67
65
  it 'should return visit of Metasploit::Model::Search::Operator::Association#source_operator' do
68
- visitor.should_receive(:visit).with(node).and_call_original
66
+ expect(visitor).to receive(:visit).with(node).and_call_original
69
67
 
70
68
  visited = double('Source Operator Visited')
71
- visitor.stub(:visit).with(source_operator).and_return(visited)
69
+ allow(visitor).to receive(:visit).with(source_operator).and_return(visited)
72
70
 
73
- visit.should == visited
71
+ expect(visit).to eq(visited)
74
72
  end
75
73
  end
76
74
 
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::Search::Visitor::Includes do
1
+ RSpec.describe MetasploitDataModels::Search::Visitor::Includes, type: :model do
4
2
  subject(:visitor) do
5
3
  described_class.new
6
4
  end
@@ -122,7 +120,7 @@ describe MetasploitDataModels::Search::Visitor::Includes do
122
120
  Metasploit::Model::Search::Operator::Attribute.new
123
121
  end
124
122
 
125
- it { should == [] }
123
+ it { is_expected.to eq([]) }
126
124
  end
127
125
 
128
126
  context 'with MetasploitDataModels::Search::Operator::Port::List' do
@@ -130,7 +128,7 @@ describe MetasploitDataModels::Search::Visitor::Includes do
130
128
  MetasploitDataModels::Search::Operator::Port::List.new
131
129
  end
132
130
 
133
- it { should == [] }
131
+ it { is_expected.to eq([]) }
134
132
  end
135
133
 
136
134
  context 'with Metasploit::Model::Search::Query#tree' do
@@ -160,7 +158,7 @@ describe MetasploitDataModels::Search::Visitor::Includes do
160
158
  "name:\"#{name}\""
161
159
  end
162
160
 
163
- it { should be_empty }
161
+ it { is_expected.to be_empty }
164
162
  end
165
163
 
166
164
  context 'with services.name' do
@@ -172,7 +170,7 @@ describe MetasploitDataModels::Search::Visitor::Includes do
172
170
  "services.name:\"#{name}\""
173
171
  end
174
172
 
175
- it { should include :services }
173
+ it { is_expected.to include :services }
176
174
  end
177
175
  end
178
176
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::Search::Visitor::Joins do
1
+ RSpec.describe MetasploitDataModels::Search::Visitor::Joins, type: :model do
4
2
  subject(:visitor) do
5
3
  described_class.new
6
4
  end
@@ -33,10 +31,10 @@ describe MetasploitDataModels::Search::Visitor::Joins do
33
31
 
34
32
  it 'should visit each child' do
35
33
  # needed for call to visit subject
36
- visitor.should_receive(:visit).with(node).and_call_original
34
+ expect(visitor).to receive(:visit).with(node).and_call_original
37
35
 
38
36
  children.each do |child|
39
- visitor.should_receive(:visit).with(child).and_return([])
37
+ expect(visitor).to receive(:visit).with(child).and_return([])
40
38
  end
41
39
 
42
40
  visit
@@ -45,15 +43,15 @@ describe MetasploitDataModels::Search::Visitor::Joins do
45
43
  it 'should return Array of all child visits' do
46
44
  child_visits = []
47
45
 
48
- visitor.should_receive(:visit).with(node).and_call_original
46
+ expect(visitor).to receive(:visit).with(node).and_call_original
49
47
 
50
48
  children.each_with_index do |child, i|
51
49
  child_visit = ["Visited Child #{i}"]
52
- visitor.stub(:visit).with(child).and_return(child_visit)
50
+ allow(visitor).to receive(:visit).with(child).and_return(child_visit)
53
51
  child_visits.concat(child_visit)
54
52
  end
55
53
 
56
- visit.should == child_visits
54
+ expect(visit).to eq(child_visits)
57
55
  end
58
56
  end
59
57
  end
@@ -81,7 +79,7 @@ describe MetasploitDataModels::Search::Visitor::Joins do
81
79
  }
82
80
  end
83
81
 
84
- it { should == [] }
82
+ it { is_expected.to eq([]) }
85
83
  end
86
84
 
87
85
  context 'with association and attribute' do
@@ -117,7 +115,7 @@ describe MetasploitDataModels::Search::Visitor::Joins do
117
115
  ]
118
116
  end
119
117
 
120
- it { should == [] }
118
+ it { is_expected.to eq([]) }
121
119
  end
122
120
 
123
121
  context 'with the same child join for all' do
@@ -145,7 +143,7 @@ describe MetasploitDataModels::Search::Visitor::Joins do
145
143
  end
146
144
 
147
145
  it 'should include association' do
148
- visit.should include association
146
+ expect(visit).to include association
149
147
  end
150
148
  end
151
149
 
@@ -215,13 +213,13 @@ describe MetasploitDataModels::Search::Visitor::Joins do
215
213
 
216
214
  it 'should include common associations' do
217
215
  common_associations.each do |association|
218
- visit.should include(association)
216
+ expect(visit).to include(association)
219
217
  end
220
218
  end
221
219
 
222
220
  it 'should not include disjoint associations' do
223
221
  disjoint_associations.each do |association|
224
- visit.should_not include(association)
222
+ expect(visit).not_to include(association)
225
223
  end
226
224
  end
227
225
  end
@@ -231,7 +229,7 @@ describe MetasploitDataModels::Search::Visitor::Joins do
231
229
  []
232
230
  end
233
231
 
234
- it { should == [] }
232
+ it { is_expected.to eq([]) }
235
233
  end
236
234
  end
237
235
  end
@@ -241,7 +239,7 @@ describe MetasploitDataModels::Search::Visitor::Joins do
241
239
  []
242
240
  end
243
241
 
244
- it { should == [] }
242
+ it { is_expected.to eq([]) }
245
243
  end
246
244
  end
247
245
  end
@@ -339,7 +337,7 @@ describe MetasploitDataModels::Search::Visitor::Joins do
339
337
  Metasploit::Model::Search::Operator::Attribute.new
340
338
  end
341
339
 
342
- it { should == [] }
340
+ it { is_expected.to eq([]) }
343
341
  end
344
342
 
345
343
  context 'with MetasploitDataModels::Search::Operator::Port::List' do
@@ -347,7 +345,7 @@ describe MetasploitDataModels::Search::Visitor::Joins do
347
345
  MetasploitDataModels::Search::Operator::Port::List.new
348
346
  end
349
347
 
350
- it { should == [] }
348
+ it { is_expected.to eq([]) }
351
349
  end
352
350
 
353
351
  context 'with Metasploit::Model::Search::Query#tree' do
@@ -377,7 +375,7 @@ describe MetasploitDataModels::Search::Visitor::Joins do
377
375
  "name:\"#{name}\""
378
376
  end
379
377
 
380
- it { should be_empty }
378
+ it { is_expected.to be_empty }
381
379
  end
382
380
 
383
381
  context 'with services.name' do
@@ -389,7 +387,7 @@ describe MetasploitDataModels::Search::Visitor::Joins do
389
387
  "services.name:\"#{name}\""
390
388
  end
391
389
 
392
- it { should include :services }
390
+ it { is_expected.to include :services }
393
391
  end
394
392
  end
395
393
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::Search::Visitor::Method do
1
+ RSpec.describe MetasploitDataModels::Search::Visitor::Method, type: :model do
4
2
  subject(:visitor) do
5
3
  described_class.new
6
4
  end
@@ -21,7 +19,7 @@ describe MetasploitDataModels::Search::Visitor::Method do
21
19
  Metasploit::Model::Search::Group::Intersection
22
20
  end
23
21
 
24
- it { should == :and }
22
+ it { is_expected.to eq(:and) }
25
23
  end
26
24
 
27
25
  context 'with Metasploit::Model::Search::Operation::Group::Intersection' do
@@ -29,7 +27,7 @@ describe MetasploitDataModels::Search::Visitor::Method do
29
27
  Metasploit::Model::Search::Operation::Group::Intersection
30
28
  end
31
29
 
32
- it { should == :and }
30
+ it { is_expected.to eq(:and) }
33
31
  end
34
32
 
35
33
  context 'with Metasploit::Model::Search::Group::Union' do
@@ -37,7 +35,7 @@ describe MetasploitDataModels::Search::Visitor::Method do
37
35
  Metasploit::Model::Search::Group::Union
38
36
  end
39
37
 
40
- it { should == :or }
38
+ it { is_expected.to eq(:or) }
41
39
  end
42
40
 
43
41
  context 'with Metasploit::Model::Search::Operation::Group::Union' do
@@ -45,7 +43,7 @@ describe MetasploitDataModels::Search::Visitor::Method do
45
43
  Metasploit::Model::Search::Operation::Group::Union
46
44
  end
47
45
 
48
- it { should == :or }
46
+ it { is_expected.to eq(:or) }
49
47
  end
50
48
  end
51
49
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::Search::Visitor::Relation do
1
+ RSpec.describe MetasploitDataModels::Search::Visitor::Relation, type: :model do
4
2
  subject(:visitor) do
5
3
  described_class.new(
6
4
  :query => query
@@ -31,7 +29,7 @@ describe MetasploitDataModels::Search::Visitor::Relation do
31
29
 
32
30
  context 'validations' do
33
31
  context 'query' do
34
- it { should validate_presence_of(:query) }
32
+ it { is_expected.to validate_presence_of(:query) }
35
33
 
36
34
  context 'valid' do
37
35
  let(:error) do
@@ -48,7 +46,7 @@ describe MetasploitDataModels::Search::Visitor::Relation do
48
46
  end
49
47
 
50
48
  before(:each) do
51
- query.stub(:valid? => query)
49
+ allow(query).to receive(:valid?).and_return(query)
52
50
 
53
51
  visitor.valid?
54
52
  end
@@ -59,7 +57,7 @@ describe MetasploitDataModels::Search::Visitor::Relation do
59
57
  end
60
58
 
61
59
  it 'should not record error' do
62
- errors.should_not include(error)
60
+ expect(errors).not_to include(error)
63
61
  end
64
62
  end
65
63
 
@@ -69,7 +67,7 @@ describe MetasploitDataModels::Search::Visitor::Relation do
69
67
  end
70
68
 
71
69
  it 'should record error' do
72
- errors.should_not include(error)
70
+ expect(errors).not_to include(error)
73
71
  end
74
72
  end
75
73
  end
@@ -80,7 +78,7 @@ describe MetasploitDataModels::Search::Visitor::Relation do
80
78
  end
81
79
 
82
80
  it 'should not record error' do
83
- errors.should_not include(error)
81
+ expect(errors).not_to include(error)
84
82
  end
85
83
  end
86
84
  end
@@ -98,16 +96,16 @@ describe MetasploitDataModels::Search::Visitor::Relation do
98
96
  end
99
97
 
100
98
  it 'should visit Metasploit::Model::Search::Query#tree' do
101
- includes_visitor.should_receive(:visit).with(query.tree)
99
+ expect(includes_visitor).to receive(:visit).with(query.tree)
102
100
 
103
101
  visit
104
102
  end
105
103
 
106
104
  it 'should pass visited to ActiveRecord::Relation#includes' do
107
105
  visited = double('Visited')
108
- includes_visitor.stub(:visit).with(query.tree).and_return(visited)
106
+ allow(includes_visitor).to receive(:visit).with(query.tree).and_return(visited)
109
107
 
110
- ActiveRecord::Relation.any_instance.should_receive(:includes).with(visited).and_return(query.klass.scoped)
108
+ expect_any_instance_of(ActiveRecord::Relation).to receive(:includes).with(visited).and_return(query.klass.scoped)
111
109
 
112
110
  visit
113
111
  end
@@ -119,16 +117,16 @@ describe MetasploitDataModels::Search::Visitor::Relation do
119
117
  end
120
118
 
121
119
  it 'should visit Metasploit::Model::Search::Query#tree' do
122
- joins_visitor.should_receive(:visit).with(query.tree)
120
+ expect(joins_visitor).to receive(:visit).with(query.tree)
123
121
 
124
122
  visit
125
123
  end
126
124
 
127
125
  it 'should pass visited to ActiveRecord::Relation#joins' do
128
126
  visited = double('Visited')
129
- joins_visitor.stub(:visit).with(query.tree).and_return(visited)
127
+ allow(joins_visitor).to receive(:visit).with(query.tree).and_return(visited)
130
128
 
131
- ActiveRecord::Relation.any_instance.should_receive(:joins).with(visited).and_return(query.klass.scoped)
129
+ expect_any_instance_of(ActiveRecord::Relation).to receive(:joins).with(visited).and_return(query.klass.scoped)
132
130
 
133
131
  visit
134
132
  end
@@ -140,16 +138,16 @@ describe MetasploitDataModels::Search::Visitor::Relation do
140
138
  end
141
139
 
142
140
  it 'should visit Metasploit::Model::Search::Query#tree' do
143
- where_visitor.should_receive(:visit).with(query.tree)
141
+ expect(where_visitor).to receive(:visit).with(query.tree)
144
142
 
145
143
  visit
146
144
  end
147
145
 
148
146
  it 'should pass visited to ActiveRecord::Relation#includes' do
149
147
  visited = double('Visited')
150
- where_visitor.stub(:visit).with(query.tree).and_return(visited)
148
+ allow(where_visitor).to receive(:visit).with(query.tree).and_return(visited)
151
149
 
152
- ActiveRecord::Relation.any_instance.should_receive(:where).with(visited).and_return(query.klass.scoped)
150
+ expect_any_instance_of(ActiveRecord::Relation).to receive(:where).with(visited).and_return(query.klass.scoped)
153
151
 
154
152
  visit
155
153
  end
@@ -870,9 +868,29 @@ describe MetasploitDataModels::Search::Visitor::Relation do
870
868
  visitor.visitor_by_relation_method
871
869
  end
872
870
 
873
- its([:joins]) { should be_a MetasploitDataModels::Search::Visitor::Joins }
874
- its([:includes]) { should be_a MetasploitDataModels::Search::Visitor::Includes }
875
- its([:where]) { should be_a MetasploitDataModels::Search::Visitor::Where }
871
+ context 'joins' do
872
+ subject(:joins) {
873
+ visitor_by_relation_method[:joins]
874
+ }
875
+
876
+ it { is_expected.to be_a MetasploitDataModels::Search::Visitor::Joins }
877
+ end
878
+
879
+ context 'includes' do
880
+ subject(:includes) {
881
+ visitor_by_relation_method[:includes]
882
+ }
883
+
884
+ it { is_expected.to be_a MetasploitDataModels::Search::Visitor::Includes }
885
+ end
886
+
887
+ context 'where' do
888
+ subject(:where) {
889
+ visitor_by_relation_method[:where]
890
+ }
891
+
892
+ it { is_expected.to be_a MetasploitDataModels::Search::Visitor::Where }
893
+ end
876
894
  end
877
895
 
878
896
  context 'visitor_class_by_relation_method' do
@@ -880,8 +898,28 @@ describe MetasploitDataModels::Search::Visitor::Relation do
880
898
  described_class.visitor_class_by_relation_method
881
899
  end
882
900
 
883
- its([:joins]) { should == MetasploitDataModels::Search::Visitor::Joins }
884
- its([:includes]) { should == MetasploitDataModels::Search::Visitor::Includes }
885
- its([:where]) { should == MetasploitDataModels::Search::Visitor::Where }
901
+ context 'joins' do
902
+ subject(:joins) {
903
+ visitor_class_by_relation_method[:joins]
904
+ }
905
+
906
+ it { is_expected.to eq(MetasploitDataModels::Search::Visitor::Joins) }
907
+ end
908
+
909
+ context 'includes' do
910
+ subject(:includes) {
911
+ visitor_class_by_relation_method[:includes]
912
+ }
913
+
914
+ it { is_expected.to eq(MetasploitDataModels::Search::Visitor::Includes) }
915
+ end
916
+
917
+ context 'where' do
918
+ subject(:where) {
919
+ visitor_class_by_relation_method[:where]
920
+ }
921
+
922
+ it { is_expected.to eq(MetasploitDataModels::Search::Visitor::Where) }
923
+ end
886
924
  end
887
925
  end