osaka 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/osaka/applicationwrapper.rb +64 -20
- data/lib/osaka/applicationwrapperexpectations.rb +4 -0
- data/lib/osaka/calculator.rb +5 -5
- data/lib/osaka/keynote.rb +9 -0
- data/lib/osaka/keynoteflow.rb +29 -0
- data/lib/osaka/location.rb +132 -0
- data/lib/osaka/mailmergeflow.rb +19 -0
- data/lib/osaka/pages.rb +10 -7
- data/lib/osaka/scriptrunner.rb +18 -3
- data/lib/osaka/textedit.rb +2 -2
- data/lib/osaka/typicalapplication.rb +80 -27
- data/lib/osaka/version.rb +1 -1
- data/lib/osaka.rb +3 -0
- data/spec/applicationwrapper_spec.rb +76 -39
- data/spec/assets/01_first_slides.key +0 -0
- data/spec/assets/02_second_slides.key +0 -0
- data/spec/assets/03_third_slides.key +0 -0
- data/spec/assets/mail_merge_data.numbers +0 -0
- data/spec/assets/mail_merge_template.pages +0 -0
- data/spec/calculator_spec.rb +6 -6
- data/spec/integration_calculator_spec.rb +0 -1
- data/spec/integration_keynote_spec.rb +29 -0
- data/spec/integration_pages_numbers_mail_merge_spec.rb +17 -0
- data/spec/integration_textedit_spec.rb +7 -3
- data/spec/keynote_flows_spec.rb +62 -0
- data/spec/keynote_spec.rb +21 -1
- data/spec/location_spec.rb +53 -0
- data/spec/mailmergeflow_spec.rb +40 -0
- data/spec/pages_spec.rb +13 -13
- data/spec/scriptrunner_spec.rb +9 -0
- data/spec/textedit_spec.rb +3 -3
- data/spec/typicalapplication_spec.rb +94 -29
- metadata +15 -2
data/spec/textedit_spec.rb
CHANGED
@@ -13,16 +13,16 @@ describe "TextEdit" do
|
|
13
13
|
|
14
14
|
it "should set the window on activation" do
|
15
15
|
@wrapper.should_receive(:activate)
|
16
|
-
@wrapper.should_receive(:
|
16
|
+
@wrapper.should_receive(:current_window_name).and_return("")
|
17
17
|
subject.should_receive(:wait_for_new_window).with([])
|
18
18
|
@wrapper.should_receive(:window_list).and_return(["Untitled"])
|
19
|
-
@wrapper.should_receive(:
|
19
|
+
@wrapper.should_receive(:set_current_window).with("Untitled")
|
20
20
|
subject.activate
|
21
21
|
end
|
22
22
|
|
23
23
|
it "shouldn't set the window on activation when it is already set" do
|
24
24
|
@wrapper.should_receive(:activate)
|
25
|
-
@wrapper.should_receive(:
|
25
|
+
@wrapper.should_receive(:current_window_name).and_return("Untitled")
|
26
26
|
subject.activate
|
27
27
|
end
|
28
28
|
|
@@ -9,27 +9,48 @@ describe "Osaka::TypicalApplication" do
|
|
9
9
|
|
10
10
|
before (:each) do
|
11
11
|
@wrapper = subject.wrapper = double("Osaka::ApplicationWrapper")
|
12
|
+
Osaka::ScriptRunner.enable_debug_prints
|
12
13
|
end
|
13
14
|
|
14
|
-
|
15
|
+
after (:each) do
|
16
|
+
Osaka::ScriptRunner.disable_debug_prints
|
17
|
+
end
|
18
|
+
|
19
|
+
it "Should pass the right open string to the application osascript" do
|
15
20
|
filename = "filename.key"
|
16
21
|
expect_tell("open \"#{File.absolute_path(filename)}\"")
|
17
|
-
@wrapper.should_receive(:
|
22
|
+
@wrapper.should_receive(:set_current_window).with(filename)
|
18
23
|
subject.open(filename)
|
19
24
|
end
|
20
25
|
|
26
|
+
it "Should only get the basename of the filename when it sets the window title." do
|
27
|
+
filename = "/root/dirname/filename.key"
|
28
|
+
expect_tell("open \"#{File.absolute_path(filename)}\"")
|
29
|
+
@wrapper.should_receive(:set_current_window).with("filename.key")
|
30
|
+
subject.open(filename)
|
31
|
+
end
|
32
|
+
|
21
33
|
it "Should be able to quit" do
|
34
|
+
@wrapper.should_receive(:running?).and_return(true)
|
22
35
|
@wrapper.should_receive(:quit)
|
23
36
|
subject.quit
|
24
37
|
end
|
25
38
|
|
39
|
+
it "Should be able to check if its running" do
|
40
|
+
@wrapper.should_receive(:running?)
|
41
|
+
subject.running?
|
42
|
+
end
|
43
|
+
|
44
|
+
it "Won't quit when the application isn't running" do
|
45
|
+
@wrapper.should_receive(:running?).and_return(false)
|
46
|
+
subject.quit(:dont_save)
|
47
|
+
end
|
48
|
+
|
26
49
|
it "Should be able to quit without saving" do
|
27
|
-
@wrapper.should_receive(:
|
50
|
+
@wrapper.should_receive(:running?).and_return(true, true, false)
|
28
51
|
@wrapper.should_receive(:quit)
|
29
|
-
|
30
|
-
|
31
|
-
expect_click!('button 2 of sheet 1 of window "Untitled"')
|
32
|
-
}
|
52
|
+
should_check!(:exists, at.sheet(1), true)
|
53
|
+
expect_click!(at.button(2).sheet(1))
|
33
54
|
subject.quit(:dont_save)
|
34
55
|
end
|
35
56
|
|
@@ -52,7 +73,7 @@ describe "Osaka::TypicalApplication" do
|
|
52
73
|
subject.wrapper.should_receive(:window_list)
|
53
74
|
expect_keystroke("n", :command)
|
54
75
|
subject.should_receive(:wait_for_new_window).and_return("new_window")
|
55
|
-
subject.wrapper.should_receive(:
|
76
|
+
subject.wrapper.should_receive(:set_current_window).with("new_window")
|
56
77
|
subject.wrapper.should_receive(:focus)
|
57
78
|
subject.new_document
|
58
79
|
end
|
@@ -62,6 +83,14 @@ describe "Osaka::TypicalApplication" do
|
|
62
83
|
subject.save
|
63
84
|
end
|
64
85
|
|
86
|
+
it "Should be able to save as a file" do
|
87
|
+
save_dialog = double("Osaka::TypicalSaveDialog")
|
88
|
+
subject.should_receive(:save_dialog).and_return(save_dialog)
|
89
|
+
save_dialog.should_receive(:save).with("filename")
|
90
|
+
subject.wrapper.should_receive(:set_current_window).with("filename")
|
91
|
+
subject.save_as("filename")
|
92
|
+
end
|
93
|
+
|
65
94
|
it "Should be able to close" do
|
66
95
|
expect_keystroke("w", :command)
|
67
96
|
subject.close
|
@@ -72,19 +101,49 @@ describe "Osaka::TypicalApplication" do
|
|
72
101
|
subject.should_receive(:wait_for_window_and_dialogs_to_close).with(:dont_save)
|
73
102
|
subject.close(:dont_save)
|
74
103
|
end
|
75
|
-
|
76
|
-
it "Should be able to activate
|
104
|
+
|
105
|
+
it "Should be able to activate" do
|
77
106
|
@wrapper.should_receive(:activate)
|
78
107
|
subject.activate
|
79
108
|
end
|
80
109
|
|
110
|
+
it "Should be able to focus" do
|
111
|
+
@wrapper.should_receive(:focus)
|
112
|
+
subject.focus
|
113
|
+
end
|
114
|
+
|
115
|
+
it "Should be able to copy" do
|
116
|
+
expect_keystroke("c", :command)
|
117
|
+
subject.copy
|
118
|
+
end
|
119
|
+
|
120
|
+
it "Should be able to paste" do
|
121
|
+
expect_keystroke("v", :command)
|
122
|
+
subject.paste
|
123
|
+
end
|
124
|
+
|
125
|
+
it "Should be able to cut" do
|
126
|
+
expect_keystroke("x", :command)
|
127
|
+
subject.cut
|
128
|
+
end
|
129
|
+
|
130
|
+
it "Should be able to select all" do
|
131
|
+
expect_keystroke("a", :command)
|
132
|
+
subject.select_all
|
133
|
+
end
|
134
|
+
|
81
135
|
it "Should be able to retrieve a print dialog" do
|
82
136
|
expect_keystroke("p", :command)
|
83
|
-
|
84
|
-
should_wait_until(:exists, "sheet 1 of window 1")
|
137
|
+
should_wait_until(:exists, at.sheet(1))
|
85
138
|
subject.print_dialog
|
86
139
|
end
|
87
140
|
|
141
|
+
it "Should be able to retrieve a save dialog" do
|
142
|
+
expect_keystroke("s", [:command, :shift])
|
143
|
+
should_wait_until(:exists, at.sheet(1))
|
144
|
+
subject.save_dialog
|
145
|
+
end
|
146
|
+
|
88
147
|
describe "Application info" do
|
89
148
|
it "Should be able to retrieve an application info object and parse it" do
|
90
149
|
@wrapper.should_receive(:tell).with('get info for (path to application "ApplicationName")').and_return('name:ApplicationName.app, creation date:date "Sunday, December 21, 2008 PM 06:14:11"}')
|
@@ -95,23 +154,22 @@ describe "Osaka::TypicalApplication" do
|
|
95
154
|
|
96
155
|
describe "Generic Print Dialog" do
|
97
156
|
|
98
|
-
|
99
|
-
subject { Osaka::TypicalPrintDialog.new("window 1", double(:OSAApp).as_null_object) }
|
157
|
+
subject { Osaka::TypicalPrintDialog.new(at.sheet(1), double(:OSAApp).as_null_object) }
|
100
158
|
|
101
159
|
it "Should be able to save the PDF in a print dialog" do
|
102
160
|
save_dialog_mock = double(:GenericSaveDialog)
|
103
161
|
|
104
|
-
expect_click!(
|
105
|
-
should_wait_until!(:exists,
|
162
|
+
expect_click!(at.menu_button("PDF").sheet(1))
|
163
|
+
should_wait_until!(:exists, at.menu(1).menu_button("PDF").sheet(1))
|
106
164
|
|
107
|
-
expect_click!(
|
108
|
-
should_wait_until!(:exists,
|
165
|
+
expect_click!(at.menu_item(2).menu(1).menu_button("PDF").sheet(1))
|
166
|
+
should_wait_until!(:exists, at.window("Save"))
|
109
167
|
|
110
|
-
subject.should_receive(:create_save_dialog).with(
|
168
|
+
subject.should_receive(:create_save_dialog).with(at.window("Save"), subject.wrapper).and_return(save_dialog_mock)
|
111
169
|
save_dialog_mock.should_receive(:save).with("filename")
|
112
170
|
|
113
|
-
should_do_until!(:not_exists,
|
114
|
-
expect_click!(
|
171
|
+
should_do_until!(:not_exists, at.sheet(1)) {
|
172
|
+
expect_click!(at.checkbox(1).window("Print"))
|
115
173
|
}
|
116
174
|
|
117
175
|
subject.save_as_pdf("filename")
|
@@ -120,7 +178,14 @@ describe "Osaka::TypicalApplication" do
|
|
120
178
|
|
121
179
|
describe "Generic Save Dialog" do
|
122
180
|
|
123
|
-
subject { Osaka::TypicalSaveDialog.new(
|
181
|
+
subject { Osaka::TypicalSaveDialog.new(at.sheet(1), double("Osaka::ApplicationWrapper").as_null_object)}
|
182
|
+
|
183
|
+
it "Should clone the wrapper and change the window name to Save" do
|
184
|
+
app_wrapper = double("Osaka::ApplicationWrapper")
|
185
|
+
app_cloned_wrapper = double("Osaka::ApplicationWrapper")
|
186
|
+
app_wrapper.should_receive(:clone).and_return(app_cloned_wrapper)
|
187
|
+
Osaka::TypicalSaveDialog.new(at.sheet(1), app_wrapper)
|
188
|
+
end
|
124
189
|
|
125
190
|
it "Should set the filename in the test field" do
|
126
191
|
subject.should_receive(:set_filename).with("filename")
|
@@ -144,22 +209,22 @@ describe "Osaka::TypicalApplication" do
|
|
144
209
|
end
|
145
210
|
|
146
211
|
it "Should be able to click save" do
|
147
|
-
expect_click(
|
148
|
-
should_wait_until(:not_exists,
|
212
|
+
expect_click(at.button("Save").sheet(1))
|
213
|
+
should_wait_until(:not_exists, at.sheet(1))
|
149
214
|
subject.click_save
|
150
215
|
end
|
151
216
|
|
152
217
|
it "Should be able to set the filename" do
|
153
|
-
subject.wrapper.should_receive(:set).with('value',
|
218
|
+
subject.wrapper.should_receive(:set).with('value', at.text_field(1).sheet(1), "filename")
|
154
219
|
subject.set_filename("filename")
|
155
220
|
end
|
156
221
|
|
157
222
|
it "Should be able to set the path" do
|
158
223
|
expect_keystroke("g", [ :command, :shift ])
|
159
|
-
should_wait_until(:exists,
|
160
|
-
subject.wrapper.should_receive(:set).with("value",
|
161
|
-
expect_click(
|
162
|
-
should_wait_until(:not_exists,
|
224
|
+
should_wait_until(:exists, at.sheet(1).sheet(1))
|
225
|
+
subject.wrapper.should_receive(:set).with("value", at.text_field(1).sheet(1).sheet(1), "path")
|
226
|
+
expect_click(at.button("Go").sheet(1).sheet(1))
|
227
|
+
should_wait_until(:not_exists, at.sheet(1).sheet(1))
|
163
228
|
subject.set_folder("path")
|
164
229
|
end
|
165
230
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: osaka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.3.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Bas Vodde
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-07-23 00:00:00 +08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -51,6 +51,9 @@ files:
|
|
51
51
|
- lib/osaka/applicationwrapperexpectations.rb
|
52
52
|
- lib/osaka/calculator.rb
|
53
53
|
- lib/osaka/keynote.rb
|
54
|
+
- lib/osaka/keynoteflow.rb
|
55
|
+
- lib/osaka/location.rb
|
56
|
+
- lib/osaka/mailmergeflow.rb
|
54
57
|
- lib/osaka/numbers.rb
|
55
58
|
- lib/osaka/pages.rb
|
56
59
|
- lib/osaka/scriptrunner.rb
|
@@ -59,10 +62,20 @@ files:
|
|
59
62
|
- lib/osaka/version.rb
|
60
63
|
- osaka.gemfile
|
61
64
|
- spec/applicationwrapper_spec.rb
|
65
|
+
- spec/assets/01_first_slides.key
|
66
|
+
- spec/assets/02_second_slides.key
|
67
|
+
- spec/assets/03_third_slides.key
|
68
|
+
- spec/assets/mail_merge_data.numbers
|
69
|
+
- spec/assets/mail_merge_template.pages
|
62
70
|
- spec/calculator_spec.rb
|
63
71
|
- spec/integration_calculator_spec.rb
|
72
|
+
- spec/integration_keynote_spec.rb
|
73
|
+
- spec/integration_pages_numbers_mail_merge_spec.rb
|
64
74
|
- spec/integration_textedit_spec.rb
|
75
|
+
- spec/keynote_flows_spec.rb
|
65
76
|
- spec/keynote_spec.rb
|
77
|
+
- spec/location_spec.rb
|
78
|
+
- spec/mailmergeflow_spec.rb
|
66
79
|
- spec/numbers_spec.rb
|
67
80
|
- spec/pages_spec.rb
|
68
81
|
- spec/scriptrunner_spec.rb
|