From c812ebaa631ad00d9d7e136fbe545e18d2589ef8 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 20 Dec 2019 21:58:08 -0800 Subject: Add all the dev deps we need for testing Signed-off-by: Tim Smith --- Gemfile | 10 +++++++++- wmi-lite.gemspec | 4 ---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index e3b6279..c970eae 100644 --- a/Gemfile +++ b/Gemfile @@ -8,8 +8,16 @@ group :docs do gem "github-markup" end -group :debug do +group :test do + gem "chefstyle" + gem "rspec", "~> 3.1" + gem "rake" +end + +group :development do gem "pry" gem "pry-byebug" gem "pry-stack_explorer" + gem "rb-readline" + gem "simplecov", "~> 0.9" end diff --git a/wmi-lite.gemspec b/wmi-lite.gemspec index 6b3e546..771a57d 100644 --- a/wmi-lite.gemspec +++ b/wmi-lite.gemspec @@ -20,8 +20,4 @@ Gem::Specification.new do |spec| spec.files = %w{LICENSE} + Dir.glob("lib/**/*") spec.require_paths = ['lib'] - - spec.add_development_dependency 'bundler' - spec.add_development_dependency 'rspec' - spec.add_development_dependency 'rake' end -- cgit v1.2.1 From 60261bd2993c5625bc095ea52a9c91651d745617 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 20 Dec 2019 21:58:25 -0800 Subject: Apply Chefstyle Signed-off-by: Tim Smith --- .rubocop.yml | 8 +++ lib/wmi-lite.rb | 3 +- lib/wmi-lite/wmi.rb | 16 +++--- lib/wmi-lite/wmi_exception.rb | 5 +- spec/functional/wmi_spec.rb | 98 +++++++++++++++++----------------- spec/spec_helper.rb | 9 ++-- spec/unit/wmi_spec.rb | 120 +++++++++++++++++++++--------------------- wmi-lite.gemspec | 30 +++++------ 8 files changed, 147 insertions(+), 142 deletions(-) create mode 100644 .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..02323b3 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,8 @@ +Lint/UselessAssignment: + Exclude: + - 'lib/wmi-lite/wmi.rb' + - 'spec/unit/wmi_spec.rb' + +Lint/Void: + Exclude: + - 'spec/unit/wmi_spec.rb' diff --git a/lib/wmi-lite.rb b/lib/wmi-lite.rb index 8c94317..44375b3 100644 --- a/lib/wmi-lite.rb +++ b/lib/wmi-lite.rb @@ -16,5 +16,4 @@ # limitations under the License. # -require 'wmi-lite/wmi' - +require "wmi-lite/wmi" diff --git a/lib/wmi-lite/wmi.rb b/lib/wmi-lite/wmi.rb index 9f7c07c..2f54825 100644 --- a/lib/wmi-lite/wmi.rb +++ b/lib/wmi-lite/wmi.rb @@ -16,14 +16,14 @@ # limitations under the License. # -require 'win32ole' if RUBY_PLATFORM =~ /mswin|mingw32|windows/ -require 'wmi-lite/wmi_instance' -require 'wmi-lite/wmi_exception' +require "win32ole" if RUBY_PLATFORM =~ /mswin|mingw32|windows/ +require "wmi-lite/wmi_instance" +require "wmi-lite/wmi_exception" module WmiLite class Wmi def initialize(namespace = nil) - @namespace = namespace.nil? ? 'root/cimv2' : namespace + @namespace = namespace.nil? ? "root/cimv2" : namespace @connection = nil end @@ -38,7 +38,7 @@ module WmiLite def first_of(wmi_class) query_result = start_query("select * from #{wmi_class}", wmi_class) first_result = nil - query_result.each do | record | + query_result.each do |record| first_result = record break end @@ -52,7 +52,7 @@ module WmiLite result_set = [] - results.each do | result | + results.each do |result| result_set.push(wmi_result_to_snapshot(result)) end @@ -80,10 +80,10 @@ module WmiLite def connect_to_namespace if @connection.nil? - namespace = @namespace.nil? ? 'root/cimv2' : @namespace + namespace = @namespace.nil? ? "root/cimv2" : @namespace locator = WIN32OLE.new("WbemScripting.SWbemLocator") begin - @connection = locator.ConnectServer('.', namespace) + @connection = locator.ConnectServer(".", namespace) rescue WIN32OLERuntimeError => native_exception raise WmiException.new(native_exception, :ConnectServer, @namespace) end diff --git a/lib/wmi-lite/wmi_exception.rb b/lib/wmi-lite/wmi_exception.rb index 4ea3a41..7d97011 100644 --- a/lib/wmi-lite/wmi_exception.rb +++ b/lib/wmi-lite/wmi_exception.rb @@ -17,7 +17,7 @@ # module WmiLite - class WmiException < Exception + class WmiException < RuntimeError def initialize(exception, wmi_method_context, namespace, query = nil, class_name = nil) error_message = exception.message error_code = translate_error_code(error_message) @@ -40,7 +40,7 @@ module WmiLite # Parse the error to get the error status code error_code_match = error_message.match(/[^\:]+\:\s*([0-9A-Fa-f]{1,8}).*/) error_code = error_code_match.captures.first if error_code_match - error_code ? error_code : '' + error_code ? error_code : "" end def translate_wmi_connect_error_message(native_message, error_code, namespace) @@ -74,4 +74,3 @@ module WmiLite end end end - diff --git a/spec/functional/wmi_spec.rb b/spec/functional/wmi_spec.rb index cf16f44..e6bfe0e 100644 --- a/spec/functional/wmi_spec.rb +++ b/spec/functional/wmi_spec.rb @@ -16,101 +16,101 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe WmiLite::Wmi, :windows_only do let(:wmi) { WmiLite::Wmi.new(namespace) } def validate_wmi_results(results, class_name) result_collection = cardinality_transform.call(results) - result_collection.each do | result | + result_collection.each do |result| # make sure the class name of the instance is what we asked for - expect(result['creationclassname'].downcase).to eql(class_name.downcase) + expect(result["creationclassname"].downcase).to eql(class_name.downcase) end end - shared_examples_for 'a valid WMI query result' do - it 'should successfully return multiple results' do + shared_examples_for "a valid WMI query result" do + it "should successfully return multiple results" do query_parameter = wmi_query.nil? ? wmi_class : wmi_query results = wmi.send(query_method, query_parameter) validate_wmi_results(results, wmi_class) end - describe 'when the namespace is invalid' do - it_behaves_like 'an invalid namespace' + describe "when the namespace is invalid" do + it_behaves_like "an invalid namespace" end end - shared_examples_for 'an invalid query' do - it 'should raise an exception' do + shared_examples_for "an invalid query" do + it "should raise an exception" do expect { wmi.send(query_method, wmi_query) }.to raise_error(WmiLite::WmiException) end end - shared_examples_for 'an invalid namespace' do - it 'should raise an exception if an invalid namespace is specified' do - invalid_wmi = WmiLite::Wmi.new('root/notvalid') + shared_examples_for "an invalid namespace" do + it "should raise an exception if an invalid namespace is specified" do + invalid_wmi = WmiLite::Wmi.new("root/notvalid") expect { invalid_wmi.send(query_method, wmi_query) }.to raise_error(WmiLite::WmiException) end end - shared_examples_for 'a valid WMI query' do - let(:wmi_class) { 'Win32_LogicalDisk' } - it_behaves_like 'a valid WMI query result' + shared_examples_for "a valid WMI query" do + let(:wmi_class) { "Win32_LogicalDisk" } + it_behaves_like "a valid WMI query result" - let(:wmi_class) { 'Win32_ComputerSystem' } - it_behaves_like 'a valid WMI query result' + let(:wmi_class) { "Win32_ComputerSystem" } + it_behaves_like "a valid WMI query result" - let(:wmi_class) { 'Win32_Process' } - it_behaves_like 'a valid WMI query result' + let(:wmi_class) { "Win32_Process" } + it_behaves_like "a valid WMI query result" - context 'that return 0 results' do - let(:wmi_class) { 'Win32_TapeDrive' } - it_behaves_like 'a valid WMI query result' + context "that return 0 results" do + let(:wmi_class) { "Win32_TapeDrive" } + it_behaves_like "a valid WMI query result" end end - context 'when making valid queries' do + context "when making valid queries" do let(:namespace) { nil } let(:wmi_query) { nil } - let(:cardinality_transform) { lambda{|x| x} } - context 'using first_of' do - let(:cardinality_transform) { lambda{|x| x.nil? ? [] : [x] } } + let(:cardinality_transform) { lambda { |x| x } } + context "using first_of" do + let(:cardinality_transform) { lambda { |x| x.nil? ? [] : [x] } } let(:query_method) { :first_of } - it_behaves_like 'a valid WMI query' + it_behaves_like "a valid WMI query" end - context 'using instances_of' do + context "using instances_of" do let(:query_method) { :instances_of } - it_behaves_like 'a valid WMI query' + it_behaves_like "a valid WMI query" end - context 'using query' do + context "using query" do let(:wmi_query) { "select * from #{wmi_class}" } let(:query_method) { :query } - it_behaves_like 'a valid WMI query' + it_behaves_like "a valid WMI query" end end - context 'when making invalid queries' do + context "when making invalid queries" do let(:namespace) { nil } - let(:wmi_query) { 'invalidclass' } + let(:wmi_query) { "invalidclass" } let(:query_method) { :first_of } - it_behaves_like 'an invalid query' + it_behaves_like "an invalid query" let(:query_method) { :instances_of } - it_behaves_like 'an invalid query' + it_behaves_like "an invalid query" let(:query_method) { :query } - let(:wmi_query) { 'nosql_4_life' } - it_behaves_like 'an invalid query' + let(:wmi_query) { "nosql_4_life" } + it_behaves_like "an invalid query" end let(:namespace) { nil } - describe 'when querying Win32_Environment' do - it 'should have the same environment variables as the Ruby ENV environment hash' do - results = wmi.instances_of('Win32_Environment') + describe "when querying Win32_Environment" do + it "should have the same environment variables as the Ruby ENV environment hash" do + results = wmi.instances_of("Win32_Environment") variables = {} @@ -119,15 +119,15 @@ describe WmiLite::Wmi, :windows_only do # PROCESSOR_ARCHITECTURE is actually the real processor arch of the system, so #{ENV['processor_architecture']} will # report X86, while WMI will (correctly) report X64. # And username is oddly the username of the WMI service, i.e. 'SYSTEM'. - ignore = {'path' => true, 'pathext' => true, 'processor_architecture' => true, 'psmodulepath' => true, 'username' => true} - results.each do | result | - if ! variables.has_key?(result['name']) || result['username'] != '' - variables[result['name']] = result['variablevalue'] + ignore = { "path" => true, "pathext" => true, "processor_architecture" => true, "psmodulepath" => true, "username" => true } + results.each do |result| + if ! variables.key?(result["name"]) || result["username"] != "" + variables[result["name"]] = result["variablevalue"] end end verified_count = 0 - variables.each_pair do | name, value | + variables.each_pair do |name, value| if ignore[name.downcase] != true # Turn %SYSTEMROOT% into c:\windows @@ -146,10 +146,10 @@ describe WmiLite::Wmi, :windows_only do end let(:namespace) { nil } - it 'should ignore case when retrieving WMI properties' do - result = wmi.first_of('Win32_ComputerSystem') - caption_mixed = result['Caption'] - caption_lower = result['caption'] + it "should ignore case when retrieving WMI properties" do + result = wmi.first_of("Win32_ComputerSystem") + caption_mixed = result["Caption"] + caption_lower = result["caption"] expect(caption_mixed.nil?).to eql(false) expect(caption_lower.nil?).to eql(false) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 58036cc..762363c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,11 +1,10 @@ # $:.unshift File.expand_path('../../lib', __FILE__) -require 'rspec' -require 'wmi-lite' +require "rspec" +require "wmi-lite" RSpec.configure do |config| config.include(RSpec::Matchers) - config.filter_run :focus => true - config.filter_run_excluding :windows_only => true if ! (RUBY_PLATFORM =~ /mswin|mingw32|windows/) + config.filter_run focus: true + config.filter_run_excluding windows_only: true unless RUBY_PLATFORM =~ /mswin|mingw32|windows/ config.run_all_when_everything_filtered = true end - diff --git a/spec/unit/wmi_spec.rb b/spec/unit/wmi_spec.rb index a116ec9..3ee3805 100644 --- a/spec/unit/wmi_spec.rb +++ b/spec/unit/wmi_spec.rb @@ -16,37 +16,37 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe WmiLite::Wmi do - let(:wbem_locator) { double 'WIN32OLE', :ConnectServer => wbem_connection } - let(:wmi_query_instance1) { double 'Wmi::Instance', :wmi_ole_object => native_query_instance1, :[] => native_properties1 } - let(:wmi_query_instance2) { double 'Wmi::Instance', :wmi_ole_object => native_query_instance2, :[] => native_properties2 } + let(:wbem_locator) { double "WIN32OLE", ConnectServer: wbem_connection } + let(:wmi_query_instance1) { double "Wmi::Instance", :wmi_ole_object => native_query_instance1, :[] => native_properties1 } + let(:wmi_query_instance2) { double "Wmi::Instance", :wmi_ole_object => native_query_instance2, :[] => native_properties2 } let(:wmi_query_result1) { [ wmi_query_instance1 ].to_enum } let(:wmi_query_result2) { [ wmi_query_instance1, wmi_query_instance2 ].to_enum } let(:native_query_result1) { [ native_query_instance1 ].to_enum } let(:native_query_result2) { [ native_query_instance1, native_query_instance2 ].to_enum } let(:wmi_query_result_empty) { [].to_enum } - let(:native_properties1) { wmi_properties1.map { | property, value | double 'WIN32OLE', :name => property } } - let(:native_properties2) { wmi_properties2.map { | property, value | double 'WIN32OLE', :name => property } } - let(:native_query_instance1) { double 'WIN32OLE', :properties_ => native_properties1, :invoke => 'value1' } - let(:native_query_instance2) { double 'WIN32OLE', :properties_ => native_properties2, :invoke => 'value2' } - let(:wbem_connection) { double 'WIN32OLE', :ExecQuery => native_query_result } + let(:native_properties1) { wmi_properties1.map { |property, value| double "WIN32OLE", name: property } } + let(:native_properties2) { wmi_properties2.map { |property, value| double "WIN32OLE", name: property } } + let(:native_query_instance1) { double "WIN32OLE", properties_: native_properties1, invoke: "value1" } + let(:native_query_instance2) { double "WIN32OLE", properties_: native_properties2, invoke: "value2" } + let(:wbem_connection) { double "WIN32OLE", ExecQuery: native_query_result } def validate_query_result(actual, expected) expect(actual.count).to eql(expected.count) index = 0 - expected.each do | expected_value | + expected.each do |expected_value| actual_value = actual[index] expected_value.wmi_ole_object.invoke == actual_value.wmi_ole_object.invoke - expected_value.wmi_ole_object.properties_.each do | expected_property | + expected_value.wmi_ole_object.properties_.each do |expected_property| expect(actual_value[expected_property.name]).not_to eql(nil) - names = actual_value.wmi_ole_object.properties_.map { | property | property.name } + names = actual_value.wmi_ole_object.properties_.map(&:name) expect(names.include?(expected_property.name)).to eql(true) @@ -56,9 +56,9 @@ describe WmiLite::Wmi do end before(:each) do - stub_const('WIN32OLE', Class.new) + stub_const("WIN32OLE", Class.new) WIN32OLE.stub(:new).with("WbemScripting.SWbemLocator").and_return(wbem_locator) - stub_const('WIN32OLERuntimeError', Class.new(Exception)) + stub_const("WIN32OLERuntimeError", Class.new(RuntimeError)) end let(:wmi) { WmiLite::Wmi.new } @@ -66,21 +66,21 @@ describe WmiLite::Wmi do let(:native_query_result) { [].to_enum } it "should not fail with empty query results" do - results = wmi.query('') + results = wmi.query("") result_count = 0 - results.each { | result | result_count += 1 } + results.each { |result| result_count += 1 } expect( result_count ).to eq(0) end shared_examples_for "the first_of method" do - let(:wmi_properties1) { { 'cores' => 4, 'name' => 'mycomputer1', 'diskspace' => 400, 'os' => 'windows' } } - let(:wmi_properties2) { { 'cores' => 2, 'name' => 'mycomputer2', 'bios' => 'ami', 'os' => 'windows' } } + let(:wmi_properties1) { { "cores" => 4, "name" => "mycomputer1", "diskspace" => 400, "os" => "windows" } } + let(:wmi_properties2) { { "cores" => 2, "name" => "mycomputer2", "bios" => "ami", "os" => "windows" } } let(:native_query_result) { [].to_enum } it "should not fail with empty query results" do - results = wmi.first_of('vm') + results = wmi.first_of("vm") expect( results ).to eq(nil) end @@ -89,7 +89,7 @@ describe WmiLite::Wmi do let(:native_query_result) { native_query_result1 } it "should get one instance" do - results = wmi.first_of('vm') + results = wmi.first_of("vm") expected_result = WmiLite::Wmi::Instance.new(native_query_result.first) validate_query_result([results], [expected_result]) end @@ -100,7 +100,7 @@ describe WmiLite::Wmi do let(:native_query_result) { native_query_result2 } it "should get one instance" do - results = wmi.first_of('vm') + results = wmi.first_of("vm") expected_result = WmiLite::Wmi::Instance.new(native_query_result.first) validate_query_result([results], [expected_result]) end @@ -110,12 +110,12 @@ describe WmiLite::Wmi do shared_examples_for "the instances_of method" do - let(:wmi_properties1) { { 'cores' => 4, 'name' => 'mycomputer1', 'diskspace' => 400, 'os' => 'windows' } } - let(:wmi_properties2) { { 'cores' => 2, 'name' => 'mycomputer2', 'bios' => 'ami', 'os' => 'windows' } } + let(:wmi_properties1) { { "cores" => 4, "name" => "mycomputer1", "diskspace" => 400, "os" => "windows" } } + let(:wmi_properties2) { { "cores" => 2, "name" => "mycomputer2", "bios" => "ami", "os" => "windows" } } let(:native_query_result) { [].to_enum } it "should not fail with empty query results" do - results = wmi.instances_of('vm') + results = wmi.instances_of("vm") expect( results ).to eq([]) end @@ -124,9 +124,9 @@ describe WmiLite::Wmi do let(:native_query_result) { native_query_result1 } it "should get one instance" do - results = wmi.instances_of('vm') + results = wmi.instances_of("vm") index = 0 - expected_result = results.map do | result | + expected_result = results.map do |result| WmiLite::Wmi::Instance.new(result.wmi_ole_object) end validate_query_result(results, expected_result) @@ -138,9 +138,9 @@ describe WmiLite::Wmi do let(:native_query_result) { native_query_result2 } it "should get one instance" do - results = wmi.instances_of('vm') + results = wmi.instances_of("vm") index = 0 - expected_result = results.map do | result | + expected_result = results.map do |result| WmiLite::Wmi::Instance.new(result.wmi_ole_object) end validate_query_result(results, expected_result) @@ -149,15 +149,15 @@ describe WmiLite::Wmi do end - shared_examples_for 'an invalid query' do - let(:unparseable_error) { 'unparseableerror' } - it 'should raise an exception' do + shared_examples_for "an invalid query" do + let(:unparseable_error) { "unparseableerror" } + it "should raise an exception" do wbem_connection.should_receive(:ExecQuery).and_raise(WIN32OLERuntimeError) wmi_service = WmiLite::Wmi.new expect { wmi_service.send(query_method, wmi_query) }.to raise_error(WmiLite::WmiException) end - it 'should raise an exception that ends with the original exception message' do + it "should raise an exception that ends with the original exception message" do wbem_connection.should_receive(:ExecQuery).and_raise(WIN32OLERuntimeError.new(unparseable_error)) wmi_service = WmiLite::Wmi.new error_message = nil @@ -177,15 +177,15 @@ describe WmiLite::Wmi do end end - shared_examples_for 'an invalid namespace' do - let(:unparseable_error) { 'unparseableerror' } - it 'should raise an exception' do + shared_examples_for "an invalid namespace" do + let(:unparseable_error) { "unparseableerror" } + it "should raise an exception" do wbem_locator.should_receive(:ConnectServer).and_raise(WIN32OLERuntimeError) - wmi_service = WmiLite::Wmi.new('notavalidnamespace') + wmi_service = WmiLite::Wmi.new("notavalidnamespace") expect { wmi_service.send(query_method, wmi_query) }.to raise_error(WmiLite::WmiException) end - it 'should raise an exception that starts with the original exception message' do + it "should raise an exception that starts with the original exception message" do wbem_locator.should_receive(:ConnectServer).and_raise(WIN32OLERuntimeError.new(unparseable_error)) wmi_service = WmiLite::Wmi.new error_message = nil @@ -205,12 +205,12 @@ describe WmiLite::Wmi do shared_examples_for "the query method" do - let(:wmi_properties1) { { 'cores' => 4, 'name' => 'mycomputer1', 'diskspace' => 400, 'os' => 'windows' } } - let(:wmi_properties2) { { 'cores' => 2, 'name' => 'mycomputer2', 'bios' => 'ami', 'os' => 'windows' } } + let(:wmi_properties1) { { "cores" => 4, "name" => "mycomputer1", "diskspace" => 400, "os" => "windows" } } + let(:wmi_properties2) { { "cores" => 2, "name" => "mycomputer2", "bios" => "ami", "os" => "windows" } } let(:native_query_result) { [].to_enum } it "should not fail with empty query results" do - results = wmi.query('vm') + results = wmi.query("vm") expect( results ).to eq([]) end @@ -219,9 +219,9 @@ describe WmiLite::Wmi do let(:native_query_result) { native_query_result1 } it "should get one instance" do - results = wmi.query('vm') + results = wmi.query("vm") index = 0 - expected_result = results.map do | result | + expected_result = results.map do |result| WmiLite::Wmi::Instance.new(result.wmi_ole_object) end validate_query_result(results, expected_result) @@ -233,9 +233,9 @@ describe WmiLite::Wmi do let(:native_query_result) { native_query_result2 } it "should get one instance" do - results = wmi.query('vm') + results = wmi.query("vm") index = 0 - expected_result = results.map do | result | + expected_result = results.map do |result| WmiLite::Wmi::Instance.new(result.wmi_ole_object) end validate_query_result(results, expected_result) @@ -248,7 +248,7 @@ describe WmiLite::Wmi do it "should not connect to WMI in the constructor" do WmiLite::Wmi.any_instance.should_not_receive(:connect_to_namespace) wmi_service_nil_namespace = WmiLite::Wmi.new - wmi_service_explicit_namespace = WmiLite::Wmi.new('root/cimv2') + wmi_service_explicit_namespace = WmiLite::Wmi.new("root/cimv2") end end @@ -258,32 +258,32 @@ describe WmiLite::Wmi do wmi_service = WmiLite::Wmi.new # Make a lot of queries to be sure the connection is only created once - wmi_service.query('select * from Win32_Process') - wmi_service.query('select * from Win32_Process') - wmi_service.instances_of('Win32_Processor') - wmi_service.instances_of('Win32_Processor') - wmi_service.first_of('Win32_Group') - wmi_service.first_of('Win32_Group') + wmi_service.query("select * from Win32_Process") + wmi_service.query("select * from Win32_Process") + wmi_service.instances_of("Win32_Processor") + wmi_service.instances_of("Win32_Processor") + wmi_service.first_of("Win32_Group") + wmi_service.first_of("Win32_Group") end end - context 'when making invalid queries' do + context "when making invalid queries" do let(:namespace) { nil } - let(:wmi_query) { 'invalidclass' } + let(:wmi_query) { "invalidclass" } let(:query_method) { :first_of } - it_behaves_like 'an invalid query' - it_behaves_like 'an invalid namespace' + it_behaves_like "an invalid query" + it_behaves_like "an invalid namespace" let(:query_method) { :instances_of } - it_behaves_like 'an invalid query' - it_behaves_like 'an invalid namespace' + it_behaves_like "an invalid query" + it_behaves_like "an invalid namespace" let(:query_method) { :query } - let(:wmi_query) { 'nosql_4_life' } - it_behaves_like 'an invalid query' - it_behaves_like 'an invalid namespace' + let(:wmi_query) { "nosql_4_life" } + it_behaves_like "an invalid query" + it_behaves_like "an invalid namespace" end it_should_behave_like "the first_of method" diff --git a/wmi-lite.gemspec b/wmi-lite.gemspec index 771a57d..716683c 100644 --- a/wmi-lite.gemspec +++ b/wmi-lite.gemspec @@ -1,23 +1,23 @@ # coding: utf-8 -lib = File.expand_path('../lib', __FILE__) +lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'wmi-lite/version' +require "wmi-lite/version" Gem::Specification.new do |spec| - spec.name = 'wmi-lite' + spec.name = "wmi-lite" spec.version = WmiLite::VERSION - spec.authors = ['Adam Edwards'] - spec.email = ['dev@chef.io'] - spec.description = 'A lightweight utility over win32ole for accessing basic ' \ - 'WMI (Windows Management Instrumentation) functionality ' \ - 'in the Microsoft Windows operating system. It has no ' \ - 'runtime dependencies other than Ruby, so it can be used ' \ - 'without concerns around dependency issues.' - spec.summary = 'A lightweight utility library for accessing basic WMI ' \ - '(Windows Management Instrumentation) functionality on Windows' - spec.homepage = 'https://github.com/chef/wmi-lite' - spec.license = 'Apache-2.0' + spec.authors = ["Adam Edwards"] + spec.email = ["dev@chef.io"] + spec.description = "A lightweight utility over win32ole for accessing basic " \ + "WMI (Windows Management Instrumentation) functionality " \ + "in the Microsoft Windows operating system. It has no " \ + "runtime dependencies other than Ruby, so it can be used " \ + "without concerns around dependency issues." + spec.summary = "A lightweight utility library for accessing basic WMI " \ + "(Windows Management Instrumentation) functionality on Windows" + spec.homepage = "https://github.com/chef/wmi-lite" + spec.license = "Apache-2.0" spec.files = %w{LICENSE} + Dir.glob("lib/**/*") - spec.require_paths = ['lib'] + spec.require_paths = ["lib"] end -- cgit v1.2.1 From 197b58ee79c4435edeca8a5fbf1b024b5c0810b8 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 20 Dec 2019 22:01:55 -0800 Subject: Add testing on Windows Signed-off-by: Tim Smith --- .expeditor/verify.pipeline.yml | 17 ++++++++++++++++- Gemfile | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.expeditor/verify.pipeline.yml b/.expeditor/verify.pipeline.yml index 8ab2bfa..81fbec5 100644 --- a/.expeditor/verify.pipeline.yml +++ b/.expeditor/verify.pipeline.yml @@ -1,4 +1,11 @@ --- +expeditor: + defaults: + buildkite: + retry: + automatic: + limit: 1 + timeout_in_minutes: 30 steps: @@ -29,4 +36,12 @@ steps: expeditor: executor: docker: - image: ruby:2.7-rc-buster \ No newline at end of file + image: ruby:2.7-rc-buster +- label: run-specs-windows + command: + - bundle install --jobs=7 --retry=3 --without docs debug + - bundle exec rake spec + expeditor: + executor: + docker: + host_os: windows diff --git a/Gemfile b/Gemfile index c970eae..d144f2e 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ group :test do gem "rake" end -group :development do +group :debug do gem "pry" gem "pry-byebug" gem "pry-stack_explorer" -- cgit v1.2.1