windows_error 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,97 @@
1
+ require 'spec_helper'
2
+
3
+ describe WindowsError::ErrorCode do
4
+
5
+ subject(:error_code) { described_class.new(name,value,description) }
6
+ let(:name) { "STATUS_TIMEOUT" }
7
+ let(:value) { 0x00000102 }
8
+ let(:description) { "The given Timeout interval expired." }
9
+
10
+ context 'with a non-number value' do
11
+ let(:value) { "Bogus" }
12
+
13
+ it 'will raise an ArgumentError' do
14
+ expect{described_class.new(name,value,description)}.to raise_error ArgumentError,"Invalid Error Code Value!"
15
+ end
16
+ end
17
+
18
+ context 'with a non-string description' do
19
+ let(:description) { 42 }
20
+
21
+ it 'will raise an ArgumentError' do
22
+ expect{described_class.new(name,value,description)}.to raise_error ArgumentError,"Invalid Error Description!"
23
+ end
24
+ end
25
+
26
+ context 'with an empty string description' do
27
+ let(:description) { '' }
28
+
29
+ it 'will raise an ArgumentError' do
30
+ expect{described_class.new(name,value,description)}.to raise_error ArgumentError,"Invalid Error Description!"
31
+ end
32
+ end
33
+
34
+ context 'with a non-string name' do
35
+ let(:name) { 42 }
36
+
37
+ it 'will raise an ArgumentError' do
38
+ expect{described_class.new(name,value,description)}.to raise_error ArgumentError,"Invalid Error Name!"
39
+ end
40
+ end
41
+
42
+ context 'with an empty string name' do
43
+ let(:name) { '' }
44
+
45
+ it 'will raise an ArgumentError' do
46
+ expect{described_class.new(name,value,description)}.to raise_error ArgumentError,"Invalid Error Name!"
47
+ end
48
+ end
49
+
50
+ it 'sets #name based on the initializer' do
51
+ expect(error_code.name).to eq name
52
+ end
53
+
54
+ it 'sets #value based on the initializer' do
55
+ expect(error_code.value).to eq value
56
+ end
57
+
58
+ it 'sets #description based on the initializer' do
59
+ expect(error_code.description).to eq description
60
+ end
61
+
62
+ describe '#==' do
63
+ let(:invalid_str) { "foo" }
64
+
65
+ it 'raises an ArgumentError for an invalid comparison' do
66
+ expect{ error_code == invalid_str}.to raise_error ArgumentError, "Cannot compare a WindowsError::ErrorCode to a #{invalid_str.class}"
67
+ end
68
+
69
+ context 'when passed a Fixnum' do
70
+ let(:fixnum_value) { 258 }
71
+ let(:other_fixnum) { 42 }
72
+
73
+ it 'returns true if equal to the #value' do
74
+ expect(error_code == fixnum_value).to eq true
75
+ end
76
+
77
+ it 'returns false if not equal to the #value' do
78
+ expect(error_code == other_fixnum).to eq false
79
+ end
80
+ end
81
+
82
+ context 'when passed another error code' do
83
+ let(:matching_error_code) { described_class.new(name,value,description) }
84
+ let(:other_error_code) { described_class.new(name,42,description) }
85
+
86
+ it 'returns true when the values match' do
87
+ expect(error_code == matching_error_code).to eq true
88
+ end
89
+
90
+ it 'returns false when the values do not match' do
91
+ expect(error_code == other_error_code).to eq false
92
+ end
93
+ end
94
+ end
95
+
96
+
97
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+ require 'windows_error/nt_status'
3
+
4
+ describe WindowsError::NTStatus do
5
+
6
+ describe '#find_by_retval' do
7
+
8
+ it 'raises an argument error when passed an invalid value' do
9
+ expect{ WindowsError::NTStatus.find_by_retval("foo") }.to raise_error ArgumentError,"Invalid Return Code!"
10
+ end
11
+
12
+ it 'returns an array with the error_codes for that return value' do
13
+ expect(WindowsError::NTStatus.find_by_retval(0x00000102)).to match_array([WindowsError::NTStatus::STATUS_TIMEOUT])
14
+ end
15
+
16
+ it 'returns multiple entries if there are more than one match' do
17
+ expect(WindowsError::NTStatus.find_by_retval(0x00000000)).to match_array([WindowsError::NTStatus::STATUS_SUCCESS,WindowsError::NTStatus::STATUS_WAIT_0])
18
+ end
19
+
20
+ it 'returns an empty array if there is no match' do
21
+ expect(WindowsError::NTStatus.find_by_retval(0x99999999)).to match_array([])
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe WindowsError::Version do
4
+ it_should_behave_like 'Metasploit::Version Version Module'
5
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+ require 'windows_error/win32'
3
+
4
+ describe WindowsError::Win32 do
5
+
6
+ describe '#find_by_retval' do
7
+
8
+ it 'raises an argument error when passed an invalid value' do
9
+ expect{ WindowsError::Win32.find_by_retval("foo") }.to raise_error ArgumentError,"Invalid Return Code!"
10
+ end
11
+
12
+ it 'returns an array with the error_codes for that return value' do
13
+ expect(WindowsError::Win32.find_by_retval(0x00000008)).to match_array([WindowsError::Win32::ERROR_NOT_ENOUGH_MEMORY])
14
+ end
15
+
16
+ it 'returns an empty array if there is no match' do
17
+ expect(WindowsError::Win32.find_by_retval(0x99999999)).to match_array([])
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+
3
+ describe WindowsError do
4
+ it_should_behave_like 'Metasploit::Version VERSION constant'
5
+ it_should_behave_like 'Metasploit::Version GEM_VERSION constant'
6
+ end
@@ -0,0 +1,32 @@
1
+ require 'pathname'
2
+ require 'simplecov'
3
+ require 'coveralls'
4
+
5
+ if ENV['TRAVIS'] == 'true'
6
+ # don't generate local report as it is inaccessible on travis-ci, which is
7
+ # why coveralls is being used.
8
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
9
+ else
10
+ SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
11
+ end
12
+
13
+ require 'rspec'
14
+ require 'windows_error'
15
+
16
+ # Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
17
+ gem_specification = Gem::Specification.find_all_by_name('metasploit-version').first
18
+
19
+ Dir[File.join(gem_specification.gem_dir, 'spec', 'support', '**', '*.rb')].each do |f|
20
+ require f
21
+ end
22
+
23
+ # add project lib directory to load path
24
+ spec_pathname = Pathname.new(__FILE__).dirname
25
+ root_pathname = spec_pathname.join('..').expand_path
26
+ # Requires supporting ruby files with custom matchers and macros, etc,
27
+ # in spec/support/ and its subdirectories.
28
+ support_glob = root_pathname.join('spec', 'support', '**', '*.rb')
29
+
30
+ Dir.glob(support_glob) do |path|
31
+ require path
32
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'windows_error/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "windows_error"
8
+ spec.version = WindowsError::VERSION
9
+ spec.authors = ["David Maloney"]
10
+ spec.email = ["DMaloney@rapid7.com"]
11
+ spec.summary = %q{Provides a way to look up Windows NTSTATUS and Win32 Error Codes}
12
+ spec.description = %q{The WindowsError gem provides an easily accessible reference for
13
+ standard Windows API Error Codes. It allows you to do comparisons
14
+ as well as direct lookups of error codes to translate the numerical
15
+ value returned by the API, into a meaninful and humand readable message.}
16
+ spec.homepage = "https://github.com/rapid7/windows_error"
17
+ spec.license = "BSD"
18
+
19
+ spec.files = `git ls-files -z`.split("\x0")
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "yard"
27
+ spec.add_development_dependency "fivemat"
28
+
29
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: windows_error
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - David Maloney
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: yard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fivemat
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: |-
70
+ The WindowsError gem provides an easily accessible reference for
71
+ standard Windows API Error Codes. It allows you to do comparisons
72
+ as well as direct lookups of error codes to translate the numerical
73
+ value returned by the API, into a meaninful and humand readable message.
74
+ email:
75
+ - DMaloney@rapid7.com
76
+ executables: []
77
+ extensions: []
78
+ extra_rdoc_files: []
79
+ files:
80
+ - ".gitignore"
81
+ - ".rspec"
82
+ - ".simplecov"
83
+ - ".travis.yml"
84
+ - CONTRIBUTING.md
85
+ - Gemfile
86
+ - LICENSE.txt
87
+ - README.md
88
+ - Rakefile
89
+ - lib/windows_error.rb
90
+ - lib/windows_error/error_code.rb
91
+ - lib/windows_error/nt_status.rb
92
+ - lib/windows_error/version.rb
93
+ - lib/windows_error/win32.rb
94
+ - spec/lib/windows_error/error_code_spec.rb
95
+ - spec/lib/windows_error/nt_status_spec.rb
96
+ - spec/lib/windows_error/version_spec.rb
97
+ - spec/lib/windows_error/win32_spec.rb
98
+ - spec/lib/windows_error_spec.rb
99
+ - spec/spec_helper.rb
100
+ - windows_error.gemspec
101
+ homepage: https://github.com/rapid7/windows_error
102
+ licenses:
103
+ - BSD
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.4.3
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Provides a way to look up Windows NTSTATUS and Win32 Error Codes
125
+ test_files:
126
+ - spec/lib/windows_error/error_code_spec.rb
127
+ - spec/lib/windows_error/nt_status_spec.rb
128
+ - spec/lib/windows_error/version_spec.rb
129
+ - spec/lib/windows_error/win32_spec.rb
130
+ - spec/lib/windows_error_spec.rb
131
+ - spec/spec_helper.rb
132
+ has_rdoc: