Refactor specs with factory helper methods

This commit is contained in:
Thibault Jouan
2015-04-21 12:35:45 +00:00
parent 2cad5da620
commit 47bc9c9da2
5 changed files with 44 additions and 25 deletions

23
spec/support/factories.rb Normal file
View File

@@ -0,0 +1,23 @@
module Factories
def build_geo x = 0, y = 0, width = 640, height = 480
Uh::Geo.new(x, y, width, height)
end
def mock_event type = :xany, **options
double 'event', type: type, **options
end
def mock_event_key_press key, modifier_mask
mock_event :key_press,
key: 'f',
modifier_mask: modifier_mask
end
def mock_window override_redirect: false
instance_spy Uh::Window, 'window',
to_s: 'wid',
name: 'wname',
wclass: 'wclass',
override_redirect?: override_redirect
end
end