diff options
Diffstat (limited to 'spec/ruby/library/win32ole')
82 files changed, 1718 insertions, 0 deletions
diff --git a/spec/ruby/library/win32ole/fixtures/classes.rb b/spec/ruby/library/win32ole/fixtures/classes.rb new file mode 100644 index 0000000000..5a16fcca45 --- /dev/null +++ b/spec/ruby/library/win32ole/fixtures/classes.rb @@ -0,0 +1,33 @@ +require 'win32ole' + +# win32ole deprecated constants like WIN32OLE_TYPELIB in Ruby 3.4 +# but only added the replacements like WIN32OLE::TypeLib in Ruby 3.4. +# So we use the new-style constants in specs to avoid deprecation warnings +# and we define the new-style constants as the old ones if they don't exist yet. +WIN32OLE::TypeLib ||= WIN32OLE_TYPELIB +WIN32OLE::RuntimeError ||= WIN32OLERuntimeError +WIN32OLE::Method ||= WIN32OLE_METHOD +WIN32OLE::Type ||= WIN32OLE_TYPE +WIN32OLE::Event ||= WIN32OLE_EVENT +WIN32OLE::Param ||= WIN32OLE_PARAM + +module WIN32OLESpecs + MSXML_AVAILABLE = WIN32OLE::TypeLib.typelibs.any? { |t| t.name.start_with?('Microsoft XML') } + SYSTEM_MONITOR_CONTROL_AVAILABLE = WIN32OLE::TypeLib.typelibs.any? { |t| t.name.start_with?('System Monitor Control') } + + def self.new_ole(name) + tries = 0 + begin + WIN32OLE.new(name) + rescue WIN32OLE::RuntimeError => e + if tries < 3 + tries += 1 + $stderr.puts "WIN32OLESpecs#new_ole retry (#{tries}): #{e.class}: #{e.message}" + sleep(2 ** tries) + retry + else + raise + end + end + end +end diff --git a/spec/ruby/library/win32ole/fixtures/event.xml b/spec/ruby/library/win32ole/fixtures/event.xml new file mode 100644 index 0000000000..23f3d2b126 --- /dev/null +++ b/spec/ruby/library/win32ole/fixtures/event.xml @@ -0,0 +1,4 @@ +<program> + <name>Ruby</name> + <version>trunk</version> +</program> diff --git a/spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb b/spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb new file mode 100644 index 0000000000..52cb978bea --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb @@ -0,0 +1,15 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + + describe "WIN32OLE#_getproperty" do + before :each do + @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary') + end + + it "gets value" do + @dict.add('key', 'value') + @dict._getproperty(0, ['key'], [WIN32OLE::VARIANT::VT_BSTR]).should == 'value' + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb b/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb new file mode 100644 index 0000000000..747121aeba --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + + describe "WIN32OLE#_invoke" do + before :each do + @shell = WIN32OLESpecs.new_ole 'Shell.application' + end + + it "raises ArgumentError if insufficient number of arguments are given" do + -> { @shell._invoke() }.should.raise ArgumentError + -> { @shell._invoke(0) }.should.raise ArgumentError + -> { @shell._invoke(0, []) }.should.raise ArgumentError + end + + it "dispatches the method bound to a specific ID" do + @shell._invoke(0x60020002, [37], [WIN32OLE::VARIANT::VT_VARIANT]).title.should =~ /System32/i + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/codepage_spec.rb b/spec/ruby/library/win32ole/win32ole/codepage_spec.rb new file mode 100644 index 0000000000..07e93646ac --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/codepage_spec.rb @@ -0,0 +1,14 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + + describe "WIN32OLE.codepage=" do + it "sets codepage" do + cp = WIN32OLE.codepage + WIN32OLE.codepage = WIN32OLE::CP_UTF8 + WIN32OLE.codepage.should == WIN32OLE::CP_UTF8 + WIN32OLE.codepage = cp + end + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/connect_spec.rb b/spec/ruby/library/win32ole/win32ole/connect_spec.rb new file mode 100644 index 0000000000..3a1caf85d3 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/connect_spec.rb @@ -0,0 +1,16 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + + describe "WIN32OLE.connect" do + it "creates WIN32OLE object given valid argument" do + obj = WIN32OLE.connect("winmgmts:") + obj.should.is_a? WIN32OLE + end + + it "raises TypeError when given invalid argument" do + -> { WIN32OLE.connect 1 }.should.raise TypeError + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole/const_load_spec.rb b/spec/ruby/library/win32ole/win32ole/const_load_spec.rb new file mode 100644 index 0000000000..b0ba023536 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/const_load_spec.rb @@ -0,0 +1,33 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + + describe "WIN32OLE.const_load when passed Shell.Application OLE object" do + before :each do + @win32ole = WIN32OLESpecs.new_ole 'Shell.Application' + end + + it "loads constant SsfWINDOWS into WIN32OLE namespace" do + WIN32OLE.const_defined?(:SsfWINDOWS).should == false + WIN32OLE.const_load @win32ole + WIN32OLE.const_defined?(:SsfWINDOWS).should == true + end + end + + describe "WIN32OLE.const_load when namespace is specified" do + before :each do + module WIN32OLE_RUBYSPEC; end + @win32ole = WIN32OLESpecs.new_ole 'Shell.Application' + end + + it "loads constants into given namespace" do + module WIN32OLE_RUBYSPEC; end + + WIN32OLE_RUBYSPEC.const_defined?(:SsfWINDOWS).should == false + WIN32OLE.const_load @win32ole, WIN32OLE_RUBYSPEC + WIN32OLE_RUBYSPEC.const_defined?(:SsfWINDOWS).should == true + + end + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/constants_spec.rb b/spec/ruby/library/win32ole/win32ole/constants_spec.rb new file mode 100644 index 0000000000..8533741440 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/constants_spec.rb @@ -0,0 +1,43 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + + describe "WIN32OLE class" do + it "defines constant CP_ACP" do + WIN32OLE::CP_ACP.should == 0 + end + + it "defines constant CP_OEMCP" do + WIN32OLE::CP_OEMCP.should == 1 + end + + it "defines constant CP_MACCP" do + WIN32OLE::CP_MACCP.should == 2 + end + + it "defines constant CP_THREAD_ACP" do + WIN32OLE::CP_THREAD_ACP.should == 3 + end + + it "defines constant CP_SYMBOL" do + WIN32OLE::CP_SYMBOL.should == 42 + end + + it "defines constant CP_UTF7" do + WIN32OLE::CP_UTF7.should == 65000 + end + + it "defines constant CP_UTF8" do + WIN32OLE::CP_UTF8.should == 65001 + end + + it "defines constant LOCALE_SYSTEM_DEFAULT" do + WIN32OLE::LOCALE_SYSTEM_DEFAULT.should == 0x0800 + end + + it "defines constant LOCALE_USER_DEFAULT" do + WIN32OLE::LOCALE_USER_DEFAULT.should == 0x0400 + end + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/create_guid_spec.rb b/spec/ruby/library/win32ole/win32ole/create_guid_spec.rb new file mode 100644 index 0000000000..8aa853df9e --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/create_guid_spec.rb @@ -0,0 +1,10 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + + describe "WIN32OLE.create_guid" do + it "generates guid with valid format" do + WIN32OLE.create_guid.should =~ /^\{[A-Z0-9]{8}\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{12}/ + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/invoke_spec.rb b/spec/ruby/library/win32ole/win32ole/invoke_spec.rb new file mode 100644 index 0000000000..d6ff7fade3 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/invoke_spec.rb @@ -0,0 +1,15 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + + describe "WIN32OLE#invoke" do + before :each do + @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary') + end + + it "get value by invoking 'Item' OLE method" do + @dict.add('key', 'value') + @dict.invoke('Item', 'key').should == 'value' + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/locale_spec.rb b/spec/ruby/library/win32ole/win32ole/locale_spec.rb new file mode 100644 index 0000000000..390c41d1a2 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/locale_spec.rb @@ -0,0 +1,30 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + + describe "WIN32OLE.locale" do + it "gets locale" do + WIN32OLE.locale.should == WIN32OLE::LOCALE_SYSTEM_DEFAULT + end + end + + describe "WIN32OLE.locale=" do + it "sets locale to Japanese, if available" do + begin + begin + WIN32OLE.locale = 1041 + rescue WIN32OLE::RuntimeError + STDERR.puts("\n#{__FILE__}:#{__LINE__}:#{self.class.name}.test_s_locale_set is skipped(Japanese locale is not installed)") + return + end + + WIN32OLE.locale.should == 1041 + WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT + -> { WIN32OLE.locale = 111 }.should.raise WIN32OLE::RuntimeError + WIN32OLE.locale.should == WIN32OLE::LOCALE_SYSTEM_DEFAULT + ensure + WIN32OLE.locale.should == WIN32OLE::LOCALE_SYSTEM_DEFAULT + end + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/new_spec.rb b/spec/ruby/library/win32ole/win32ole/new_spec.rb new file mode 100644 index 0000000000..4f54c724d9 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/new_spec.rb @@ -0,0 +1,26 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + + describe "WIN32OLESpecs.new_ole" do + it "creates a WIN32OLE object from OLE server name" do + shell = WIN32OLESpecs.new_ole 'Shell.Application' + shell.should.is_a? WIN32OLE + end + + it "creates a WIN32OLE object from valid CLSID" do + shell = WIN32OLESpecs.new_ole("{13709620-C279-11CE-A49E-444553540000}") + shell.should.is_a? WIN32OLE + end + + it "raises TypeError if argument cannot be converted to String" do + -> { WIN32OLESpecs.new_ole(42) }.should.raise( TypeError ) + end + + it "raises WIN32OLE::RuntimeError if invalid string is given" do + -> { WIN32OLE.new('foo') }.should.raise( WIN32OLE::RuntimeError ) + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb new file mode 100644 index 0000000000..33e3e23b1b --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + + describe "WIN32OLE#ole_func_methods" do + before :each do + @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary') + end + + it "raises ArgumentError if argument is given" do + -> { @dict.ole_func_methods(1) }.should.raise ArgumentError + end + + it "returns an array of WIN32OLE::Methods" do + @dict.ole_func_methods.all? { |m| m.kind_of? WIN32OLE::Method }.should == true + end + + it "contains a 'AddRef' method for Scripting Dictionary" do + @dict.ole_func_methods.map { |m| m.name }.include?('AddRef').should == true + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb new file mode 100644 index 0000000000..168a225d58 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb @@ -0,0 +1,17 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + + describe "WIN32OLE#ole_get_methods" do + + before :each do + @win32ole = WIN32OLESpecs.new_ole('Shell.Application') + end + + it "returns an array of WIN32OLE::Method objects" do + @win32ole.ole_get_methods.all? {|m| m.kind_of? WIN32OLE::Method}.should == true + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb new file mode 100644 index 0000000000..9cb3f9e6cf --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb @@ -0,0 +1,11 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + require_relative 'shared/ole_method' + + describe "WIN32OLE#ole_method_help" do + it_behaves_like :win32ole_ole_method, :ole_method_help + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/ole_method_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_method_spec.rb new file mode 100644 index 0000000000..e48ff8d905 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/ole_method_spec.rb @@ -0,0 +1,11 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + require_relative 'shared/ole_method' + + describe "WIN32OLE#ole_method" do + it_behaves_like :win32ole_ole_method, :ole_method + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb new file mode 100644 index 0000000000..5152deeaf4 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + + describe "WIN32OLE#ole_methods" do + before :each do + @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary') + end + + it "raises ArgumentError if argument is given" do + -> { @dict.ole_methods(1) }.should.raise ArgumentError + end + + it "returns an array of WIN32OLE::Methods" do + @dict.ole_methods.all? { |m| m.kind_of? WIN32OLE::Method }.should == true + end + + it "contains a 'AddRef' method for Scripting Dictionary" do + @dict.ole_methods.map { |m| m.name }.include?('AddRef').should == true + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb new file mode 100644 index 0000000000..1478804b55 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" + +platform_is :windows do + require_relative '../fixtures/classes' + + describe "WIN32OLE#ole_obj_help" do + before :each do + @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary') + end + + it "raises ArgumentError if argument is given" do + -> { @dict.ole_obj_help(1) }.should.raise ArgumentError + end + + it "returns an instance of WIN32OLE::Type" do + @dict.ole_obj_help.kind_of?(WIN32OLE::Type).should == true + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb new file mode 100644 index 0000000000..b03a5d4b06 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + + describe "WIN32OLE#ole_put_methods" do + before :each do + @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary') + end + + it "raises ArgumentError if argument is given" do + -> { @dict.ole_put_methods(1) }.should.raise ArgumentError + end + + it "returns an array of WIN32OLE::Methods" do + @dict.ole_put_methods.all? { |m| m.kind_of? WIN32OLE::Method }.should == true + end + + it "contains a 'Key' method for Scripting Dictionary" do + @dict.ole_put_methods.map { |m| m.name }.include?('Key').should == true + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/setproperty_spec.rb b/spec/ruby/library/win32ole/win32ole/setproperty_spec.rb new file mode 100644 index 0000000000..bacdee63da --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/setproperty_spec.rb @@ -0,0 +1,11 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + require_relative 'shared/setproperty' + + describe "WIN32OLE#setproperty" do + it_behaves_like :win32ole_setproperty, :setproperty + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb b/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb new file mode 100644 index 0000000000..9e4b7e7c20 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb @@ -0,0 +1,19 @@ +platform_is :windows do + require_relative '../../fixtures/classes' + + describe :win32ole_ole_method, shared: true do + before :each do + @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary') + end + + it "raises ArgumentError if no argument is given" do + -> { @dict.send(@method) }.should.raise ArgumentError + end + + it "returns the WIN32OLE::Method 'Add' if given 'Add'" do + result = @dict.send(@method, "Add") + result.kind_of?(WIN32OLE::Method).should == true + result.name.should == 'Add' + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/shared/setproperty.rb b/spec/ruby/library/win32ole/win32ole/shared/setproperty.rb new file mode 100644 index 0000000000..de3ad7b286 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/shared/setproperty.rb @@ -0,0 +1,23 @@ +platform_is :windows do + require_relative '../../fixtures/classes' + + describe :win32ole_setproperty, shared: true do + before :each do + @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary') + end + + it "raises ArgumentError if no argument is given" do + -> { @dict.send(@method) }.should.raise ArgumentError + end + + it "sets key to newkey and returns nil" do + oldkey = 'oldkey' + newkey = 'newkey' + @dict.add(oldkey, 'value') + result = @dict.send(@method, 'Key', oldkey, newkey) + result.should == nil + @dict[oldkey].should == nil + @dict[newkey].should == 'value' + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole_event/new_spec.rb b/spec/ruby/library/win32ole/win32ole_event/new_spec.rb new file mode 100644 index 0000000000..d09c38b78d --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_event/new_spec.rb @@ -0,0 +1,34 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + + guard -> { WIN32OLESpecs::MSXML_AVAILABLE } do + describe "WIN32OLE::Event.new" do + before :all do + @xml_dom = WIN32OLESpecs.new_ole('MSXML.DOMDocument') + end + + after :all do + @xml_dom = nil + end + + it "raises TypeError given invalid argument" do + -> { WIN32OLE::Event.new "A" }.should.raise TypeError + end + + it "raises RuntimeError if event does not exist" do + -> { WIN32OLE::Event.new(@xml_dom, 'A') }.should.raise RuntimeError + end + + it "raises RuntimeError if OLE object has no events" do + dict = WIN32OLESpecs.new_ole('Scripting.Dictionary') + -> { WIN32OLE::Event.new(dict) }.should.raise RuntimeError + end + + it "creates WIN32OLE::Event object" do + ev = WIN32OLE::Event.new(@xml_dom) + ev.should.is_a? WIN32OLE::Event + end + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb b/spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb new file mode 100644 index 0000000000..acc7d2d6b6 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb @@ -0,0 +1,71 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + guard -> { WIN32OLESpecs::MSXML_AVAILABLE } do + + def handler_global(event, *args) + @event_global += event + end + + def handler_specific(*args) + @event_specific = "specific" + end + + def handler_spec_alt(*args) + @event_spec_alt = "spec_alt" + end + + describe "WIN32OLE::Event#on_event" do + before :all do + @fn_xml = File.absolute_path "../fixtures/event.xml", __dir__ + end + + before :each do + @xml_dom = WIN32OLESpecs.new_ole 'MSXML.DOMDocument' + @xml_dom.async = true + @ev = WIN32OLE::Event.new @xml_dom + @event_global = '' + @event_specific = '' + @event_spec_alt = '' + end + + after :each do + @xml_dom = nil + @ev = nil + end + + it "sets global event handler properly, and the handler is invoked by event loop" do + @ev.on_event { |*args| handler_global(*args) } + @xml_dom.loadXML "<program><name>Ruby</name><version>trunk</version></program>" + WIN32OLE::Event.message_loop + @event_global.should =~ /onreadystatechange/ + end + + it "accepts a String argument and the handler is invoked by event loop" do + @ev.on_event("onreadystatechange") { |*args| @event = 'foo' } + @xml_dom.loadXML "<program><name>Ruby</name><version>trunk</version></program>" + WIN32OLE::Event.message_loop + @event.should =~ /foo/ + end + + it "accepts a Symbol argument and the handler is invoked by event loop" do + @ev.on_event(:onreadystatechange) { |*args| @event = 'bar' } + @xml_dom.loadXML "<program><name>Ruby</name><version>trunk</version></program>" + WIN32OLE::Event.message_loop + @event.should =~ /bar/ + end + + it "accepts a specific event handler and overrides a global event handler" do + @ev.on_event { |*args| handler_global(*args) } + @ev.on_event("onreadystatechange") { |*args| handler_specific(*args) } + @ev.on_event("onreadystatechange") { |*args| handler_spec_alt(*args) } + @xml_dom.load @fn_xml + WIN32OLE::Event.message_loop + @event_global.should == 'ondataavailable' + @event_global.should_not =~ /onreadystatechange/ + @event_specific.should == '' + @event_spec_alt.should == "spec_alt" + end + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb b/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb new file mode 100644 index 0000000000..43084eb943 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb @@ -0,0 +1,21 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#dispid" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + @m = WIN32OLE::Method.new(ole_type, "namespace") + end + + it "raises ArgumentError if argument is given" do + -> { @m.dispid(0) }.should.raise ArgumentError + end + + it "returns expected dispatch ID for Shell's 'namespace' method" do + @m.dispid.should == 1610743810 # value found in MRI's test + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb b/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb new file mode 100644 index 0000000000..1d00fb9696 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb @@ -0,0 +1,29 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + guard -> { WIN32OLESpecs::SYSTEM_MONITOR_CONTROL_AVAILABLE } do + + describe "WIN32OLE::Method#event_interface" do + before :each do + ole_type = WIN32OLE::Type.new("System Monitor Control", "SystemMonitor") + @on_dbl_click_method = WIN32OLE::Method.new(ole_type, "OnDblClick") + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + @namespace_method = WIN32OLE::Method.new(ole_type, "namespace") + end + + it "raises ArgumentError if argument is given" do + -> { @on_dbl_click_method.event_interface(1) }.should.raise ArgumentError + end + + it "returns expected string for System Monitor Control's 'OnDblClick' method" do + @on_dbl_click_method.event_interface.should == "DISystemMonitorEvents" + end + + it "returns nil if method has no event interface" do + @namespace_method.event_interface.should == nil + end + + end + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/event_spec.rb b/spec/ruby/library/win32ole/win32ole_method/event_spec.rb new file mode 100644 index 0000000000..fd611519cb --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/event_spec.rb @@ -0,0 +1,23 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require_relative '../fixtures/classes' + guard -> { WIN32OLESpecs::SYSTEM_MONITOR_CONTROL_AVAILABLE } do + + describe "WIN32OLE::Method#event?" do + before :each do + ole_type = WIN32OLE::Type.new("System Monitor Control", "SystemMonitor") + @on_dbl_click_method = WIN32OLE::Method.new(ole_type, "OnDblClick") + end + + it "raises ArgumentError if argument is given" do + -> { @on_dbl_click_method.event?(1) }.should.raise ArgumentError + end + + it "returns true for System Monitor Control's 'OnDblClick' method" do + @on_dbl_click_method.event?.should == true + end + + end + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb b/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb new file mode 100644 index 0000000000..88164bcd1f --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb @@ -0,0 +1,27 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#helpcontext" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "FileSystemObject") + @get_file_version = WIN32OLE::Method.new(ole_type, "GetFileVersion") + ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE::Method.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + -> { @get_file_version.helpcontext(1) }.should.raise ArgumentError + end + + it "returns expected value for FileSystemObject's 'GetFileVersion' method" do + @get_file_version.helpcontext.should == 0 + end + + it "returns expected value for Scripting Runtime's 'name' method" do + @m_file_name.helpcontext.should == 2181996 # value indicated in MRI's test + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb b/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb new file mode 100644 index 0000000000..314f58c062 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb @@ -0,0 +1,21 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#helpfile" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE::Method.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + -> { @m_file_name.helpfile(1) }.should.raise ArgumentError + end + + it "returns expected value for Scripting Runtime's 'File' method" do + @m_file_name.helpfile.should =~ /VBENLR.*\.CHM$/i + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb b/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb new file mode 100644 index 0000000000..2a93acdb37 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb @@ -0,0 +1,21 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#helpstring" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE::Method.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + -> { @m_file_name.helpstring(1) }.should.raise ArgumentError + end + + it "returns expected value for Scripting Runtime's 'File' method" do + @m_file_name.helpstring.should == "Get name of file" # value indicated in MRI's test + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb b/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb new file mode 100644 index 0000000000..16e5412a36 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb @@ -0,0 +1,21 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#invkind" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE::Method.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + -> { @m_file_name.invkind(1) }.should.raise ArgumentError + end + + it "returns expected value for Scripting Runtime's 'name' method" do + @m_file_name.invkind.should == 2 + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb b/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb new file mode 100644 index 0000000000..312860a9c5 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb @@ -0,0 +1,21 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#invoke_kind" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE::Method.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + -> { @m_file_name.invoke_kind(1) }.should.raise ArgumentError + end + + it "returns expected value for Scripting Runtime's 'name' method" do + @m_file_name.invoke_kind.should =~ /^(UNKNOWN|PROPERTY|PROPERTYGET|PROPERTYPUT|PROPERTYPUTREF|FUNC)$/ + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/name_spec.rb b/spec/ruby/library/win32ole/win32ole_method/name_spec.rb new file mode 100644 index 0000000000..6e2e233a62 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/name_spec.rb @@ -0,0 +1,12 @@ +require_relative "../../../spec_helper" +require_relative 'shared/name' + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#name" do + it_behaves_like :win32ole_method_name, :name + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/new_spec.rb b/spec/ruby/library/win32ole/win32ole_method/new_spec.rb new file mode 100644 index 0000000000..d805d80128 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/new_spec.rb @@ -0,0 +1,34 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method.new" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + it "raises TypeError when given non-strings" do + -> { WIN32OLE::Method.new(1, 2) }.should.raise TypeError + end + + it "raises ArgumentError if only 1 argument is given" do + -> { WIN32OLE::Method.new("hello") }.should.raise ArgumentError + -> { WIN32OLE::Method.new(@ole_type) }.should.raise ArgumentError + end + + it "returns a valid WIN32OLE::Method object" do + WIN32OLE::Method.new(@ole_type, "Open").should.is_a? WIN32OLE::Method + WIN32OLE::Method.new(@ole_type, "open").should.is_a? WIN32OLE::Method + end + + it "raises WIN32OLE::RuntimeError if the method does not exist" do + -> { WIN32OLE::Method.new(@ole_type, "NonexistentMethod") }.should.raise WIN32OLE::RuntimeError + end + + it "raises TypeError if second argument is not a String" do + -> { WIN32OLE::Method.new(@ole_type, 5) }.should.raise TypeError + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb b/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb new file mode 100644 index 0000000000..7c7e49ff3a --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#offset_vtbl" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE::Method.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + -> { @m_file_name.offset_vtbl(1) }.should.raise ArgumentError + end + + it "returns expected value for Scripting Runtime's 'name' method" do + pointer_size = PlatformGuard::POINTER_SIZE + @m_file_name.offset_vtbl.should == pointer_size + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/params_spec.rb b/spec/ruby/library/win32ole/win32ole_method/params_spec.rb new file mode 100644 index 0000000000..40a543fa55 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/params_spec.rb @@ -0,0 +1,29 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#params" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE::Method.new(ole_type, "name") + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + @m_browse_for_folder = WIN32OLE::Method.new(ole_type, "BrowseForFolder") + end + + it "raises ArgumentError if argument is given" do + -> { @m_file_name.params(1) }.should.raise ArgumentError + end + + it "returns empty array for Scripting Runtime's 'name' method" do + @m_file_name.params.should.is_a? Array + @m_file_name.params.should.empty? + end + + it "returns 4-element array of WIN32OLE::Param for Shell's 'BrowseForFolder' method" do + @m_browse_for_folder.params.all? { |p| p.kind_of? WIN32OLE::Param }.should == true + @m_browse_for_folder.params.size == 4 + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb b/spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb new file mode 100644 index 0000000000..6d46c705c6 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#return_type_detail" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + @m_browse_for_folder = WIN32OLE::Method.new(ole_type, "BrowseForFolder") + end + + it "raises ArgumentError if argument is given" do + -> { @m_browse_for_folder.return_type_detail(1) }.should.raise ArgumentError + end + + it "returns expected value for Shell Control's 'BrowseForFolder' method" do + @m_browse_for_folder.return_type_detail.should.is_a? Array + @m_browse_for_folder.return_type_detail.should == ['PTR', 'USERDEFINED', 'Folder'] + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb b/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb new file mode 100644 index 0000000000..5afaf202f2 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb @@ -0,0 +1,21 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#return_type" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE::Method.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + -> { @m_file_name.return_type(1) }.should.raise ArgumentError + end + + it "returns expected value for Scripting Runtime's 'name' method" do + @m_file_name.return_type.should == 'BSTR' + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb b/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb new file mode 100644 index 0000000000..882b5eaf43 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb @@ -0,0 +1,21 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#return_vtype" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + @m_browse_for_folder = WIN32OLE::Method.new(ole_type, "BrowseForFolder") + end + + it "raises ArgumentError if argument is given" do + -> { @m_browse_for_folder.return_vtype(1) }.should.raise ArgumentError + end + + it "returns expected value for Shell Control's 'BrowseForFolder' method" do + @m_browse_for_folder.return_vtype.should == 26 + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/shared/name.rb b/spec/ruby/library/win32ole/win32ole_method/shared/name.rb new file mode 100644 index 0000000000..ef63999836 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/shared/name.rb @@ -0,0 +1,20 @@ +platform_is :windows do + require 'win32ole' + + describe :win32ole_method_name, shared: true do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE::Method.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + -> { @m_file_name.send(@method, 1) }.should.raise ArgumentError + end + + it "returns expected value for Scripting Runtime's 'name' method" do + @m_file_name.send(@method).should == 'Name' # note the capitalization + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb b/spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb new file mode 100644 index 0000000000..e03a97c6c0 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb @@ -0,0 +1,21 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#size_opt_params" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + @m_browse_for_folder = WIN32OLE::Method.new(ole_type, "BrowseForFolder") + end + + it "raises ArgumentError if argument is given" do + -> { @m_browse_for_folder.size_opt_params(1) }.should.raise ArgumentError + end + + it "returns expected value for Shell Control's 'BrowseForFolder' method" do + @m_browse_for_folder.size_opt_params.should == 1 + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb b/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb new file mode 100644 index 0000000000..f64f77af46 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb @@ -0,0 +1,21 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#size_params" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + @m_browse_for_folder = WIN32OLE::Method.new(ole_type, "BrowseForFolder") + end + + it "raises ArgumentError if argument is given" do + -> { @m_browse_for_folder.size_params(1) }.should.raise ArgumentError + end + + it "returns expected value for Shell Control's 'BrowseForFolder' method" do + @m_browse_for_folder.size_params.should == 4 + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb new file mode 100644 index 0000000000..cdcc4525b1 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb @@ -0,0 +1,12 @@ +require_relative "../../../spec_helper" +require_relative 'shared/name' + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#name" do + it_behaves_like :win32ole_method_name, :to_s + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb b/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb new file mode 100644 index 0000000000..a04ac6570b --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb @@ -0,0 +1,21 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Method#visible?" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + @m_browse_for_folder = WIN32OLE::Method.new(ole_type, "BrowseForFolder") + end + + it "raises ArgumentError if argument is given" do + -> { @m_browse_for_folder.visible?(1) }.should.raise ArgumentError + end + + it "returns true for Shell Control's 'BrowseForFolder' method" do + @m_browse_for_folder.visible?.should == true + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/default_spec.rb b/spec/ruby/library/win32ole/win32ole_param/default_spec.rb new file mode 100644 index 0000000000..dded6833d4 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/default_spec.rb @@ -0,0 +1,32 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Param#default" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + m_browse_for_folder = WIN32OLE::Method.new(ole_type, "BrowseForFolder") + @params = m_browse_for_folder.params + + ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE::Method.new(ole_type, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + it "raises ArgumentError if argument is given" do + -> { @params[0].default(1) }.should.raise ArgumentError + end + + it "returns nil for each of WIN32OLE::Param for Shell's 'BrowseForFolder' method" do + @params.each do |p| + p.default.should == nil + end + end + + it "returns true for 3rd parameter of FileSystemObject's 'CopyFile' method" do + @param_overwritefiles.default.should == true # not be_true + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/input_spec.rb b/spec/ruby/library/win32ole/win32ole_param/input_spec.rb new file mode 100644 index 0000000000..46dc305d2b --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/input_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Param#input?" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE::Method.new(ole_type, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + it "raises ArgumentError if argument is given" do + -> { @param_overwritefiles.input?(1) }.should.raise ArgumentError + end + + it "returns true for 3rd parameter of FileSystemObject's 'CopyFile' method" do + @param_overwritefiles.should.input? + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/name_spec.rb b/spec/ruby/library/win32ole/win32ole_param/name_spec.rb new file mode 100644 index 0000000000..2c3474ffb3 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/name_spec.rb @@ -0,0 +1,12 @@ +require_relative "../../../spec_helper" +require_relative 'shared/name' + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Param#name" do + it_behaves_like :win32ole_param_name, :name + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb b/spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb new file mode 100644 index 0000000000..bd25ec325a --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Param#ole_type_detail" do + before :each do + ole_type_detail = WIN32OLE::Type.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE::Method.new(ole_type_detail, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + it "raises ArgumentError if argument is given" do + -> { @param_overwritefiles.ole_type_detail(1) }.should.raise ArgumentError + end + + it "returns ['BOOL'] for 3rd parameter of FileSystemObject's 'CopyFile' method" do + @param_overwritefiles.ole_type_detail.should == ['BOOL'] + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb b/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb new file mode 100644 index 0000000000..3f0c279316 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Param#ole_type" do + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE::Method.new(ole_type, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + it "raises ArgumentError if argument is given" do + -> { @param_overwritefiles.ole_type(1) }.should.raise ArgumentError + end + + it "returns 'BOOL' for 3rd parameter of FileSystemObject's 'CopyFile' method" do + @param_overwritefiles.ole_type.should == 'BOOL' + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb b/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb new file mode 100644 index 0000000000..ca676e0950 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Param#optional?" do + before :each do + ole_type_detail = WIN32OLE::Type.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE::Method.new(ole_type_detail, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + it "raises ArgumentError if argument is given" do + -> { @param_overwritefiles.optional?(1) }.should.raise ArgumentError + end + + it "returns true for 3rd parameter of FileSystemObject's 'CopyFile' method" do + @param_overwritefiles.optional?.should == true + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb b/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb new file mode 100644 index 0000000000..f25b1e7e14 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Param#retval?" do + before :each do + ole_type_detail = WIN32OLE::Type.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE::Method.new(ole_type_detail, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + it "raises ArgumentError if argument is given" do + -> { @param_overwritefiles.retval?(1) }.should.raise ArgumentError + end + + it "returns false for 3rd parameter of FileSystemObject's 'CopyFile' method" do + @param_overwritefiles.retval?.should == false + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/shared/name.rb b/spec/ruby/library/win32ole/win32ole_param/shared/name.rb new file mode 100644 index 0000000000..1f6cbea7a0 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/shared/name.rb @@ -0,0 +1,21 @@ +platform_is :windows do + require 'win32ole' + + describe :win32ole_param_name, shared: true do + before :each do + ole_type_detail = WIN32OLE::Type.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE::Method.new(ole_type_detail, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + it "raises ArgumentError if argument is given" do + -> { @param_overwritefiles.send(@method, 1) }.should.raise ArgumentError + end + + it "returns expected value for Scripting Runtime's 'name' method" do + @param_overwritefiles.send(@method).should == 'OverWriteFiles' # note the capitalization + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb new file mode 100644 index 0000000000..c59f426692 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb @@ -0,0 +1,12 @@ +require_relative "../../../spec_helper" +require_relative 'shared/name' + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Param#to_s" do + it_behaves_like :win32ole_param_name, :to_s + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_type/guid_spec.rb b/spec/ruby/library/win32ole/win32ole_type/guid_spec.rb new file mode 100644 index 0000000000..e574a945ad --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/guid_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type#guid for Shell Controls" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns String with expected format" do + @ole_type.guid.should =~ /\A\{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}\}\z/ + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb b/spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb new file mode 100644 index 0000000000..7b605a038b --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type#helpcontext for Shell Controls" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns an Integer" do + @ole_type.helpcontext.should.is_a? Integer + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb b/spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb new file mode 100644 index 0000000000..43a979882a --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type#helpfile for Shell Controls" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns an empty string" do + @ole_type.helpfile.should.empty? + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/helpstring_spec.rb b/spec/ruby/library/win32ole/win32ole_type/helpstring_spec.rb new file mode 100644 index 0000000000..940475b25e --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/helpstring_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type#helpstring for Shell Controls" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns expected string" do + @ole_type.helpstring.should == "Shell Object Type Information" + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/major_version_spec.rb b/spec/ruby/library/win32ole/win32ole_type/major_version_spec.rb new file mode 100644 index 0000000000..66fdbc9ab0 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/major_version_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type#major_version for Shell Controls" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns an Integer" do + @ole_type.major_version.should.is_a? Integer + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/minor_version_spec.rb b/spec/ruby/library/win32ole/win32ole_type/minor_version_spec.rb new file mode 100644 index 0000000000..afb5086565 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/minor_version_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type#minor_version for Shell Controls" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns an Integer" do + @ole_type.minor_version.should.is_a? Integer + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/name_spec.rb b/spec/ruby/library/win32ole/win32ole_type/name_spec.rb new file mode 100644 index 0000000000..4cc3426872 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/name_spec.rb @@ -0,0 +1,12 @@ +require_relative "../../../spec_helper" +require_relative 'shared/name' + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type#name" do + it_behaves_like :win32ole_type_name, :name + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_type/new_spec.rb b/spec/ruby/library/win32ole/win32ole_type/new_spec.rb new file mode 100644 index 0000000000..9d92177a4b --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/new_spec.rb @@ -0,0 +1,41 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type.new" do + it "raises ArgumentError with no argument" do + -> { WIN32OLE::Type.new }.should.raise ArgumentError + end + + it "raises ArgumentError with invalid string" do + -> { WIN32OLE::Type.new("foo") }.should.raise ArgumentError + end + + it "raises TypeError if second argument is not a String" do + -> { WIN32OLE::Type.new(1,2) }.should.raise TypeError + -> { + WIN32OLE::Type.new('Microsoft Shell Controls And Automation',2) + }.should.raise TypeError + end + + it "raise WIN32OLE::RuntimeError if OLE object specified is not found" do + -> { + WIN32OLE::Type.new('Microsoft Shell Controls And Automation','foo') + }.should.raise WIN32OLE::RuntimeError + -> { + WIN32OLE::Type.new('Microsoft Shell Controls And Automation','Application') + }.should.raise WIN32OLE::RuntimeError + end + + it "creates WIN32OLE::Type object from name and valid type" do + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + ole_type.should.is_a? WIN32OLE::Type + end + + it "creates WIN32OLE::Type object from CLSID and valid type" do + ole_type2 = WIN32OLE::Type.new("{13709620-C279-11CE-A49E-444553540000}", "Shell") + ole_type2.should.is_a? WIN32OLE::Type + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/ole_classes_spec.rb b/spec/ruby/library/win32ole/win32ole_type/ole_classes_spec.rb new file mode 100644 index 0000000000..7db08dc900 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/ole_classes_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type.ole_classes for Shell Controls" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns array of WIN32OLE_TYPEs" do + WIN32OLE::Type.ole_classes("Microsoft Shell Controls And Automation").all? {|e| e.kind_of? WIN32OLE::Type }.should == true + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/ole_methods_spec.rb b/spec/ruby/library/win32ole/win32ole_type/ole_methods_spec.rb new file mode 100644 index 0000000000..bdf668e53b --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/ole_methods_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type#ole_methods for Shell Controls" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns an Integer" do + @ole_type.ole_methods.all? { |m| m.kind_of? WIN32OLE::Method }.should == true + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/ole_type_spec.rb b/spec/ruby/library/win32ole/win32ole_type/ole_type_spec.rb new file mode 100644 index 0000000000..49c1902f8c --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/ole_type_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type#ole_type for Shell Controls" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns string 'Class'" do + @ole_type.ole_type.should == "Class" + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/progid_spec.rb b/spec/ruby/library/win32ole/win32ole_type/progid_spec.rb new file mode 100644 index 0000000000..9a700426d9 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/progid_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type#progid for Shell Controls" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns expected string" do + @ole_type.progid.should == "Shell.Application.1" + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb b/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb new file mode 100644 index 0000000000..cbb9247da1 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb @@ -0,0 +1,15 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type.progids" do + it "raises ArgumentError if an argument is given" do + -> { WIN32OLE::Type.progids(1) }.should.raise ArgumentError + end + + it "returns an array containing 'Shell.Explorer'" do + WIN32OLE::Type.progids().include?('Shell.Explorer').should == true + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/shared/name.rb b/spec/ruby/library/win32ole/win32ole_type/shared/name.rb new file mode 100644 index 0000000000..707149a5bb --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/shared/name.rb @@ -0,0 +1,19 @@ +platform_is :windows do + require 'win32ole' + + describe :win32ole_type_name, shared: true do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + end + + it "raises ArgumentError if argument is given" do + -> { @ole_type.send(@method, 1) }.should.raise ArgumentError + end + + it "returns a String" do + @ole_type.send(@method).should == 'ShellSpecialFolderConstants' + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_type/src_type_spec.rb b/spec/ruby/library/win32ole/win32ole_type/src_type_spec.rb new file mode 100644 index 0000000000..9f0893b750 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/src_type_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type#src_type for Shell Controls" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns nil" do + @ole_type.src_type.should == nil + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb new file mode 100644 index 0000000000..03a0344fdb --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb @@ -0,0 +1,12 @@ +require_relative "../../../spec_helper" +require_relative 'shared/name' + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type#to_s" do + it_behaves_like :win32ole_type_name, :to_s + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb b/spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb new file mode 100644 index 0000000000..1051627025 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type#typekind for Shell Controls" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns an Integer" do + @ole_type.typekind.should.is_a? Integer + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb b/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb new file mode 100644 index 0000000000..36400d75f2 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb @@ -0,0 +1,23 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type.typelibs for Shell Controls" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "raises ArgumentError if any argument is give" do + -> { WIN32OLE::Type.typelibs(1) }.should.raise ArgumentError + end + + it "returns array of type libraries" do + WIN32OLE::Type.typelibs().include?("Microsoft Shell Controls And Automation").should == true + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/variables_spec.rb b/spec/ruby/library/win32ole/win32ole_type/variables_spec.rb new file mode 100644 index 0000000000..b1a407523c --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/variables_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type#variables for Shell Controls" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns an empty array" do + @ole_type.variables.should == [] + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/visible_spec.rb b/spec/ruby/library/win32ole/win32ole_type/visible_spec.rb new file mode 100644 index 0000000000..bca9159d53 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/visible_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Type#visible? for Shell Controls" do + before :each do + @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns true" do + @ole_type.visible?.should == true + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/name_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/name_spec.rb new file mode 100644 index 0000000000..dd9bfa594f --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/name_spec.rb @@ -0,0 +1,12 @@ +require_relative "../../../spec_helper" +require_relative 'shared/name' + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#name" do + it_behaves_like :win32ole_variable_new, :name + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/ole_type_detail_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/ole_type_detail_spec.rb new file mode 100644 index 0000000000..a9232d2b28 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/ole_type_detail_spec.rb @@ -0,0 +1,20 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#ole_type_detail" do + # not sure how WIN32OLE_VARIABLE objects are supposed to be generated + # WIN32OLE_VARIABLE.new even seg faults in some cases + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + @var = ole_type.variables[0] + end + + it "returns a nonempty Array" do + @var.ole_type_detail.should.is_a? Array + @var.ole_type_detail.should_not.empty? + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/ole_type_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/ole_type_spec.rb new file mode 100644 index 0000000000..f28cbfd37a --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/ole_type_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#ole_type" do + # not sure how WIN32OLE_VARIABLE objects are supposed to be generated + # WIN32OLE_VARIABLE.new even seg faults in some cases + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + @var = ole_type.variables[0] + end + + it "returns a String" do + @var.ole_type.should.is_a? String + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/shared/name.rb b/spec/ruby/library/win32ole/win32ole_variable/shared/name.rb new file mode 100644 index 0000000000..d079066616 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/shared/name.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe :win32ole_variable_new, shared: true do + # not sure how WIN32OLE_VARIABLE objects are supposed to be generated + # WIN32OLE_VARIABLE.new even seg faults in some cases + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + @var = ole_type.variables[0] + end + + it "returns a String" do + @var.send(@method).should.is_a? String + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb new file mode 100644 index 0000000000..d4cab8e924 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb @@ -0,0 +1,12 @@ +require_relative "../../../spec_helper" +require_relative 'shared/name' + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#to_s" do + it_behaves_like :win32ole_variable_new, :to_s + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/value_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/value_spec.rb new file mode 100644 index 0000000000..33066e40ef --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/value_spec.rb @@ -0,0 +1,20 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#value" do + # not sure how WIN32OLE_VARIABLE objects are supposed to be generated + # WIN32OLE_VARIABLE.new even seg faults in some cases + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + @var = ole_type.variables[0] + end + + it "returns an Integer" do + # according to doc, this could return nil + @var.value.should.is_a? Integer + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/variable_kind_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/variable_kind_spec.rb new file mode 100644 index 0000000000..2cf1d7f1f2 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/variable_kind_spec.rb @@ -0,0 +1,20 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#variable_kind" do + # not sure how WIN32OLE_VARIABLE objects are supposed to be generated + # WIN32OLE_VARIABLE.new even seg faults in some cases + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + @var = ole_type.variables[0] + end + + it "returns a String" do + @var.variable_kind.should.is_a? String + @var.variable_kind.should == 'CONSTANT' + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb new file mode 100644 index 0000000000..04ccb8d46f --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb @@ -0,0 +1,20 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#varkind" do + # TODO review + # not sure how WIN32OLE_VARIABLE objects are supposed to be generated + # WIN32OLE_VARIABLE.new even seg faults in some cases + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + @var = ole_type.variables[0] + end + + it "returns an Integer" do + @var.varkind.should.is_a? Integer + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb new file mode 100644 index 0000000000..939468122c --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb @@ -0,0 +1,19 @@ +require_relative "../../../spec_helper" +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#visible?" do + # not sure how WIN32OLE_VARIABLE objects are supposed to be generated + # WIN32OLE_VARIABLE.new even seg faults in some cases + before :each do + ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + @var = ole_type.variables[0] + end + + it "returns a String" do + @var.visible?.should == true + end + + end + +end |
