win_gui 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -21
- data/HISTORY +7 -0
- data/LICENSE +20 -20
- data/README.rdoc +77 -114
- data/Rakefile +24 -58
- data/VERSION +1 -1
- data/features/support/env.rb +7 -4
- data/features/win_gui.feature +9 -9
- data/lib/version.rb +8 -0
- data/lib/win_gui/window.rb +78 -69
- data/lib/win_gui.rb +25 -3
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +90 -118
- data/spec/win_gui/window_spec.rb +120 -123
- data/tasks/common.rake +14 -0
- data/tasks/doc.rake +14 -0
- data/tasks/gem.rake +39 -0
- data/tasks/git.rake +34 -0
- data/tasks/spec.rake +19 -0
- data/tasks/version.rake +71 -0
- metadata +68 -188
- data/.document +0 -5
- data/book_code/early_success/bundle.rb +0 -34
- data/book_code/early_success/english.txt +0 -1
- data/book_code/early_success/jruby_basics.rb +0 -47
- data/book_code/early_success/windows_basics.rb +0 -97
- data/book_code/guessing/locknote.rb +0 -379
- data/book_code/guessing/monkeyshines.rb +0 -14
- data/book_code/guessing/note.rb +0 -120
- data/book_code/guessing/note_spec.rb +0 -175
- data/book_code/guessing/replay.rb +0 -21
- data/book_code/guessing/seed.rb +0 -9
- data/book_code/guessing/spec_helper.rb +0 -69
- data/book_code/guessing/windows_gui.rb +0 -247
- data/book_code/home_stretch/junquenote.rb +0 -151
- data/book_code/home_stretch/locknote.rb +0 -180
- data/book_code/home_stretch/note.rb +0 -144
- data/book_code/home_stretch/note_spec.rb +0 -191
- data/book_code/home_stretch/spec_helper.rb +0 -55
- data/book_code/home_stretch/swing_gui.rb +0 -50
- data/book_code/home_stretch/windows_gui.rb +0 -232
- data/book_code/junquenote/exports.sh +0 -10
- data/book_code/junquenote/jruby_mac.sh +0 -10
- data/book_code/junquenote/junquenote_app.rb +0 -262
- data/book_code/novite/Rakefile +0 -10
- data/book_code/novite/app/controllers/application.rb +0 -18
- data/book_code/novite/app/controllers/guests_controller.rb +0 -28
- data/book_code/novite/app/controllers/parties_controller.rb +0 -77
- data/book_code/novite/app/helpers/application_helper.rb +0 -11
- data/book_code/novite/app/helpers/guests_helper.rb +0 -10
- data/book_code/novite/app/helpers/parties_helper.rb +0 -10
- data/book_code/novite/app/models/guest.rb +0 -11
- data/book_code/novite/app/models/party.rb +0 -32
- data/book_code/novite/app/models/party_mailer.rb +0 -19
- data/book_code/novite/app/views/layouts/application.rhtml +0 -44
- data/book_code/novite/app/views/parties/new.html.erb +0 -42
- data/book_code/novite/app/views/parties/show.html.erb +0 -43
- data/book_code/novite/app/views/party_mailer/invite.erb +0 -17
- data/book_code/novite/config/boot.rb +0 -117
- data/book_code/novite/config/database.yml +0 -19
- data/book_code/novite/config/environment.rb +0 -67
- data/book_code/novite/config/environments/development.rb +0 -29
- data/book_code/novite/config/environments/production.rb +0 -27
- data/book_code/novite/config/environments/test.rb +0 -30
- data/book_code/novite/config/initializers/inflections.rb +0 -18
- data/book_code/novite/config/initializers/mime_types.rb +0 -13
- data/book_code/novite/config/routes.rb +0 -47
- data/book_code/novite/db/migrate/001_create_parties.rb +0 -26
- data/book_code/novite/db/migrate/002_create_guests.rb +0 -23
- data/book_code/novite/db/schema.rb +0 -41
- data/book_code/novite/log/empty.txt +0 -0
- data/book_code/novite/public/.htaccess +0 -40
- data/book_code/novite/public/404.html +0 -38
- data/book_code/novite/public/422.html +0 -38
- data/book_code/novite/public/500.html +0 -38
- data/book_code/novite/public/dispatch.cgi +0 -10
- data/book_code/novite/public/dispatch.fcgi +0 -24
- data/book_code/novite/public/dispatch.rb +0 -18
- data/book_code/novite/public/favicon.ico +0 -0
- data/book_code/novite/public/images/rails.png +0 -0
- data/book_code/novite/public/index.html +0 -285
- data/book_code/novite/public/javascripts/application.js +0 -10
- data/book_code/novite/public/javascripts/controls.js +0 -971
- data/book_code/novite/public/javascripts/dragdrop.js +0 -980
- data/book_code/novite/public/javascripts/effects.js +0 -1128
- data/book_code/novite/public/javascripts/prototype.js +0 -4233
- data/book_code/novite/public/robots.txt +0 -5
- data/book_code/novite/script/about +0 -3
- data/book_code/novite/script/console +0 -3
- data/book_code/novite/script/destroy +0 -3
- data/book_code/novite/script/generate +0 -3
- data/book_code/novite/script/performance/benchmarker +0 -3
- data/book_code/novite/script/performance/profiler +0 -3
- data/book_code/novite/script/performance/request +0 -3
- data/book_code/novite/script/plugin +0 -3
- data/book_code/novite/script/process/inspector +0 -3
- data/book_code/novite/script/process/reaper +0 -3
- data/book_code/novite/script/process/spawner +0 -3
- data/book_code/novite/script/runner +0 -3
- data/book_code/novite/script/server +0 -3
- data/book_code/novite/test/test_helper.rb +0 -46
- data/book_code/one_more_thing/applescript.rb +0 -68
- data/book_code/one_more_thing/note_spec.rb +0 -50
- data/book_code/one_more_thing/spec_helper.rb +0 -17
- data/book_code/one_more_thing/textedit-pure.rb +0 -28
- data/book_code/one_more_thing/textedit.applescript +0 -26
- data/book_code/one_more_thing/textedit.rb +0 -32
- data/book_code/one_more_thing/textnote.rb +0 -87
- data/book_code/simplify/junquenote.rb +0 -48
- data/book_code/simplify/locknote.rb +0 -46
- data/book_code/simplify/note.rb +0 -35
- data/book_code/simplify/note_spec.rb +0 -28
- data/book_code/simplify/swing_gui.rb +0 -45
- data/book_code/simplify/windows_gui.rb +0 -232
- data/book_code/simplify/windows_gui_spec.rb +0 -35
- data/book_code/story/invite.story +0 -19
- data/book_code/story/journal.txt +0 -29
- data/book_code/story/novite_stories.rb +0 -156
- data/book_code/story/party.rb +0 -149
- data/book_code/story/password.rb +0 -61
- data/book_code/story/password.story +0 -26
- data/book_code/story/rsvp.story +0 -29
- data/book_code/tables/TestTime.html +0 -93
- data/book_code/tables/TestTimeSample.html +0 -63
- data/book_code/tables/calculate_time.rb +0 -39
- data/book_code/tables/calculator.rb +0 -108
- data/book_code/tables/calculator_actions.rb +0 -27
- data/book_code/tables/calculator_spec.rb +0 -47
- data/book_code/tables/fit.rb +0 -32
- data/book_code/tables/matrix.rb +0 -109
- data/book_code/tables/pseudocode.rb +0 -17
- data/book_code/tubes/book_selenium.rb +0 -67
- data/book_code/tubes/book_watir.rb +0 -60
- data/book_code/tubes/dragdrop.html +0 -81
- data/book_code/tubes/html_capture.rb +0 -33
- data/book_code/tubes/joke_list.rb +0 -67
- data/book_code/tubes/list_spec.rb +0 -41
- data/book_code/tubes/search_spec.rb +0 -32
- data/book_code/tubes/selenium_example.rb +0 -66
- data/book_code/tubes/selenium_link.rb +0 -23
- data/book_code/tubes/web_server.rb +0 -14
- data/book_code/windows/wgui.rb +0 -29
- data/book_code/windows/wobj.rb +0 -25
- data/book_code/windows/wsh.rb +0 -25
- data/book_code/with_rspec/empty_spec.rb +0 -13
- data/book_code/with_rspec/junquenote.rb +0 -60
- data/book_code/with_rspec/locknote.rb +0 -129
- data/book_code/with_rspec/note_spec.rb +0 -32
- data/book_code/with_rspec/should_examples.rb +0 -18
- data/lib/note/java/jemmy.jar +0 -0
- data/lib/note/java/jnote.rb +0 -48
- data/lib/note/java/jruby_basics.rb +0 -37
- data/lib/note/java/junquenote_app.rb +0 -262
- data/lib/note/java/note_spec.rb +0 -20
- data/lib/note/win/locknote.rb +0 -19
- data/lib/note.rb +0 -15
- data/lib/win_gui/constants.rb +0 -82
- data/lib/win_gui/def_api.rb +0 -160
- data/lib/win_gui/string_extensions.rb +0 -36
- data/lib/win_gui/win_gui.rb +0 -437
- data/old/windows_basics.rb +0 -80
- data/old/wnote.rb +0 -80
- data/old/wnote_spec.rb +0 -20
- data/spec/note/win/locknote_spec.rb +0 -7
- data/spec/test_apps/locknote/LockNote.exe +0 -0
- data/spec/win_gui/def_api_spec.rb +0 -339
- data/spec/win_gui/string_extensions_spec.rb +0 -61
- data/spec/win_gui/win_gui_spec.rb +0 -537
- data/win_gui.gemspec +0 -215
data/spec/spec_helper.rb
CHANGED
@@ -1,118 +1,90 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require '
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
def launch_test_app
|
93
|
-
system TEST_APP_START
|
94
|
-
sleep TEST_SLEEP_DELAY until (handle = find_window(nil, TEST_WIN_TITLE))
|
95
|
-
@launched_test_app = Window.new handle
|
96
|
-
end
|
97
|
-
|
98
|
-
def close_test_app(app = @launched_test_app)
|
99
|
-
while app and app.respond_to? :handle and find_window(nil, TEST_WIN_TITLE)
|
100
|
-
post_message(app.handle, WM_SYSCOMMAND, SC_CLOSE, 0)
|
101
|
-
sleep TEST_SLEEP_DELAY
|
102
|
-
end
|
103
|
-
@launched_test_app = nil
|
104
|
-
end
|
105
|
-
|
106
|
-
# Creates test app object and yields it back to the block
|
107
|
-
def test_app
|
108
|
-
app = launch_test_app
|
109
|
-
|
110
|
-
def app.textarea #define singleton method retrieving app's text area
|
111
|
-
Window.new find_window_ex(self.handle, 0, TEST_TEXTAREA_CLASS, nil)
|
112
|
-
end
|
113
|
-
|
114
|
-
yield app
|
115
|
-
close_test_app
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
1
|
+
require 'spec'
|
2
|
+
require 'spec/autorun'
|
3
|
+
require 'win_gui'
|
4
|
+
|
5
|
+
# Customize RSpec with my own extensions
|
6
|
+
module SpecMacros
|
7
|
+
|
8
|
+
# wrapper for it method that extracts description from example source code, such as:
|
9
|
+
# spec { use{ function(arg1 = 4, arg2 = 'string') }}
|
10
|
+
def spec &block
|
11
|
+
it description_from(*block.source_location), &block
|
12
|
+
end
|
13
|
+
|
14
|
+
# reads description line from source file and drops external brackets (like its{}, use{}
|
15
|
+
def description_from(file, line)
|
16
|
+
File.open(file) do |f|
|
17
|
+
f.lines.to_a[line-1].gsub( /(spec.*?{)|(use.*?{)|}/, '' ).strip
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Spec::Runner.configure { |config| config.extend(SpecMacros) }
|
23
|
+
|
24
|
+
module WinGuiTest
|
25
|
+
include Win::Gui
|
26
|
+
|
27
|
+
# Test related Constants:
|
28
|
+
TIMEOUT = 0.001
|
29
|
+
KEY_DELAY = 0.001
|
30
|
+
SLEEP_DELAY = 0.01
|
31
|
+
APP_PATH = File.join(File.dirname(__FILE__), "../misc/locknote/LockNote.exe" )
|
32
|
+
APP_START = RUBY_PLATFORM =~ /cygwin/ ? "cmd /c start `cygpath -w #{APP_PATH}`" : "start #{APP_PATH}"
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# 'start "" "' + APP_PATH + '"'
|
36
|
+
WIN_TITLE = 'LockNote - Steganos LockNote'
|
37
|
+
WIN_CLASS = 'ATL:00434098'
|
38
|
+
WIN_RECT = [710, 400, 1210, 800]
|
39
|
+
MAX_RECT = [-4, -4, 1924, 1204] # on my 1920x1200 display
|
40
|
+
MIN_RECT = [-32000, -32000, -31840, -31976]
|
41
|
+
TEXTAREA_CLASS = 'ATL:00434310'
|
42
|
+
STATUSBAR_CLASS = 'msctls_statusbar32'
|
43
|
+
IMPOSSIBLE = 'Impossible'
|
44
|
+
ERROR_CONVERSION = /Can.t convert/
|
45
|
+
|
46
|
+
# Helper methods:
|
47
|
+
def use
|
48
|
+
lambda {yield}.should_not raise_error
|
49
|
+
end
|
50
|
+
|
51
|
+
def any_handle
|
52
|
+
WinGui.def_api 'FindWindow', 'PP', 'L' unless respond_to? :find_window
|
53
|
+
find_window(nil, nil)
|
54
|
+
end
|
55
|
+
|
56
|
+
def not_a_handle
|
57
|
+
123
|
58
|
+
end
|
59
|
+
|
60
|
+
def any_block
|
61
|
+
lambda {|*args| args}
|
62
|
+
end
|
63
|
+
|
64
|
+
def launch_test_app
|
65
|
+
system APP_START
|
66
|
+
sleep SLEEP_DELAY until (handle = find_window(nil, WIN_TITLE))
|
67
|
+
@launched_test_app = Window.new handle
|
68
|
+
end
|
69
|
+
|
70
|
+
def close_test_app(app = @launched_test_app)
|
71
|
+
while app && app.respond_to?(:handle) && find_window(nil, WIN_TITLE)
|
72
|
+
post_message(app.handle, WM_SYSCOMMAND, SC_CLOSE, nil)
|
73
|
+
sleep SLEEP_DELAY
|
74
|
+
end
|
75
|
+
@launched_test_app = nil
|
76
|
+
end
|
77
|
+
|
78
|
+
# Creates test app object and yields it back to the block
|
79
|
+
def test_app
|
80
|
+
app = launch_test_app
|
81
|
+
|
82
|
+
def app.textarea #define singleton method retrieving app's text area
|
83
|
+
Window.new find_window_ex(self.handle, 0, TEXTAREA_CLASS, nil)
|
84
|
+
end
|
85
|
+
|
86
|
+
yield app
|
87
|
+
close_test_app
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
data/spec/win_gui/window_spec.rb
CHANGED
@@ -1,124 +1,121 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), ".." , "spec_helper" )
|
2
|
-
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
@app.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
it '
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
children
|
96
|
-
children.should
|
97
|
-
children.
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
#
|
112
|
-
#
|
113
|
-
# it '
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
it 'emulates clicking of the control identified by id'
|
122
|
-
end
|
123
|
-
end
|
1
|
+
require File.join(File.dirname(__FILE__), ".." , "spec_helper" )
|
2
|
+
|
3
|
+
module WinGuiTest
|
4
|
+
include WinGui
|
5
|
+
|
6
|
+
describe Window do
|
7
|
+
before(:each) { @app = launch_test_app }
|
8
|
+
after(:each){ close_test_app }
|
9
|
+
|
10
|
+
context 'initializing' do
|
11
|
+
it 'can be wrapped around any existing window' do
|
12
|
+
any_handle = find_window(nil, nil)
|
13
|
+
use{ Window.new any_handle }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'manipulating' do
|
18
|
+
|
19
|
+
it 'has handle property equal to underlying window handle' do
|
20
|
+
any_handle = find_window(nil, nil)
|
21
|
+
any = Window.new any_handle
|
22
|
+
any.handle.should == any_handle
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'has text property equal to underlying window text(title)' do
|
26
|
+
@app.text.should == WIN_TITLE
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'closes when asked nicely' do
|
30
|
+
@app.close
|
31
|
+
sleep SLEEP_DELAY # needed to ensure window had enough time to close down
|
32
|
+
find_window(nil, WIN_TITLE).should == nil
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'waits f0r window to disappear (NB: this happens before handle is released!)' do
|
36
|
+
start = Time.now
|
37
|
+
@app.close
|
38
|
+
@app.wait_for_close
|
39
|
+
(Time.now - start).should be <= WG_CLOSE_TIMEOUT
|
40
|
+
window_visible?(@app.handle).should be false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context '.top_level class method' do
|
45
|
+
it 'finds any top-level window (title = nil) and wraps it in a Window object' do
|
46
|
+
use { @win = Window.top_level(title = nil, timeout_sec = 3) }
|
47
|
+
Window.should === @win
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'finds top-level window by title and wraps it in a Window object' do
|
51
|
+
win = Window.top_level( WIN_TITLE, 1)
|
52
|
+
win.handle.should == @app.handle
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context '#child' do
|
57
|
+
spec { use { @control = @app.child(title_class_id = nil) }}
|
58
|
+
|
59
|
+
it 'finds any child window(control) if given nil' do
|
60
|
+
@app.child(nil).should_not == nil
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'finds child window(control) by class' do
|
64
|
+
@app.child(TEXTAREA_CLASS).should_not == nil
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'finds child window(control) by name' do
|
68
|
+
pending 'Need to find control with short name'
|
69
|
+
@app.child(TEXTAREA_TEXT).should_not == nil
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'finds child window(control) by control ID' do
|
73
|
+
pending 'Need to find some control ID'
|
74
|
+
@app.child(TEXTAREA_ID).should_not == nil
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'raises error if wrong control is given' do
|
78
|
+
expect { @app.child('Impossible Control')}.to raise_error "Control 'Impossible Control' not found"
|
79
|
+
end
|
80
|
+
it 'substitutes & for _ when searching by title ("&Yes" type controls)'
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
context '#children' do
|
85
|
+
spec { use { children = @app.children }}
|
86
|
+
|
87
|
+
it 'returns an array' do
|
88
|
+
@app.children.should be_a_kind_of(Array)
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'returns an array of all child windows to the given window ' do
|
92
|
+
children = @app.children
|
93
|
+
children.should be_a_kind_of Array
|
94
|
+
children.should_not be_empty
|
95
|
+
children.should have(2).elements
|
96
|
+
children.each{|child| child?(@app.handle, child.handle).should == true }
|
97
|
+
get_class_name(children.last.handle).should == TEXTAREA_CLASS
|
98
|
+
end
|
99
|
+
|
100
|
+
# it 'finds child window(control) by name' do
|
101
|
+
# pending 'Need to find control with short name'
|
102
|
+
# @app.child(TEXTAREA_TEXT).should_not == nil
|
103
|
+
# end
|
104
|
+
#
|
105
|
+
# it 'finds child window(control) by control ID' do
|
106
|
+
# pending 'Need to find some control ID'
|
107
|
+
# @app.child(TEXTAREA_ID).should_not == nil
|
108
|
+
# end
|
109
|
+
#
|
110
|
+
# it 'raises error if wrong control is given' do
|
111
|
+
# expect { @app.child('Impossible Control')}.to raise_error "Control 'Impossible Control' not found"
|
112
|
+
# end
|
113
|
+
# it 'substitutes & for _ when searching by title ("&Yes" type controls)'
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
context '#click' do
|
118
|
+
it 'emulates clicking of the control identified by id'
|
119
|
+
end
|
120
|
+
end
|
124
121
|
end
|
data/tasks/common.rake
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#task :default => 'test:run'
|
2
|
+
#task 'gem:release' => 'test:run'
|
3
|
+
|
4
|
+
#Bundler not ready for prime time just yet
|
5
|
+
#desc 'Bundle dependencies'
|
6
|
+
#task :bundle do
|
7
|
+
# output = `bundle check 2>&1`
|
8
|
+
#
|
9
|
+
# unless $?.to_i == 0
|
10
|
+
# puts output
|
11
|
+
# system "bundle install"
|
12
|
+
# puts
|
13
|
+
# end
|
14
|
+
#end
|
data/tasks/doc.rake
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
desc 'Alias to doc:rdoc'
|
2
|
+
task :doc => 'doc:rdoc'
|
3
|
+
|
4
|
+
namespace :doc do
|
5
|
+
require 'rake/rdoctask'
|
6
|
+
Rake::RDocTask.new do |rdoc|
|
7
|
+
# Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "clobber", :rerdoc => "rerdoc") do |rdoc|
|
8
|
+
rdoc.rdoc_dir = DOC_PATH.basename.to_s
|
9
|
+
rdoc.title = "#{NAME} #{VERSION} Documentation"
|
10
|
+
rdoc.main = "README.doc"
|
11
|
+
rdoc.rdoc_files.include('README*')
|
12
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
13
|
+
end
|
14
|
+
end
|
data/tasks/gem.rake
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
desc "Alias to gem:release"
|
2
|
+
task :release => 'gem:release'
|
3
|
+
|
4
|
+
desc "Alias to gem:install"
|
5
|
+
task :install => 'gem:install'
|
6
|
+
|
7
|
+
desc "Alias to gem:build"
|
8
|
+
task :gem => 'gem:build'
|
9
|
+
|
10
|
+
namespace :gem do
|
11
|
+
gem_file = "#{NAME}-#{VERSION}.gem"
|
12
|
+
|
13
|
+
desc "(Re-)Build gem"
|
14
|
+
task :build do
|
15
|
+
puts "Remove existing gem package"
|
16
|
+
rm_rf PKG_PATH
|
17
|
+
puts "Build new gem package"
|
18
|
+
system "gem build #{NAME}.gemspec"
|
19
|
+
puts "Move built gem to package dir"
|
20
|
+
mkdir_p PKG_PATH
|
21
|
+
mv gem_file, PKG_PATH
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Cleanup already installed gem(s)"
|
25
|
+
task :cleanup do
|
26
|
+
puts "Cleaning up installed gem(s)"
|
27
|
+
system "gem cleanup #{NAME}"
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Build and install gem"
|
31
|
+
task :install => :build do
|
32
|
+
system "gem install #{PKG_PATH}/#{gem_file}"
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Build and push gem to Gemcutter"
|
36
|
+
task :release => [:build, 'git:tag'] do
|
37
|
+
system "gem push #{PKG_PATH}/#{gem_file}"
|
38
|
+
end
|
39
|
+
end
|
data/tasks/git.rake
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
desc "Alias to git:commit"
|
2
|
+
task :git => 'git:commit'
|
3
|
+
|
4
|
+
namespace :git do
|
5
|
+
|
6
|
+
desc "Stage and commit your work [with message]"
|
7
|
+
task :commit, [:message] do |t, args|
|
8
|
+
puts "Staging new (unversioned) files"
|
9
|
+
system "git add --all"
|
10
|
+
if args.message
|
11
|
+
puts "Committing with message: #{args.message}"
|
12
|
+
system %Q[git commit -a -m "#{args.message}" --author arvicco]
|
13
|
+
else
|
14
|
+
puts "Committing"
|
15
|
+
system %Q[git commit -a -m "No message" --author arvicco]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Push local changes to Github"
|
20
|
+
task :push => :commit do
|
21
|
+
puts "Pushing local changes to remote"
|
22
|
+
system "git push"
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Create (release) tag on Github"
|
26
|
+
task :tag => :push do
|
27
|
+
tag = VERSION
|
28
|
+
puts "Creating git tag: #{tag}"
|
29
|
+
system %Q{git tag -a -m "Release tag #{tag}" #{tag}}
|
30
|
+
puts "Pushing #{tag} to remote"
|
31
|
+
system "git push origin #{tag}"
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/tasks/spec.rake
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
desc 'Alias to spec:spec'
|
2
|
+
task :spec => 'spec:spec'
|
3
|
+
|
4
|
+
namespace :spec do
|
5
|
+
require 'spec/rake/spectask'
|
6
|
+
|
7
|
+
desc "Run all specs"
|
8
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
9
|
+
t.spec_opts = ['--options', %Q{"#{BASE_PATH}/spec/spec.opts"}]
|
10
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Run specs with RCov"
|
14
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
15
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
16
|
+
t.rcov = true
|
17
|
+
t.rcov_opts = ['--exclude', 'spec']
|
18
|
+
end
|
19
|
+
end
|
data/tasks/version.rake
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
class Version
|
2
|
+
attr_accessor :major, :minor, :patch, :build
|
3
|
+
|
4
|
+
def initialize(version_string)
|
5
|
+
raise "Invalid version #{version_string}" unless version_string =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
|
6
|
+
@major = $1.to_i
|
7
|
+
@minor = $2.to_i
|
8
|
+
@patch = $3.to_i
|
9
|
+
@build = $4
|
10
|
+
end
|
11
|
+
|
12
|
+
def bump_major(x)
|
13
|
+
@major += x.to_i
|
14
|
+
@minor = 0
|
15
|
+
@patch = 0
|
16
|
+
@build = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def bump_minor(x)
|
20
|
+
@minor += x.to_i
|
21
|
+
@patch = 0
|
22
|
+
@build = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def bump_patch(x)
|
26
|
+
@patch += x.to_i
|
27
|
+
@build = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def update(major, minor, patch, build=nil)
|
31
|
+
@major = major
|
32
|
+
@minor = minor
|
33
|
+
@patch = patch
|
34
|
+
@build = build
|
35
|
+
end
|
36
|
+
|
37
|
+
def write(desc = nil)
|
38
|
+
CLASS_NAME::VERSION_FILE.open('w') {|file| file.puts to_s }
|
39
|
+
(BASE_PATH + 'HISTORY').open('a') do |file|
|
40
|
+
file.puts "\n== #{to_s} / #{Time.now.strftime '%Y-%m-%d'}\n"
|
41
|
+
file.puts "\n* #{desc}\n" if desc
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_s
|
46
|
+
[major, minor, patch, build].compact.join('.')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
desc 'Set version: [x.y.z] - explicitly, [1/10/100] - bump major/minor/patch, [.build] - build'
|
51
|
+
task :version, [:command, :desc] do |t, args|
|
52
|
+
version = Version.new(VERSION)
|
53
|
+
case args.command
|
54
|
+
when /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/ # Set version explicitly
|
55
|
+
version.update($1, $2, $3, $4)
|
56
|
+
when /^\.(.*?)$/ # Set build
|
57
|
+
version.build = $1
|
58
|
+
when /^(\d{1})$/ # Bump patch
|
59
|
+
version.bump_patch $1
|
60
|
+
when /^(\d{1})0$/ # Bump minor
|
61
|
+
version.bump_minor $1
|
62
|
+
when /^(\d{1})00$/ # Bump major
|
63
|
+
version.bump_major $1
|
64
|
+
else # Unknown command, just display VERSION
|
65
|
+
puts "#{NAME} #{version}"
|
66
|
+
next
|
67
|
+
end
|
68
|
+
|
69
|
+
puts "Writing version #{version} to VERSION file"
|
70
|
+
version.write args.desc
|
71
|
+
end
|