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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -4
  3. data/CHANGELOG.md +6 -0
  4. data/CONTRIBUTING.md +9 -49
  5. data/Gemfile +1 -6
  6. data/RELEASING.md +89 -0
  7. data/UPGRADING.md +1 -0
  8. data/lib/metasploit/model/version.rb +23 -11
  9. data/metasploit-model.gemspec +3 -1
  10. data/spec/app/models/metasploit/model/association/reflection_spec.rb +5 -7
  11. data/spec/app/models/metasploit/model/search/group/base_spec.rb +2 -4
  12. data/spec/app/models/metasploit/model/search/group/intersection_spec.rb +2 -4
  13. data/spec/app/models/metasploit/model/search/group/union_spec.rb +2 -4
  14. data/spec/app/models/metasploit/model/search/operation/association_spec.rb +7 -9
  15. data/spec/app/models/metasploit/model/search/operation/base_spec.rb +5 -7
  16. data/spec/app/models/metasploit/model/search/operation/boolean_spec.rb +14 -11
  17. data/spec/app/models/metasploit/model/search/operation/date_spec.rb +6 -8
  18. data/spec/app/models/metasploit/model/search/operation/group/base_spec.rb +12 -14
  19. data/spec/app/models/metasploit/model/search/operation/group/intersection_spec.rb +2 -4
  20. data/spec/app/models/metasploit/model/search/operation/group/union_spec.rb +2 -4
  21. data/spec/app/models/metasploit/model/search/operation/integer_spec.rb +2 -4
  22. data/spec/app/models/metasploit/model/search/operation/null_spec.rb +4 -6
  23. data/spec/app/models/metasploit/model/search/operation/set/integer_spec.rb +2 -4
  24. data/spec/app/models/metasploit/model/search/operation/set/string_spec.rb +2 -4
  25. data/spec/app/models/metasploit/model/search/operation/set_spec.rb +4 -6
  26. data/spec/app/models/metasploit/model/search/operation/string_spec.rb +2 -4
  27. data/spec/app/models/metasploit/model/search/operator/association_spec.rb +6 -8
  28. data/spec/app/models/metasploit/model/search/operator/attribute_spec.rb +13 -15
  29. data/spec/app/models/metasploit/model/search/operator/base_spec.rb +3 -5
  30. data/spec/app/models/metasploit/model/search/operator/delegation_spec.rb +13 -11
  31. data/spec/app/models/metasploit/model/search/operator/group/base_spec.rb +5 -7
  32. data/spec/app/models/metasploit/model/search/operator/group/intersection_spec.rb +3 -5
  33. data/spec/app/models/metasploit/model/search/operator/group/union_spec.rb +3 -5
  34. data/spec/app/models/metasploit/model/search/operator/null_spec.rb +5 -7
  35. data/spec/app/models/metasploit/model/search/operator/single_spec.rb +26 -28
  36. data/spec/app/models/metasploit/model/search/query_spec.rb +48 -50
  37. data/spec/app/models/metasploit/model/visitation/visitor_spec.rb +7 -9
  38. data/spec/app/validators/ip_format_validator_spec.rb +7 -9
  39. data/spec/app/validators/nil_validator_spec.rb +3 -5
  40. data/spec/app/validators/parameters_validator_spec.rb +29 -29
  41. data/spec/app/validators/password_is_strong_validator_spec.rb +17 -19
  42. data/spec/lib/metasploit/model/association/error_spec.rb +1 -3
  43. data/spec/lib/metasploit/model/association_spec.rb +8 -10
  44. data/spec/lib/metasploit/model/base_spec.rb +3 -5
  45. data/spec/lib/metasploit/model/engine_spec.rb +48 -11
  46. data/spec/lib/metasploit/model/file_spec.rb +3 -5
  47. data/spec/lib/metasploit/model/invalid_spec.rb +7 -9
  48. data/spec/lib/metasploit/model/login/status_spec.rb +1 -3
  49. data/spec/lib/metasploit/model/nilify_blanks_spec.rb +11 -13
  50. data/spec/lib/metasploit/model/realm/key_spec.rb +15 -17
  51. data/spec/lib/metasploit/model/search/association/tree_spec.rb +3 -5
  52. data/spec/lib/metasploit/model/search/association_spec.rb +2 -4
  53. data/spec/lib/metasploit/model/search/attribute_spec.rb +6 -8
  54. data/spec/lib/metasploit/model/search/operation/value/integer_spec.rb +1 -3
  55. data/spec/lib/metasploit/model/search/operation/value/string_spec.rb +1 -3
  56. data/spec/lib/metasploit/model/search/operation_spec.rb +11 -13
  57. data/spec/lib/metasploit/model/search/operator/help_spec.rb +1 -3
  58. data/spec/lib/metasploit/model/search/with_spec.rb +7 -9
  59. data/spec/lib/metasploit/model/search_spec.rb +11 -13
  60. data/spec/lib/metasploit/model/spec/error_spec.rb +2 -4
  61. data/spec/lib/metasploit/model/spec/i18n_exception_handler_spec.rb +5 -7
  62. data/spec/lib/metasploit/model/spec/pathname_collision_spec.rb +4 -6
  63. data/spec/lib/metasploit/model/spec_spec.rb +9 -7
  64. data/spec/lib/metasploit/model/translation_spec.rb +10 -12
  65. data/spec/lib/metasploit/model/version_spec.rb +3 -139
  66. data/spec/lib/metasploit/model/visitation/visit_spec.rb +28 -26
  67. data/spec/lib/metasploit/model_spec.rb +4 -0
  68. data/spec/matchers/validate_nilness_of_spec.rb +0 -2
  69. data/spec/spec_helper.rb +80 -10
  70. data/spec/support/shared/contexts/metasploit/model/search/operator/union/children.rb +1 -1
  71. data/spec/support/shared/examples/metasploit/model/search/operation/value/integer.rb +8 -8
  72. data/spec/support/shared/examples/metasploit/model/search/operation/value/string.rb +5 -5
  73. data/spec/support/shared/examples/metasploit/model/search/operator/help.rb +18 -16
  74. data/spec/support/shared/examples/metasploit/model/translation.rb +4 -4
  75. data/spec/support/shared/examples/search/query.rb +3 -3
  76. data/spec/support/shared/examples/search_association.rb +2 -2
  77. data/spec/support/shared/examples/search_attribute.rb +3 -3
  78. data/spec/support/shared/examples/search_with.rb +3 -3
  79. metadata +43 -4
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Association do
1
+ RSpec.describe Metasploit::Model::Search::Association do
4
2
  subject(:base_class) do
5
3
  described_class = self.described_class
6
4
 
@@ -56,7 +54,7 @@ describe Metasploit::Model::Search::Association do
56
54
 
57
55
  context 'search_associations' do
58
56
  subject(:search_associations) {
59
- base_class.search_associations *associations
57
+ base_class.search_associations(*associations)
60
58
  }
61
59
 
62
60
  let(:associations) {
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Attribute do
1
+ RSpec.describe Metasploit::Model::Search::Attribute do
4
2
  subject(:base_class) do
5
3
  described_class = self.described_class
6
4
 
@@ -26,7 +24,7 @@ describe Metasploit::Model::Search::Attribute do
26
24
  end
27
25
 
28
26
  it 'should call search_with' do
29
- base_class.should_receive(:search_with).with(
27
+ expect(base_class).to receive(:search_with).with(
30
28
  Metasploit::Model::Search::Operator::Attribute,
31
29
  hash_including(
32
30
  :attribute => attribute,
@@ -40,7 +38,7 @@ describe Metasploit::Model::Search::Attribute do
40
38
  it 'should be in search_attribute_operator_by_attribute' do
41
39
  # grab operator first since it calls search_attribute and populates search_attribute_operator_by_attribute
42
40
  cached = operator
43
- base_class.search_with_operator_by_name[attribute].should == cached
41
+ expect(base_class.search_with_operator_by_name[attribute]).to eq(cached)
44
42
  end
45
43
 
46
44
  context 'attribute' do
@@ -49,7 +47,7 @@ describe Metasploit::Model::Search::Attribute do
49
47
  end
50
48
 
51
49
  it 'should be the attribute passed to search_attribute' do
52
- operator_attribute.should == attribute
50
+ expect(operator_attribute).to eq(attribute)
53
51
  end
54
52
  end
55
53
 
@@ -59,7 +57,7 @@ describe Metasploit::Model::Search::Attribute do
59
57
  end
60
58
 
61
59
  it 'should be class on which search_attribute was called' do
62
- klass.should == base_class
60
+ expect(klass).to eq(base_class)
63
61
  end
64
62
  end
65
63
 
@@ -69,7 +67,7 @@ describe Metasploit::Model::Search::Attribute do
69
67
  end
70
68
 
71
69
  it 'should be type passed to search_attribute' do
72
- operator_type.should == type
70
+ expect(operator_type).to eq(type)
73
71
  end
74
72
  end
75
73
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
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
- require 'spec_helper'
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
- require 'spec_helper'
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.stub(:parse_operator).with(formatted_operator).and_return(operator)
52
- operator.stub(:operate_on).with(formatted_value).and_return(operation)
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.should_receive(:parse_operator).with(formatted_operator)
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.should_receive(:operate_on).with(formatted_value)
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.should_receive(:parse_operator).with(formatted_operator)
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.should_receive(:operate_on).with(formatted_value)
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.stub(:operate_on).and_return(operation)
104
+ allow(operator).to receive(:operate_on).and_return(operation)
107
105
 
108
- query.should_receive(:parse_operator).with(formatted_operator).and_return(operator)
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.stub(:parse_operator).and_return(operator)
112
+ allow(query).to receive(:parse_operator).and_return(operator)
115
113
 
116
- operator.should_receive(:operate_on).with('')
114
+ expect(operator).to receive(:operate_on).with('')
117
115
 
118
116
  parse
119
117
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operator::Help do
1
+ RSpec.describe Metasploit::Model::Search::Operator::Help do
4
2
  it_should_behave_like 'Metasploit::Model::Search::Operator::Help' do
5
3
  let(:operator) do
6
4
  operator_class.new(
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
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.should_receive(:new).with(
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.should_receive(:new).with(
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.stub(:new).and_return(operator)
56
+ allow(operator_class).to receive(:new).and_return(operator)
59
57
 
60
- operator.should_receive(:valid!)
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].should == operator
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.should == {}
76
+ expect(search_with_operator_by_name).to eq({})
79
77
  end
80
78
  end
81
79
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
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 { should be_a Metasploit::Model::Search::Association }
20
- it { should be_a Metasploit::Model::Search::Attribute }
21
- it { should be_a Metasploit::Model::Search::With }
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.should == attribute
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 { should be_a Metasploit::Model::Search::Operator::Association }
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.should == 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.should == direct_attribute_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.should == base_class
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.should == 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 { should be_empty }
164
+ it { is_expected.to be_empty }
167
165
  end
168
166
  end
169
167
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Spec::Error do
4
- it { should be_a StandardError }
1
+ RSpec.describe Metasploit::Model::Spec::Error do
2
+ it { is_expected.to be_a StandardError }
5
3
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
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 == converted_exception.class
36
- actual_exception.key.should == converted_exception.key
37
- actual_exception.locale.should == converted_exception.locale
38
- actual_exception.options.should == converted_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
- require 'spec_helper'
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 { should be_a Metasploit::Model::Spec::Error }
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.should include("#{pathname} already exists.")
45
+ expect(message).to include("#{pathname} already exists.")
48
46
  end
49
47
 
50
48
  it 'should include potential cause' do
51
- message.should include('Metasploit::Model::Spec.remove_temporary_pathname was not called after the previous spec.')
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
- require 'spec_helper'
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?.should be_true
36
+ expect(pathname.exist?).to eq(true)
39
37
 
40
38
  remove_temporary_pathname
41
39
 
42
- pathname.exist?.should be_false
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.should == 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
- described_class.instance_variable_get(:@temporary_pathname)
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
- require 'spec_helper'
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.should include(named_class)
60
- base_class.ancestors.should include(named_module)
61
- base_class.ancestors.should include(unnamed_class)
62
- base_class.ancestors.should include(unnamed_module)
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.should include(base_class)
67
- lookup_ancestors.should include(named_class)
68
- lookup_ancestors.should include(named_module)
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.should_not include(unnamed_class)
73
- lookup_ancestors.should_not include(unnamed_module)
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,139 +1,3 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Version do
4
- context 'CONSTANTS' do
5
- context 'MAJOR' do
6
- subject(:major) do
7
- described_class::MAJOR
8
- end
9
-
10
- it { should be_a Integer }
11
- end
12
-
13
- context 'MINOR' do
14
- subject(:minor) do
15
- described_class::MINOR
16
- end
17
-
18
- it { should be_a Integer }
19
- end
20
-
21
- context 'PATCH' do
22
- subject(:patch) do
23
- described_class::PATCH
24
- end
25
-
26
- it { should be_a Integer }
27
- end
28
-
29
- pull_request = ENV['TRAVIS_PULL_REQUEST']
30
-
31
- # a pull request cannot check PRERELEASE because it will be tested in the target branch, but the source itself
32
- # is from the source branch and so has the source branch PRERELEASE.
33
- #
34
- # PRERELEASE can only be set appropriately for a merge by merging to the target branch and then updating PRERELEASE
35
- # on the target branch before committing and/or pushing to github and travis-ci.
36
- if pull_request.nil? || pull_request == 'false'
37
- context 'PREPRELEASE' do
38
- subject(:prerelease) do
39
- described_class::PRERELEASE
40
- end
41
-
42
- branch = ENV['TRAVIS_BRANCH']
43
-
44
- if branch.blank?
45
- branch = `git rev-parse --abbrev-ref HEAD`.strip
46
- end
47
-
48
- if branch == 'master'
49
- it 'does not have a PRERELEASE' do
50
- expect(defined? described_class::PRERELEASE).to be_nil
51
- end
52
- else
53
- branch_regex = /\A(?<type>bug|chore|feature|staging)(\/(?<story>[^\/]+))?\/(?<prerelease>[^\/]+)\z/
54
- match = branch.match(branch_regex)
55
-
56
- if match
57
- it 'matches the branch relative name' do
58
- expect(prerelease).to eq(match[:prerelease])
59
- end
60
- else
61
- tag_regex = /\Av(?<major>\d+).(?<minor>\d+).(?<patch>\d+)(\.pre\.(?<prerelease>.*))?\z/
62
- # travis-ci sets TRAVIS_BRANCH to the tag name for tag builds
63
- match = branch.match(tag_regex)
64
-
65
- if match
66
- tag_prerelease = match[:prerelease]
67
-
68
- if tag_prerelease
69
- it 'matches the tag prerelease converted from a gem version to a VERSION' do
70
- expect(prerelease).to eq(tag_prerelease.gsub('.pre.', '-'))
71
- end
72
- else
73
- it 'does not have a PRERELEASE' do
74
- expect(defined? described_class::PRERELEASE).to be_nil
75
- end
76
- end
77
- else
78
- it 'has a abbreviated reference that can be parsed for prerelease' do
79
- fail "Do not know how to parse #{branch.inspect} for PRERELEASE"
80
- end
81
- end
82
- end
83
- end
84
- end
85
- end
86
- end
87
-
88
- context 'full' do
89
- subject(:full) do
90
- described_class.full
91
- end
92
-
93
- #
94
- # lets
95
- #
96
-
97
- let(:major) do
98
- 1
99
- end
100
-
101
- let(:minor) do
102
- 2
103
- end
104
-
105
- let(:patch) do
106
- 3
107
- end
108
-
109
- before(:each) do
110
- stub_const("#{described_class}::MAJOR", major)
111
- stub_const("#{described_class}::MINOR", minor)
112
- stub_const("#{described_class}::PATCH", patch)
113
- end
114
-
115
- context 'with PRERELEASE' do
116
- let(:prerelease) do
117
- 'prerelease'
118
- end
119
-
120
- before(:each) do
121
- stub_const("#{described_class}::PRERELEASE", prerelease)
122
- end
123
-
124
- it 'is <major>.<minor>.<patch>-<prerelease>' do
125
- expect(full).to eq("#{major}.#{minor}.#{patch}-#{prerelease}")
126
- end
127
- end
128
-
129
- context 'without PRERELEASE' do
130
- before(:each) do
131
- hide_const("#{described_class}::PRERELEASE")
132
- end
133
-
134
- it 'is <major>.<minor>.<patch>' do
135
- expect(full).to eq("#{major}.#{minor}.#{patch}")
136
- end
137
- end
138
- end
139
- end
1
+ RSpec.describe Metasploit::Model::Version do
2
+ it_should_behave_like 'Metasploit::Version Version Module'
3
+ end