metasploit_data_models 0.24.1.pre.rspec.pre.3.pre.1 → 0.24.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 +3 -1
  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 +10 -0
  8. data/lib/metasploit_data_models/version.rb +1 -2
  9. data/metasploit_data_models.gemspec +1 -1
  10. data/spec/app/models/mdm/api_key_spec.rb +3 -1
  11. data/spec/app/models/mdm/client_spec.rb +11 -9
  12. data/spec/app/models/mdm/cred_spec.rb +54 -42
  13. data/spec/app/models/mdm/event_spec.rb +23 -21
  14. data/spec/app/models/mdm/exploit_attempt_spec.rb +21 -19
  15. data/spec/app/models/mdm/exploited_host_spec.rb +13 -11
  16. data/spec/app/models/mdm/host_detail_spec.rb +17 -15
  17. data/spec/app/models/mdm/host_spec.rb +260 -261
  18. data/spec/app/models/mdm/host_tag_spec.rb +8 -6
  19. data/spec/app/models/mdm/listener_spec.rb +32 -30
  20. data/spec/app/models/mdm/loot_spec.rb +23 -21
  21. data/spec/app/models/mdm/macro_spec.rb +3 -1
  22. data/spec/app/models/mdm/mod_ref_spec.rb +3 -1
  23. data/spec/app/models/mdm/module/action_spec.rb +12 -10
  24. data/spec/app/models/mdm/module/arch_spec.rb +12 -10
  25. data/spec/app/models/mdm/module/author_spec.rb +17 -22
  26. data/spec/app/models/mdm/module/detail_spec.rb +75 -184
  27. data/spec/app/models/mdm/module/mixin_spec.rb +12 -10
  28. data/spec/app/models/mdm/module/platform_spec.rb +12 -10
  29. data/spec/app/models/mdm/module/ref_spec.rb +12 -10
  30. data/spec/app/models/mdm/module/target_spec.rb +15 -13
  31. data/spec/app/models/mdm/nexpose_console_spec.rb +37 -35
  32. data/spec/app/models/mdm/note_spec.rb +25 -23
  33. data/spec/app/models/mdm/profile_spec.rb +3 -1
  34. data/spec/app/models/mdm/ref_spec.rb +12 -10
  35. data/spec/app/models/mdm/route_spec.rb +8 -6
  36. data/spec/app/models/mdm/service_spec.rb +40 -38
  37. data/spec/app/models/mdm/session_event_spec.rb +12 -10
  38. data/spec/app/models/mdm/session_spec.rb +15 -13
  39. data/spec/app/models/mdm/tag_spec.rb +29 -29
  40. data/spec/app/models/mdm/task_cred_spec.rb +11 -9
  41. data/spec/app/models/mdm/task_host_spec.rb +11 -9
  42. data/spec/app/models/mdm/task_service_spec.rb +11 -9
  43. data/spec/app/models/mdm/task_session_spec.rb +9 -7
  44. data/spec/app/models/mdm/task_spec.rb +29 -27
  45. data/spec/app/models/mdm/user_spec.rb +19 -17
  46. data/spec/app/models/mdm/vuln_attempt_spec.rb +16 -14
  47. data/spec/app/models/mdm/vuln_detail_spec.rb +28 -26
  48. data/spec/app/models/mdm/vuln_ref_spec.rb +10 -8
  49. data/spec/app/models/mdm/vuln_spec.rb +26 -24
  50. data/spec/app/models/mdm/web_form_spec.rb +13 -11
  51. data/spec/app/models/mdm/web_page_spec.rb +21 -19
  52. data/spec/app/models/mdm/web_site_spec.rb +23 -21
  53. data/spec/app/models/mdm/web_vuln_spec.rb +65 -63
  54. data/spec/app/models/mdm/wmap_request_spec.rb +3 -1
  55. data/spec/app/models/mdm/wmap_target_spec.rb +3 -1
  56. data/spec/app/models/mdm/workspace_spec.rb +100 -97
  57. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +5 -3
  58. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +15 -13
  59. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +3 -1
  60. data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +3 -1
  61. data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +12 -10
  62. data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +6 -4
  63. data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +23 -21
  64. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +11 -9
  65. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +23 -21
  66. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +6 -4
  67. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +15 -22
  68. data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +6 -4
  69. data/spec/app/models/metasploit_data_models/module_run_spec.rb +3 -1
  70. data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +20 -18
  71. data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +8 -6
  72. data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +10 -8
  73. data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +10 -8
  74. data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +4 -2
  75. data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +10 -8
  76. data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +8 -6
  77. data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +11 -9
  78. data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +7 -5
  79. data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +19 -17
  80. data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +7 -5
  81. data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +23 -61
  82. data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +10 -8
  83. data/spec/app/validators/parameters_validator_spec.rb +29 -29
  84. data/spec/app/validators/password_is_strong_validator_spec.rb +46 -54
  85. data/spec/factories/mdm/module/details.rb +1 -1
  86. data/spec/lib/base64_serializer_spec.rb +19 -19
  87. data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +12 -18
  88. data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +6 -4
  89. data/spec/lib/metasploit_data_models/match/child_spec.rb +4 -2
  90. data/spec/lib/metasploit_data_models/match/parent_spec.rb +6 -4
  91. data/spec/lib/metasploit_data_models/version_spec.rb +5 -3
  92. data/spec/spec_helper.rb +6 -72
  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 +6 -7
  100. metadata +7 -7
@@ -1,4 +1,6 @@
1
- RSpec.describe MetasploitDataModels::Search::Visitor::Where, type: :model do
1
+ require 'spec_helper'
2
+
3
+ describe MetasploitDataModels::Search::Visitor::Where do
2
4
  subject(:visitor) do
3
5
  described_class.new
4
6
  end
@@ -10,7 +12,7 @@ RSpec.describe MetasploitDataModels::Search::Visitor::Where, type: :model do
10
12
  visitor.attribute_visitor
11
13
  end
12
14
 
13
- it { is_expected.to be_a MetasploitDataModels::Search::Visitor::Attribute }
15
+ it { should be_a MetasploitDataModels::Search::Visitor::Attribute }
14
16
  end
15
17
 
16
18
  context '#method_visitor' do
@@ -18,7 +20,7 @@ RSpec.describe MetasploitDataModels::Search::Visitor::Where, type: :model do
18
20
  visitor.method_visitor
19
21
  end
20
22
 
21
- it { is_expected.to be_a MetasploitDataModels::Search::Visitor::Method }
23
+ it { should be_a MetasploitDataModels::Search::Visitor::Method }
22
24
  end
23
25
 
24
26
  context '#visit' do
@@ -82,16 +84,16 @@ RSpec.describe MetasploitDataModels::Search::Visitor::Where, type: :model do
82
84
  end
83
85
 
84
86
  it 'should visit operation.operator with attribute_visitor' do
85
- expect(visitor.attribute_visitor).to receive(:visit).with(operator).and_call_original
87
+ visitor.attribute_visitor.should_receive(:visit).with(operator).and_call_original
86
88
 
87
89
  visit
88
90
  end
89
91
 
90
92
  it 'should call matches on Arel::Attributes::Attribute from attribute_visitor' do
91
93
  attribute = double('Visited Operator')
92
- allow(visitor.attribute_visitor).to receive(:visit).with(operator).and_return(attribute)
94
+ visitor.attribute_visitor.stub(:visit).with(operator).and_return(attribute)
93
95
 
94
- expect(attribute).to receive(:matches).with("%#{value}%")
96
+ attribute.should_receive(:matches).with("%#{value}%")
95
97
 
96
98
  visit
97
99
  end
@@ -163,7 +165,7 @@ RSpec.describe MetasploitDataModels::Search::Visitor::Where, type: :model do
163
165
  end
164
166
 
165
167
  it 'should match module_instances.name with ILIKE' do
166
- expect(visit.to_sql).to eq("\"hosts\".\"name\" ILIKE '%#{name}%'")
168
+ visit.to_sql.should == "\"hosts\".\"name\" ILIKE '%#{name}%'"
167
169
  end
168
170
  end
169
171
 
@@ -177,7 +179,7 @@ RSpec.describe MetasploitDataModels::Search::Visitor::Where, type: :model do
177
179
  end
178
180
 
179
181
  it 'should match module_actions.name with ILIKE' do
180
- expect(visit.to_sql).to eq("\"services\".\"name\" ILIKE '%#{name}%'")
182
+ visit.to_sql.should == "\"services\".\"name\" ILIKE '%#{name}%'"
181
183
  end
182
184
  end
183
185
  end
@@ -1,4 +1,6 @@
1
- RSpec.describe ParametersValidator do
1
+ require 'spec_helper'
2
+
3
+ describe ParametersValidator do
2
4
  subject(:parameters_validator) do
3
5
  described_class.new(
4
6
  :attributes => attributes
@@ -27,7 +29,7 @@ RSpec.describe ParametersValidator do
27
29
 
28
30
  context 'CONSTANTS' do
29
31
  it 'should define TYPE_SIGNATURE_SENTENCE' do
30
- expect(described_class::TYPE_SIGNATURE_SENTENCE).to eq(type_signature_sentence)
32
+ described_class::TYPE_SIGNATURE_SENTENCE.should == type_signature_sentence
31
33
  end
32
34
  end
33
35
 
@@ -46,7 +48,7 @@ RSpec.describe ParametersValidator do
46
48
  end
47
49
 
48
50
  it 'should include prefix' do
49
- expect(error_at).to include(prefix)
51
+ error_at.should include(prefix)
50
52
  end
51
53
 
52
54
  it 'should include location_clause in same sentence as prefix' do
@@ -56,11 +58,11 @@ RSpec.describe ParametersValidator do
56
58
  :index => index
57
59
  )
58
60
 
59
- expect(error_at).to include("#{prefix} #{location_clause}.")
61
+ error_at.should include("#{prefix} #{location_clause}.")
60
62
  end
61
63
 
62
64
  it 'should include TYPE_SIGNATURE_SENTENCE' do
63
- expect(error_at).to include(type_signature_sentence)
65
+ error_at.should include(type_signature_sentence)
64
66
  end
65
67
  end
66
68
 
@@ -79,9 +81,9 @@ RSpec.describe ParametersValidator do
79
81
  end
80
82
 
81
83
  it 'should include extreme in prefix' do
82
- expect(parameters_validator).to receive(:error_at) do |*args|
84
+ parameters_validator.should_receive(:error_at) do |*args|
83
85
  options = args.first
84
- expect(options[:prefix]).to include(extreme.to_s)
86
+ options[:prefix].should include(extreme.to_s)
85
87
  end
86
88
 
87
89
  length_error_at
@@ -98,11 +100,11 @@ RSpec.describe ParametersValidator do
98
100
  end
99
101
 
100
102
  it 'should include numerical index' do
101
- expect(location_clause).to include("at index #{index}")
103
+ location_clause.should include("at index #{index}")
102
104
  end
103
105
 
104
106
  it 'should include inspect of element' do
105
- expect(location_clause).to include(element.inspect)
107
+ location_clause.should include(element.inspect)
106
108
  end
107
109
  end
108
110
 
@@ -142,7 +144,7 @@ RSpec.describe ParametersValidator do
142
144
  end
143
145
 
144
146
  it 'should call #length_error_at with :extreme => :few' do
145
- expect(parameters_validator).to receive(:length_error_at).with(
147
+ parameters_validator.should_receive(:length_error_at).with(
146
148
  hash_including(
147
149
  :extreme => :few
148
150
  )
@@ -154,7 +156,7 @@ RSpec.describe ParametersValidator do
154
156
  it 'should record error' do
155
157
  validate_each
156
158
 
157
- expect(errors).not_to be_empty
159
+ errors.should_not be_empty
158
160
  end
159
161
  end
160
162
 
@@ -164,7 +166,7 @@ RSpec.describe ParametersValidator do
164
166
  end
165
167
 
166
168
  it 'should call #length_error_at with :extreme => :many' do
167
- expect(parameters_validator).to receive(:length_error_at).with(
169
+ parameters_validator.should_receive(:length_error_at).with(
168
170
  hash_including(
169
171
  :extreme => :many
170
172
  )
@@ -176,7 +178,7 @@ RSpec.describe ParametersValidator do
176
178
  it 'should record error' do
177
179
  validate_each
178
180
 
179
- expect(errors).not_to be_empty
181
+ errors.should_not be_empty
180
182
  end
181
183
  end
182
184
 
@@ -201,7 +203,7 @@ RSpec.describe ParametersValidator do
201
203
  end
202
204
 
203
205
  it 'should call error_at with blank parameter name prefix' do
204
- expect(parameters_validator).to receive(:error_at).with(
206
+ parameters_validator.should_receive(:error_at).with(
205
207
  hash_including(
206
208
  :prefix => 'has blank parameter name'
207
209
  )
@@ -213,7 +215,7 @@ RSpec.describe ParametersValidator do
213
215
  it 'should record error' do
214
216
  validate_each
215
217
 
216
- expect(errors).not_to be_empty
218
+ errors.should_not be_empty
217
219
  end
218
220
  end
219
221
 
@@ -225,7 +227,7 @@ RSpec.describe ParametersValidator do
225
227
  it 'should not record error' do
226
228
  validate_each
227
229
 
228
- expect(errors).to be_blank
230
+ errors.should be_blank
229
231
  end
230
232
  end
231
233
  end
@@ -236,7 +238,7 @@ RSpec.describe ParametersValidator do
236
238
  end
237
239
 
238
240
  it 'should call error_at with non-String prefix' do
239
- expect(parameters_validator).to receive(:error_at).with(
241
+ parameters_validator.should_receive(:error_at).with(
240
242
  hash_including(
241
243
  :prefix => "has non-String parameter name (#{parameter_name.inspect})"
242
244
  )
@@ -248,7 +250,7 @@ RSpec.describe ParametersValidator do
248
250
  it 'should record error' do
249
251
  validate_each
250
252
 
251
- expect(errors).not_to be_empty
253
+ errors.should_not be_empty
252
254
  end
253
255
  end
254
256
  end
@@ -262,7 +264,7 @@ RSpec.describe ParametersValidator do
262
264
  it 'should not record error' do
263
265
  validate_each
264
266
 
265
- expect(errors).to be_blank
267
+ errors.should be_blank
266
268
  end
267
269
  end
268
270
 
@@ -272,7 +274,7 @@ RSpec.describe ParametersValidator do
272
274
  end
273
275
 
274
276
  it 'should call error_at with non-String prefix' do
275
- expect(parameters_validator).to receive(:error_at).with(
277
+ parameters_validator.should_receive(:error_at).with(
276
278
  hash_including(
277
279
  :prefix => "has non-String parameter value (#{parameter_value.inspect})"
278
280
  )
@@ -284,7 +286,7 @@ RSpec.describe ParametersValidator do
284
286
  it 'should record error' do
285
287
  validate_each
286
288
 
287
- expect(errors).not_to be_empty
289
+ errors.should_not be_empty
288
290
  end
289
291
  end
290
292
  end
@@ -297,7 +299,7 @@ RSpec.describe ParametersValidator do
297
299
  end
298
300
 
299
301
  it 'should use #error_at with has non-Array for prefix' do
300
- expect(parameters_validator).to receive(:error_at).with(
302
+ parameters_validator.should_receive(:error_at).with(
301
303
  hash_including(
302
304
  :prefix => 'has non-Array'
303
305
  )
@@ -309,7 +311,7 @@ RSpec.describe ParametersValidator do
309
311
  it 'should record error' do
310
312
  validate_each
311
313
 
312
- expect(errors).not_to be_empty
314
+ errors.should_not be_empty
313
315
  end
314
316
  end
315
317
  end
@@ -325,16 +327,14 @@ RSpec.describe ParametersValidator do
325
327
  end
326
328
 
327
329
  it 'should error that attribute is not an array' do
328
- expect(
329
- errors.any? { |error|
330
- error.include? 'is not an Array.'
331
- }
332
- ).to eq(true)
330
+ errors.any? { |error|
331
+ error.include? 'is not an Array.'
332
+ }.should be_true
333
333
  end
334
334
 
335
335
  it 'should include TYPE_SIGNATURE_SENTENCE' do
336
336
  errors.each do |error|
337
- expect(error).to include(type_signature_sentence)
337
+ error.should include(type_signature_sentence)
338
338
  end
339
339
  end
340
340
  end
@@ -1,4 +1,6 @@
1
- RSpec.describe PasswordIsStrongValidator do
1
+ require 'spec_helper'
2
+
3
+ describe PasswordIsStrongValidator do
2
4
 
3
5
  subject(:password_validator) do
4
6
  described_class.new(
@@ -18,23 +20,23 @@ RSpec.describe PasswordIsStrongValidator do
18
20
  context '#contains_repetition?' do
19
21
 
20
22
  it 'should return true for aaaa' do
21
- expect(password_validator.send(:contains_repetition?, 'aaaa')).to eq(true)
23
+ password_validator.send(:contains_repetition?, 'aaaa').should be_true
22
24
  end
23
25
 
24
26
  it 'should return true for ababab' do
25
- expect(password_validator.send(:contains_repetition?, 'ababab')).to eq(true)
27
+ password_validator.send(:contains_repetition?, 'ababab').should be_true
26
28
  end
27
29
 
28
30
  it 'should return true for abcabcabc' do
29
- expect(password_validator.send(:contains_repetition?, 'abcabcabc')).to eq(true)
31
+ password_validator.send(:contains_repetition?, 'abcabcabc').should be_true
30
32
  end
31
33
 
32
34
  it 'should return true for abcdabcd' do
33
- expect(password_validator.send(:contains_repetition?, 'abcdabcd')).to eq(true)
35
+ password_validator.send(:contains_repetition?, 'abcdabcd').should be_true
34
36
  end
35
37
 
36
38
  it 'should return false for abcd1234abcd' do
37
- expect(password_validator.send(:contains_repetition?, 'abcd1234abcd')).to eq(false)
39
+ password_validator.send(:contains_repetition?, 'abcd1234abcd').should be_false
38
40
  end
39
41
 
40
42
  end
@@ -110,7 +112,7 @@ RSpec.describe PasswordIsStrongValidator do
110
112
  ]
111
113
 
112
114
  it 'should return all the expected mutations of a password' do
113
- expect(password_validator.send(:mutate_pass, 'metasploit')).to eq(variants)
115
+ password_validator.send(:mutate_pass, 'metasploit').should == variants
114
116
  end
115
117
 
116
118
  end
@@ -121,81 +123,81 @@ RSpec.describe PasswordIsStrongValidator do
121
123
  PasswordIsStrongValidator::COMMON_PASSWORDS.each do |password|
122
124
 
123
125
  it "should return true for #{password}" do
124
- expect(password_validator.send(:is_common_password?, password)).to eq(true)
126
+ password_validator.send(:is_common_password?, password).should be_true
125
127
  end
126
128
 
127
129
  it "should return true for #{password}!" do
128
- expect(password_validator.send(:is_common_password?, "#{password}!")).to eq(true)
130
+ password_validator.send(:is_common_password?, "#{password}!").should be_true
129
131
  end
130
132
 
131
133
  it "should return true for #{password}1" do
132
- expect(password_validator.send(:is_common_password?, "#{password}1")).to eq(true)
134
+ password_validator.send(:is_common_password?, "#{password}1").should be_true
133
135
  end
134
136
 
135
137
  it "should return true for #{password}9" do
136
- expect(password_validator.send(:is_common_password?, "#{password}1")).to eq(true)
138
+ password_validator.send(:is_common_password?, "#{password}1").should be_true
137
139
  end
138
140
 
139
141
  it "should return true for #{password}99" do
140
- expect(password_validator.send(:is_common_password?, "#{password}12")).to eq(true)
142
+ password_validator.send(:is_common_password?, "#{password}12").should be_true
141
143
  end
142
144
 
143
145
  it "should return true for #{password}123" do
144
- expect(password_validator.send(:is_common_password?, "#{password}123")).to eq(true)
146
+ password_validator.send(:is_common_password?, "#{password}123").should be_true
145
147
  end
146
148
 
147
149
  it "should return true for #{password}123!" do
148
- expect(password_validator.send(:is_common_password?, "#{password}123!")).to eq(true)
150
+ password_validator.send(:is_common_password?, "#{password}123!").should be_true
149
151
  end
150
152
 
151
153
  end
152
154
 
153
155
  it "should return true for r00t" do
154
- expect(password_validator.send(:is_common_password?, "r00t")).to eq(true)
156
+ password_validator.send(:is_common_password?, "r00t").should be_true
155
157
  end
156
158
 
157
159
  it "should return true for m3t@spl0it" do
158
- expect(password_validator.send(:is_common_password?, "m3t@spl0it")).to eq(true)
160
+ password_validator.send(:is_common_password?, "m3t@spl0it").should be_true
159
161
  end
160
162
 
161
163
  it "should return true for m3t@spl0it123!" do
162
- expect(password_validator.send(:is_common_password?, "m3t@spl0it123!")).to eq(true)
164
+ password_validator.send(:is_common_password?, "m3t@spl0it123!").should be_true
163
165
  end
164
166
  end
165
167
 
166
168
  context '#contains_username' do
167
169
 
168
170
  it 'should return true if username and password are the same' do
169
- expect(password_validator.send(:contains_username?, 'admin', 'admin')).to eq(true)
171
+ password_validator.send(:contains_username?, 'admin', 'admin').should be_true
170
172
  end
171
173
 
172
174
  it 'should return true if the password contains the username as part of it' do
173
- expect(password_validator.send(:contains_username?, 'admin', '123admin123')).to eq(true)
175
+ password_validator.send(:contains_username?, 'admin', '123admin123').should be_true
174
176
  end
175
177
 
176
178
  it 'should return false otherwise' do
177
- expect(password_validator.send(:contains_username?, 'admin', 'foobar')).to eq(false)
179
+ password_validator.send(:contains_username?, 'admin', 'foobar').should be_false
178
180
  end
179
181
  end
180
182
 
181
183
  context '#is_simple?' do
182
184
 
183
185
  it "should return true if no number" do
184
- expect(password_validator.send(:is_simple?, "b@carat")).to eq(true)
186
+ password_validator.send(:is_simple?, "b@carat").should be_true
185
187
  end
186
188
 
187
189
  it "should return true if no special char" do
188
- expect(password_validator.send(:is_simple?, "bacarat4")).to eq(true)
190
+ password_validator.send(:is_simple?, "bacarat4").should be_true
189
191
  end
190
192
 
191
193
  it "should return true if no letters" do
192
- expect(password_validator.send(:is_simple?, "1337")).to eq(true)
194
+ password_validator.send(:is_simple?, "1337").should be_true
193
195
  end
194
196
 
195
197
  PasswordIsStrongValidator::SPECIAL_CHARS.each_char do |char|
196
198
 
197
199
  it "should return false with a #{char}" do
198
- expect(password_validator.send(:is_simple?, "bacarat4#{char}")).to eq(false)
200
+ password_validator.send(:is_simple?, "bacarat4#{char}").should be_false
199
201
  end
200
202
  end
201
203
  end
@@ -210,23 +212,13 @@ RSpec.describe PasswordIsStrongValidator do
210
212
  password_validator.validate_each(record, attribute, value)
211
213
  end
212
214
 
213
- let(:record) {
214
- record_class.new.tap { |instance|
215
- instance.username = 'admin'
215
+ let(:record) do
216
+ Object.new.tap { |object|
217
+ object.extend ActiveModel::Validations
218
+ object.class.module_eval { attr_accessor :username }
219
+ object.username = 'admin'
216
220
  }
217
- }
218
-
219
- let(:record_class) {
220
- Class.new do
221
- include ActiveModel::Validations
222
-
223
- #
224
- # Attributes
225
- #
226
-
227
- attr_accessor :username
228
- end
229
- }
221
+ end
230
222
 
231
223
 
232
224
  context 'with a password with no special char' do
@@ -234,12 +226,12 @@ RSpec.describe PasswordIsStrongValidator do
234
226
 
235
227
  it 'should record an error' do
236
228
  validate_each
237
- expect(errors).not_to be_empty
229
+ errors.should_not be_empty
238
230
  end
239
231
 
240
232
  it 'should have an error of "must contain letters, numbers, and at least one special character"' do
241
233
  validate_each
242
- expect(errors.include?("must contain letters, numbers, and at least one special character")).to eq(true)
234
+ errors.include?("must contain letters, numbers, and at least one special character").should be_true
243
235
  end
244
236
  end
245
237
 
@@ -248,12 +240,12 @@ RSpec.describe PasswordIsStrongValidator do
248
240
 
249
241
  it 'should record an error' do
250
242
  validate_each
251
- expect(errors).not_to be_empty
243
+ errors.should_not be_empty
252
244
  end
253
245
 
254
246
  it 'should have an error of "must contain letters, numbers, and at least one special character"' do
255
247
  validate_each
256
- expect(errors.include?("must contain letters, numbers, and at least one special character")).to eq(true)
248
+ errors.include?("must contain letters, numbers, and at least one special character").should be_true
257
249
  end
258
250
  end
259
251
 
@@ -262,12 +254,12 @@ RSpec.describe PasswordIsStrongValidator do
262
254
 
263
255
  it 'should record an error' do
264
256
  validate_each
265
- expect(errors).not_to be_empty
257
+ errors.should_not be_empty
266
258
  end
267
259
 
268
260
  it 'should have an error of "must contain letters, numbers, and at least one special character"' do
269
261
  validate_each
270
- expect(errors.include?("must contain letters, numbers, and at least one special character")).to eq(true)
262
+ errors.include?("must contain letters, numbers, and at least one special character").should be_true
271
263
  end
272
264
  end
273
265
 
@@ -276,12 +268,12 @@ RSpec.describe PasswordIsStrongValidator do
276
268
 
277
269
  it 'should record an error' do
278
270
  validate_each
279
- expect(errors).not_to be_empty
271
+ errors.should_not be_empty
280
272
  end
281
273
 
282
274
  it 'should have an error of "must not contain the username"' do
283
275
  validate_each
284
- expect(errors.include?("must not contain the username")).to eq(true)
276
+ errors.include?("must not contain the username").should be_true
285
277
  end
286
278
  end
287
279
 
@@ -290,12 +282,12 @@ RSpec.describe PasswordIsStrongValidator do
290
282
 
291
283
  it 'should record an error' do
292
284
  validate_each
293
- expect(errors).not_to be_empty
285
+ errors.should_not be_empty
294
286
  end
295
287
 
296
288
  it 'should have an error of "must not be a common password"' do
297
289
  validate_each
298
- expect(errors.include?("must not be a common password")).to eq(true)
290
+ errors.include?("must not be a common password").should be_true
299
291
  end
300
292
  end
301
293
 
@@ -304,12 +296,12 @@ RSpec.describe PasswordIsStrongValidator do
304
296
 
305
297
  it 'should record an error' do
306
298
  validate_each
307
- expect(errors).not_to be_empty
299
+ errors.should_not be_empty
308
300
  end
309
301
 
310
302
  it 'should have an error of "must not be a common password"' do
311
303
  validate_each
312
- expect(errors.include?("must not be a common password")).to eq(true)
304
+ errors.include?("must not be a common password").should be_true
313
305
  end
314
306
  end
315
307
 
@@ -318,12 +310,12 @@ RSpec.describe PasswordIsStrongValidator do
318
310
 
319
311
  it 'should record an error' do
320
312
  validate_each
321
- expect(errors).not_to be_empty
313
+ errors.should_not be_empty
322
314
  end
323
315
 
324
316
  it 'should have an error of "must not be a predictable sequence of characters"' do
325
317
  validate_each
326
- expect(errors.include?("must not be a predictable sequence of characters")).to eq(true)
318
+ errors.include?("must not be a predictable sequence of characters").should be_true
327
319
  end
328
320
  end
329
321