mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory. [Misc #13792] [ruby-core:82287] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
75bfc6440d
commit
1d15d5f080
4370 changed files with 0 additions and 0 deletions
33
spec/ruby/library/win32ole/win32ole_event/new_spec.rb
Normal file
33
spec/ruby/library/win32ole/win32ole_event/new_spec.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
require File.expand_path('../../fixtures/classes', __FILE__)
|
||||
|
||||
platform_is :windows do
|
||||
require 'win32ole'
|
||||
|
||||
describe "WIN32OLE_EVENT.new" do
|
||||
before :each do
|
||||
@ie = WIN32OLESpecs.new_ole('InternetExplorer.Application')
|
||||
end
|
||||
|
||||
after :each do
|
||||
@ie.Quit if @ie
|
||||
end
|
||||
|
||||
it "raises TypeError given invalid argument" do
|
||||
lambda { WIN32OLE_EVENT.new "A" }.should raise_error TypeError
|
||||
end
|
||||
|
||||
it "raises RuntimeError if event does not exist" do
|
||||
lambda { WIN32OLE_EVENT.new(@ie, 'A') }.should raise_error RuntimeError
|
||||
end
|
||||
|
||||
it "raises RuntimeError if OLE object has no events" do
|
||||
dict = WIN32OLESpecs.new_ole('Scripting.Dictionary')
|
||||
lambda { WIN32OLE_EVENT.new(dict) }.should raise_error RuntimeError
|
||||
end
|
||||
|
||||
it "creates WIN32OLE_EVENT object" do
|
||||
ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
|
||||
ev.should be_kind_of WIN32OLE_EVENT
|
||||
end
|
||||
end
|
||||
end
|
62
spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb
Normal file
62
spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb
Normal file
|
@ -0,0 +1,62 @@
|
|||
require File.expand_path('../../fixtures/classes', __FILE__)
|
||||
|
||||
platform_is :windows do
|
||||
require 'win32ole'
|
||||
|
||||
def default_handler(event, *args)
|
||||
@event += event
|
||||
end
|
||||
|
||||
def alternate_handler(event, *args)
|
||||
@event2 = "alternate"
|
||||
end
|
||||
|
||||
def handler3(event, *args)
|
||||
@event3 += event
|
||||
end
|
||||
|
||||
|
||||
describe "WIN32OLE_EVENT#on_event with no argument" do
|
||||
before :each do
|
||||
@ie = WIN32OLESpecs.new_ole('InternetExplorer.Application')
|
||||
@ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
|
||||
@event = ''
|
||||
@event2 = ''
|
||||
@event3 = ''
|
||||
@ie.StatusBar = true
|
||||
end
|
||||
|
||||
after :each do
|
||||
@ie.Quit
|
||||
end
|
||||
|
||||
it "sets event handler properly, and the handler is invoked by event loop" do
|
||||
@ev.on_event { |*args| default_handler(*args) }
|
||||
@ie.StatusText='hello'
|
||||
WIN32OLE_EVENT.message_loop
|
||||
@event.should =~ /StatusTextChange/
|
||||
end
|
||||
|
||||
it "accepts a String argument, sets event handler properly, and the handler is invoked by event loop" do
|
||||
@ev.on_event("StatusTextChange") { |*args| @event = 'foo' }
|
||||
@ie.StatusText='hello'
|
||||
WIN32OLE_EVENT.message_loop
|
||||
@event.should =~ /foo/
|
||||
end
|
||||
|
||||
it "registers multiple event handlers for the same event" do
|
||||
@ev.on_event("StatusTextChange") { |*args| default_handler(*args) }
|
||||
@ev.on_event("StatusTextChange") { |*args| alternate_handler(*args) }
|
||||
@ie.StatusText= 'hello'
|
||||
WIN32OLE_EVENT.message_loop
|
||||
@event2.should == 'alternate'
|
||||
end
|
||||
|
||||
it "accepts a Symbol argument, sets event handler properly, and the handler is invoked by event loop" do
|
||||
@ev.on_event(:StatusTextChange) { |*args| @event = 'foo' }
|
||||
@ie.StatusText='hello'
|
||||
WIN32OLE_EVENT.message_loop
|
||||
@event.should =~ /foo/
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue