osaka 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,85 +3,89 @@ module Osaka
3
3
  module ApplicationWrapperExpectations
4
4
 
5
5
  def expect_clone
6
- @wrapper.should_receive(:clone)
6
+ wrapper.should_receive(:clone)
7
7
  end
8
8
 
9
9
  def expect_activate
10
- @wrapper.should_receive(:activate)
10
+ wrapper.should_receive(:activate)
11
11
  end
12
12
 
13
13
  def expect_focus
14
- @wrapper.should_receive(:focus)
14
+ wrapper.should_receive(:focus)
15
15
  end
16
16
 
17
17
  def expect_set_current_window(name)
18
- @wrapper.should_receive(:set_current_window).with(name)
18
+ wrapper.should_receive(:set_current_window).with(name)
19
19
  end
20
20
 
21
21
  def expect_running?
22
- @wrapper.should_receive(:running?)
22
+ wrapper.should_receive(:running?)
23
23
  end
24
24
 
25
25
  def expect_quit
26
- @wrapper.should_receive(:quit)
26
+ wrapper.should_receive(:quit)
27
27
  end
28
28
 
29
29
  def expect_window_list
30
- @wrapper.should_receive(:window_list)
30
+ wrapper.should_receive(:window_list)
31
31
  end
32
32
 
33
33
  def expect_set(element, location, value)
34
- @wrapper.should_receive(:set).with(element, location, value)
34
+ wrapper.should_receive(:set).with(element, location, value)
35
35
  end
36
36
 
37
37
  def expect_keystroke(key, modifier = [])
38
- @wrapper.should_receive(:keystroke).with(key, modifier).and_return(@wrapper) unless modifier.empty?
39
- @wrapper.should_receive(:keystroke).with(key).and_return(@wrapper) if modifier.empty?
38
+ wrapper.should_receive(:keystroke).with(key, modifier).and_return(wrapper) unless modifier.empty?
39
+ wrapper.should_receive(:keystroke).with(key).and_return(wrapper) if modifier.empty?
40
40
  end
41
41
 
42
42
  def expect_keystroke!(key, modifier = [])
43
- @wrapper.should_receive(:keystroke!).with(key, modifier).and_return(@wrapper) unless modifier.empty?
44
- @wrapper.should_receive(:keystroke!).with(key).and_return(@wrapper) if modifier.empty?
43
+ wrapper.should_receive(:keystroke!).with(key, modifier).and_return(wrapper) unless modifier.empty?
44
+ wrapper.should_receive(:keystroke!).with(key).and_return(wrapper) if modifier.empty?
45
45
  end
46
46
 
47
47
  def expect_click!(location)
48
- @wrapper.should_receive(:click!).with(location).and_return(@wrapper)
48
+ wrapper.should_receive(:click!).with(location).and_return(wrapper)
49
49
  end
50
50
 
51
51
  def expect_click(location)
52
- @wrapper.should_receive(:click).with(location).and_return(@wrapper)
52
+ wrapper.should_receive(:click).with(location).and_return(wrapper)
53
53
  end
54
54
 
55
55
  def expect_click_menu_bar(menu_item, menu_name)
56
- @wrapper.should_receive(:click_menu_bar).with(menu_item, menu_name).and_return(@wrapper)
56
+ wrapper.should_receive(:click_menu_bar).with(menu_item, menu_name).and_return(wrapper)
57
+ end
58
+
59
+ def expect_get!(element, location)
60
+ wrapper.should_receive(:get!).with(element, location)
57
61
  end
58
62
 
59
63
  def expect_tell(do_this)
60
- @wrapper.should_receive(:tell).with(do_this)
64
+ wrapper.should_receive(:tell).with(do_this)
61
65
  end
62
66
 
63
67
  def expect_system_event(event)
64
- @wrapper.should_receive(:system_event).with(event)
68
+ wrapper.should_receive(:system_event).with(event)
65
69
  end
66
70
 
67
71
  def expect_exists(location)
68
- @wrapper.should_receive(:exists).with(location)
72
+ wrapper.should_receive(:exists).with(location)
69
73
  end
70
74
 
71
75
  def expect_wait_until_exists(location)
72
- @wrapper.should_receive(:wait_until_exists).with(location)
76
+ wrapper.should_receive(:wait_until_exists).with(location)
73
77
  end
74
78
 
75
79
  def expect_wait_until_exists!(*location)
76
- @wrapper.should_receive(:wait_until_exists!).with(*location)
80
+ wrapper.should_receive(:wait_until_exists!).with(*location)
77
81
  end
78
82
 
79
83
  def expect_wait_until_not_exists(location)
80
- @wrapper.should_receive(:wait_until_not_exists).with(location)
84
+ wrapper.should_receive(:wait_until_not_exists).with(location)
81
85
  end
82
86
 
83
87
  def expect_until_not_exists!(element)
84
- @wrapper.should_receive(:until_not_exists!).with(element).and_yield
88
+ wrapper.should_receive(:until_not_exists!).with(element).and_yield
85
89
  end
86
90
  end
87
91
  end
@@ -12,6 +12,9 @@ module CommonFlows
12
12
  pages.open(pages_file)
13
13
  pages.mail_merge_to_pdf(output_file)
14
14
 
15
+ numbers.close(:dont_save)
16
+ pages.close(:dont_save)
17
+
15
18
  numbers.quit(:dont_save)
16
19
  pages.quit(:dont_save)
17
20
 
@@ -155,6 +155,7 @@ module Osaka
155
155
  }
156
156
  new_instance = clone
157
157
  new_instance.wrapper.set_current_window(do_and_wait_for_new_window {
158
+ sleep(0.4) # This sleep is added because mountain lion keynote crashes without it!
158
159
  @wrapper.keystroke!(:return)
159
160
  })
160
161
 
data/lib/osaka/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Osaka
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
4
4
  end
@@ -19,7 +19,7 @@ describe "Osaka::ApplicationWrapper" do
19
19
  subject.set_current_window "Window"
20
20
  new_wrapper = subject.clone
21
21
  new_wrapper.should == subject
22
- new_wrapper.should_not.equal?(subject)
22
+ new_wrapper.should_not equal(subject)
23
23
  end
24
24
 
25
25
  it "Should be able to compare objects using names" do
Binary file
Binary file
@@ -6,20 +6,17 @@ describe "Mac GUI Calculator" do
6
6
  include(*Osaka::ApplicationWrapperExpectations)
7
7
 
8
8
  subject { Osaka::Calculator.new }
9
+ let(:wrapper) { subject.wrapper = double("Osaka::ApplicationWrapper")}
9
10
 
10
- before (:each) do
11
- @wrapper = subject.wrapper = double("Osaka::ApplicationWrapper")
12
- end
13
-
14
11
  it "Should be setting the window when starting the Calculator" do
15
12
 
16
13
  # TODO: Fix this duplication between this and TextEdit.
17
14
 
18
- @wrapper.should_receive(:activate)
19
- @wrapper.should_receive(:current_window_name).and_return("")
15
+ wrapper.should_receive(:activate)
16
+ wrapper.should_receive(:current_window_name).and_return("")
20
17
  subject.should_receive(:wait_for_new_window).with([])
21
- @wrapper.should_receive(:window_list).and_return(["Calculator"])
22
- @wrapper.should_receive(:set_current_window).with("Calculator")
18
+ wrapper.should_receive(:window_list).and_return(["Calculator"])
19
+ wrapper.should_receive(:set_current_window).with("Calculator")
23
20
  subject.activate
24
21
  end
25
22
 
@@ -34,14 +31,14 @@ describe "Mac GUI Calculator" do
34
31
  end
35
32
 
36
33
  it "Should be able to quit the calculator" do
37
- @wrapper.should_receive(:running?).and_return(true)
38
- @wrapper.should_receive(:quit)
34
+ wrapper.should_receive(:running?).and_return(true)
35
+ wrapper.should_receive(:quit)
39
36
  subject.quit
40
37
  end
41
38
 
42
39
  it "Should be able to get the value from the screen" do
43
40
  expect_wait_until_exists!(at.static_text(1).group(1))
44
- @wrapper.should_receive(:get!).with("value", at.static_text(1).group(1)).and_return("0")
41
+ wrapper.should_receive(:get!).with("value", at.static_text(1).group(1)).and_return("0")
45
42
  subject.result.should == "0"
46
43
  end
47
44
 
@@ -3,28 +3,26 @@ require "osaka"
3
3
 
4
4
  describe "Common flows in keynote" do
5
5
 
6
- before(:each) do
7
- @mock_keynote = double(:Keynote)
8
- end
6
+ let(:mock_keynote) { double(:Keynote)}
9
7
 
10
8
  it "Should be able to combine just one single file" do
11
- Osaka::Keynote.should_receive(:new).and_return(@mock_keynote)
12
- @mock_keynote.should_receive(:open).with("one_file.key")
13
- @mock_keynote.should_receive(:save_as).with("result.key")
14
- @mock_keynote.should_receive(:save)
15
- @mock_keynote.should_receive(:quit)
9
+ Osaka::Keynote.should_receive(:new).and_return(mock_keynote)
10
+ mock_keynote.should_receive(:open).with("one_file.key")
11
+ mock_keynote.should_receive(:save_as).with("result.key")
12
+ mock_keynote.should_receive(:save)
13
+ mock_keynote.should_receive(:quit)
16
14
  CommonFlows.keynote_combine_files("result.key", "one_file.key")
17
15
  end
18
16
 
19
17
  it "Should be able to combine multiple files in one result" do
20
18
  mock2_keynote = double(:Keynote)
21
19
  mock3_keynote = double(:Keynote)
22
- Osaka::Keynote.should_receive(:new).and_return(@mock_keynote, mock2_keynote, mock3_keynote)
23
- @mock_keynote.should_receive(:open).with("one_file.key")
24
- @mock_keynote.should_receive(:save_as).with("result.key")
25
- @mock_keynote.should_receive(:select_all_slides).exactly(2).times
26
- @mock_keynote.should_receive(:paste).exactly(2).times
27
- @mock_keynote.should_receive(:save)
20
+ Osaka::Keynote.should_receive(:new).and_return(mock_keynote, mock2_keynote, mock3_keynote)
21
+ mock_keynote.should_receive(:open).with("one_file.key")
22
+ mock_keynote.should_receive(:save_as).with("result.key")
23
+ mock_keynote.should_receive(:select_all_slides).exactly(2).times
24
+ mock_keynote.should_receive(:paste).exactly(2).times
25
+ mock_keynote.should_receive(:save)
28
26
 
29
27
 
30
28
  mock2_keynote.should_receive(:open).with("two_file.key")
@@ -37,7 +35,7 @@ describe "Common flows in keynote" do
37
35
  mock3_keynote.should_receive(:copy)
38
36
  mock3_keynote.should_receive(:close)
39
37
 
40
- @mock_keynote.should_receive(:quit)
38
+ mock_keynote.should_receive(:quit)
41
39
  CommonFlows.keynote_combine_files("result.key", ["one_file.key", "two_file.key", "three_file.key"])
42
40
  end
43
41
 
data/spec/keynote_spec.rb CHANGED
@@ -6,13 +6,10 @@ describe "Osaka::Keynote" do
6
6
  include(*Osaka::ApplicationWrapperExpectations)
7
7
 
8
8
  subject { Osaka::Keynote.new }
9
-
10
- before (:each) do
11
- @wrapper = subject.wrapper = double("Osaka::ApplicationWrapper").as_null_object
12
- end
9
+ let(:wrapper) {subject.wrapper = double("Osaka::ApplicationWrapper").as_null_object}
13
10
 
14
11
  it "Should create the correct keynote print dialog" do
15
- subject.create_print_dialog("window").class.should == Osaka::KeynotePrintDialog
12
+ subject.create_print_dialog("window").should be_instance_of Osaka::KeynotePrintDialog
16
13
  end
17
14
 
18
15
  it "Should be possible to select all the slides in the default location" do
@@ -3,38 +3,39 @@ require "osaka"
3
3
 
4
4
  describe "Mail Merge to PDF common flow" do
5
5
 
6
- before(:each) do
7
- @mock_numbers = double(:Numbers)
8
- @mock_pages = double(:Pages)
9
- end
10
-
6
+ let(:mock_numbers) { double(:Numbers)}
7
+ let(:mock_pages) { double(:Pages) }
8
+
11
9
  it "Should do a good mail merge with Pages and Keynote flow" do
12
- Osaka::Numbers.should_receive(:new).and_return(@mock_numbers)
13
- Osaka::Pages.should_receive(:new).and_return(@mock_pages)
10
+ Osaka::Numbers.should_receive(:new).and_return(mock_numbers)
11
+ Osaka::Pages.should_receive(:new).and_return(mock_pages)
14
12
 
15
- @mock_numbers.should_receive(:open).with("/template/numbers")
16
- @mock_numbers.should_receive(:save)
13
+ mock_numbers.should_receive(:open).with("/template/numbers")
14
+ mock_numbers.should_receive(:save)
15
+
16
+ mock_pages.should_receive(:open).with("/template/pages")
17
+ mock_pages.should_receive(:mail_merge_to_pdf).with("/output/file.pdf")
17
18
 
18
- @mock_pages.should_receive(:open).with("/template/pages")
19
- @mock_pages.should_receive(:mail_merge_to_pdf).with("/output/file.pdf")
19
+ mock_numbers.should_receive(:close).with(:dont_save)
20
+ mock_pages.should_receive(:close).with(:dont_save)
20
21
 
21
- @mock_numbers.should_receive(:quit).with(:dont_save)
22
- @mock_pages.should_receive(:quit).with(:dont_save)
22
+ mock_numbers.should_receive(:quit).with(:dont_save)
23
+ mock_pages.should_receive(:quit).with(:dont_save)
23
24
 
24
25
  CommonFlows.number_and_pages_mail_merge("/template/numbers", "/template/pages", "/output/file.pdf") {}
25
26
  end
26
27
 
27
28
  it "Should yield for filling in the numbers fields" do
28
- @mock_numbers.as_null_object
29
- @mock_pages.as_null_object
30
- Osaka::Numbers.should_receive(:new).and_return(@mock_numbers)
31
- Osaka::Pages.should_receive(:new).and_return(@mock_pages)
29
+ mock_numbers.as_null_object
30
+ mock_pages.as_null_object
31
+ Osaka::Numbers.should_receive(:new).and_return(mock_numbers)
32
+ Osaka::Pages.should_receive(:new).and_return(mock_pages)
32
33
 
33
34
  retrieved_numbers = nil
34
35
  CommonFlows.number_and_pages_mail_merge("1", "2", "3") { |numbers|
35
36
  retrieved_numbers = numbers
36
37
  }
37
- retrieved_numbers.should == @mock_numbers
38
+ retrieved_numbers.should == mock_numbers
38
39
  end
39
40
 
40
41
  end
data/spec/numbers_spec.rb CHANGED
@@ -3,14 +3,14 @@ require 'osaka'
3
3
 
4
4
  describe "Osaka::Numbers" do
5
5
 
6
- subject { Osaka::Numbers.new }
7
-
8
- before (:each) do
9
- subject.wrapper = double("Osaka::Number").as_null_object
10
- end
6
+ include(*Osaka::ApplicationWrapperExpectations)
7
+
8
+ subject { Osaka::Numbers.new }
9
+ let(:wrapper) { subject.wrapper = double("Osaka::Number").as_null_object}
11
10
 
12
11
  it "Should be able to fill in data in cells" do
13
- subject.wrapper.should_receive(:tell).with('tell document 1; tell sheet 1; tell table 1; set value of cell 1 of row 2 to "30"; end tell; end tell; end tell')
12
+ # subject.wrapper.should_receive(:tell).with('tell document 1; tell sheet 1; tell table 1; set value of cell 1 of row 2 to "30"; end tell; end tell; end tell')
13
+ expect_tell('tell document 1; tell sheet 1; tell table 1; set value of cell 1 of row 2 to "30"; end tell; end tell; end tell')
14
14
  subject.fill_cell(1, 2, "30")
15
15
  end
16
16
 
data/spec/pages_spec.rb CHANGED
@@ -7,9 +7,7 @@ describe "Osaka::Pages" do
7
7
 
8
8
  subject { Osaka::Pages.new }
9
9
 
10
- before (:each) do
11
- @wrapper = subject.wrapper = double("Osaka::ApplicationWrapper").as_null_object
12
- end
10
+ let (:wrapper) { subject.wrapper = double("Osaka::ApplicationWrapper").as_null_object}
13
11
 
14
12
  it "Should be able to do mail merge to a PDF flow" do
15
13
 
@@ -25,14 +23,14 @@ describe "Osaka::Pages" do
25
23
  end
26
24
 
27
25
  it "Should be able to select the Mail Merge" do
28
- @wrapper.should_receive(:current_window_name).any_number_of_times.and_return("Pages.pages")
26
+ wrapper.should_receive(:current_window_name).any_number_of_times.and_return("Pages.pages")
29
27
  expect_click_menu_bar(at.menu_item(20), "Edit")
30
28
  expect_wait_until_exists(at.button("Merge").sheet(1))
31
29
  subject.mail_merge
32
30
  end
33
31
 
34
32
  it "Should click the merge button of the mail merge dialog" do
35
- @wrapper.should_receive(:current_window_name).any_number_of_times.and_return("Pages.pages")
33
+ wrapper.should_receive(:current_window_name).any_number_of_times.and_return("Pages.pages")
36
34
  expect_click!(at.button("Merge").sheet(1))
37
35
  expect_wait_until_exists!(at.menu_button("PDF").window("Print"))
38
36
  subject.mail_merge.merge
@@ -44,11 +42,7 @@ describe "Osaka::Pages Mail Merge dialog" do
44
42
  include(*Osaka::ApplicationWrapperExpectations)
45
43
 
46
44
  subject { Osaka::PagesMailMergeDialog.new("", nil) }
47
-
48
- before (:each) do
49
- @wrapper = subject.wrapper = double("Osaka::ApplicationWrapper").as_null_object
50
- @location = subject.location = "window \"Pages.pages\""
51
- end
45
+ let(:wrapper) {subject.wrapper = double("Osaka::ApplicationWrapper").as_null_object}
52
46
 
53
47
  it "Should be able to set the mail merge dialog to merge to new document" do
54
48
  expect_click(at.pop_up_button(2).sheet(1))
@@ -7,17 +7,15 @@ describe "TextEdit" do
7
7
 
8
8
  subject { Osaka::TextEdit.new }
9
9
 
10
- before (:each) do
11
- @wrapper = subject.wrapper = double("Osaka::ApplicationWrapper")
12
- end
13
-
10
+ let(:wrapper) { subject.wrapper = double("Osaka::ApplicationWrapper") }
11
+
14
12
  it "Should be able to type some text" do
15
13
  expect_keystroke('Hello World')
16
14
  subject.type("Hello World")
17
15
  end
18
16
 
19
17
  it "Should be able to get the text from the document" do
20
- subject.wrapper.should_receive(:get!).with("value", 'text area 1 of scroll area 1').and_return("Hello")
18
+ expect_get!("value", 'text area 1 of scroll area 1').and_return("Hello")
21
19
  subject.text.should == "Hello"
22
20
  end
23
21
 
@@ -7,8 +7,9 @@ describe "Osaka::TypicalApplication" do
7
7
 
8
8
  subject { Osaka::TypicalApplication.new("ApplicationName") }
9
9
 
10
+ let(:wrapper) { subject.wrapper = double("Osaka::ApplicationWrapper") }
11
+
10
12
  before (:each) do
11
- @wrapper = subject.wrapper = double("Osaka::ApplicationWrapper")
12
13
  Osaka::ScriptRunner.enable_debug_prints
13
14
  end
14
15
 
@@ -99,7 +100,7 @@ describe "Osaka::TypicalApplication" do
99
100
  subject.should_receive(:duplicate_available?).and_return(true)
100
101
  subject.should_receive(:duplicate).and_return(new_instance)
101
102
  new_instance.should_receive(:wrapper).and_return(new_instance_wrapper)
102
- new_instance_wrapper.should_receive(:clone).and_return(@wrapper)
103
+ new_instance_wrapper.should_receive(:clone).and_return(wrapper)
103
104
 
104
105
  subject.should_receive(:close)
105
106
  subject.should_receive(:save_dialog).and_return(save_dialog)
@@ -123,7 +124,8 @@ describe "Osaka::TypicalApplication" do
123
124
  subject.should_receive(:do_and_wait_for_new_window).and_yield.and_return("duplicate window", "New name duplicate window")
124
125
  expect_keystroke("s", [:command, :shift])
125
126
  subject.should_receive(:clone).and_return(new_instance)
126
- new_instance.should_receive(:wrapper).and_return(@wrapper)
127
+ new_instance.should_receive(:wrapper).and_return(wrapper)
128
+ subject.should_receive(:sleep).with(0.4) # Avoiding Mountain Lion crash
127
129
  expect_keystroke!(:return)
128
130
  expect_set_current_window("New name duplicate window")
129
131
  subject.duplicate.should == new_instance
@@ -253,7 +255,7 @@ describe "Osaka::TypicalApplication" do
253
255
  end
254
256
 
255
257
  it "Should set the path when a full path is given" do
256
- @wrapper.as_null_object
258
+ wrapper.as_null_object
257
259
  subject.should_receive(:set_filename)
258
260
  subject.should_receive(:set_folder).with("/path/second")
259
261
  subject.save("/path/second/name")
@@ -266,7 +268,7 @@ describe "Osaka::TypicalApplication" do
266
268
  end
267
269
 
268
270
  it "Should be able to set the filename" do
269
- @wrapper.should_receive(:set).with('value', at.text_field(1).sheet(1), "filename")
271
+ wrapper.should_receive(:set).with('value', at.text_field(1).sheet(1), "filename")
270
272
  subject.set_filename("filename")
271
273
  end
272
274
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: osaka
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.1
5
+ version: 0.3.2
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-08-07 00:00:00 +08:00
13
+ date: 2012-08-13 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency