osaka 0.4.8 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.rdoc +1 -1
  4. data/Rakefile +12 -2
  5. data/lib/osaka.rb +6 -0
  6. data/lib/osaka/calculator.rb +1 -1
  7. data/lib/osaka/commandrunner.rb +17 -0
  8. data/lib/osaka/defaultssystem.rb +28 -0
  9. data/lib/osaka/keynote.rb +8 -6
  10. data/lib/osaka/keynoteflow.rb +10 -2
  11. data/lib/osaka/launchservices.rb +29 -0
  12. data/lib/osaka/location.rb +1 -1
  13. data/lib/osaka/mailmergeflow.rb +1 -1
  14. data/lib/osaka/numbers.rb +1 -1
  15. data/lib/osaka/osakaexpectations.rb +65 -61
  16. data/lib/osaka/pages.rb +35 -26
  17. data/lib/osaka/preview.rb +1 -1
  18. data/lib/osaka/remotecontrol.rb +57 -47
  19. data/lib/osaka/scriptrunner.rb +2 -11
  20. data/lib/osaka/textedit.rb +1 -1
  21. data/lib/osaka/typicalapplication.rb +10 -4
  22. data/lib/osaka/typicalfinderdialog.rb +1 -1
  23. data/lib/osaka/typicalopendialog.rb +22 -18
  24. data/lib/osaka/typicalprintdialog.rb +1 -1
  25. data/lib/osaka/typicalsavedialog.rb +1 -1
  26. data/lib/osaka/version.rb +1 -1
  27. data/{osaka.gemfile → osaka.gemspec} +0 -0
  28. data/spec/assets/document.pdf +0 -0
  29. data/spec/calculator_spec.rb +5 -5
  30. data/spec/defaultssystem_spec.rb +30 -0
  31. data/spec/integration_calculator_spec.rb +7 -7
  32. data/spec/integration_keynote_spec.rb +24 -11
  33. data/spec/integration_numbers_spec.rb +2 -2
  34. data/spec/integration_pages_numbers_mail_merge_spec.rb +9 -9
  35. data/spec/integration_preview_spec.rb +16 -0
  36. data/spec/integration_textedit_spec.rb +5 -5
  37. data/spec/keynote_flows_spec.rb +52 -31
  38. data/spec/keynote_spec.rb +24 -14
  39. data/spec/launchservices_spec.rb +63 -0
  40. data/spec/location_spec.rb +13 -13
  41. data/spec/mailmergeflow_spec.rb +13 -13
  42. data/spec/numbers_spec.rb +10 -10
  43. data/spec/osakaexpectations_spec.rb +3 -3
  44. data/spec/pages_spec.rb +80 -61
  45. data/spec/preview_spec.rb +5 -5
  46. data/spec/remotecontrol_spec.rb +65 -43
  47. data/spec/scriptrunner_spec.rb +22 -22
  48. data/spec/textedit_spec.rb +3 -3
  49. data/spec/typicalapplication_spec.rb +119 -108
  50. data/spec/typicalfinderdialog_spec.rb +2 -2
  51. data/spec/typicalopendialog_spec.rb +41 -35
  52. data/spec/typicalprintdialog_spec.rb +5 -5
  53. data/spec/typicalsavedialog_spec.rb +10 -10
  54. metadata +51 -47
@@ -29,4 +29,4 @@ module Osaka
29
29
  end
30
30
  end
31
31
 
32
- end
32
+ end
@@ -19,4 +19,4 @@ module Osaka
19
19
 
20
20
  end
21
21
 
22
- end
22
+ end
data/lib/osaka/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Osaka
3
- VERSION = "0.4.8"
3
+ VERSION = "0.4.10"
4
4
  end
File without changes
Binary file
@@ -6,13 +6,13 @@ describe "Mac GUI Calculator" do
6
6
  include(*Osaka::OsakaExpectations)
7
7
 
8
8
  subject { Osaka::Calculator.new }
9
- let(:control) { subject.control = mock("RemoteControl", :mac_version => :mountain_lion)}
10
-
9
+ let(:control) { subject.control = double("RemoteControl", :mac_version => :mountain_lion)}
10
+
11
11
  it "Should be setting the window when starting the Calculator" do
12
12
 
13
13
  expect_activate
14
14
  expect_current_window_name.and_return("")
15
- subject.should_receive(:wait_for_new_window).with([])
15
+ expect(subject).to receive(:wait_for_new_window).with([])
16
16
  expect_window_list.and_return(["Calculator"])
17
17
  expect_set_current_window("Calculator")
18
18
  subject.activate
@@ -37,7 +37,7 @@ describe "Mac GUI Calculator" do
37
37
  it "Should be able to get the value from the screen" do
38
38
  expect_wait_until_exists!(at.static_text(1).group(1))
39
39
  expect_get!("value", at.static_text(1).group(1)).and_return("0")
40
- subject.result.should == "0"
40
+ expect(subject.result).to eq "0"
41
41
  end
42
42
 
43
- end
43
+ end
@@ -0,0 +1,30 @@
1
+
2
+ require 'osaka'
3
+
4
+ describe "Wrapper around the defaults app which can be used for storing and retrieving preferences" do
5
+
6
+ before (:each) do
7
+ @worldclock_widget = <<-END_OF_DUMP
8
+ {
9
+ "0000000000000002-city" = 44;
10
+ "0000000000000002-continent" = 1;
11
+ city = 44;
12
+ continent = 1;
13
+ }
14
+ END_OF_DUMP
15
+ end
16
+
17
+ it "Can retrieve the settings from a domain (A domain is usually an application)" do
18
+ expect(Osaka::CommandRunner).to receive(:run).with("defaults read widget-com.apple.widget.worldclock").and_return(@worldclock_widget)
19
+ settings = DefaultsSystem.new("widget-com.apple.widget.worldclock")
20
+ expect(settings["city"]).to eq "44"
21
+ end
22
+
23
+ it "Can set settings on a domain" do
24
+ expect(Osaka::CommandRunner).to receive(:run).with("defaults read com.osaka").and_return(@worldclock_widget)
25
+ expect(Osaka::CommandRunner).to receive(:run).with("defaults write com.osaka key value").and_return(@worldclock_widget)
26
+ settings = DefaultsSystem.new("com.osaka")
27
+ settings["key"] = "value"
28
+ end
29
+
30
+ end
@@ -1,7 +1,7 @@
1
1
 
2
2
  require 'osaka'
3
3
 
4
- describe "Integration test using the Calculator" do
4
+ describe "Integration test using the Calculator", :integration => true do
5
5
 
6
6
  subject { Osaka::Calculator.new }
7
7
 
@@ -22,20 +22,20 @@ describe "Integration test using the Calculator" do
22
22
  subject.click("+")
23
23
  subject.click("1")
24
24
  subject.click("=")
25
- subject.result.should == "2"
25
+ expect(subject.result).to eq "2"
26
26
  end
27
27
 
28
28
  it "Should be able to do calculations using keyboard" do
29
29
  subject.key("10")
30
30
  subject.key("*")
31
31
  subject.key("10")
32
- subject.key("=")
33
- subject.result.should == "100"
32
+ subject.key("+")
33
+ expect(subject.result).to eq "100"
34
34
  end
35
35
 
36
36
  it "Should do whole formulas using key" do
37
- subject.key("100+10*3+99=")
38
- subject.result.should == "229"
37
+ subject.key("100+10*3+99+")
38
+ expect(subject.result).to eq "229"
39
39
  end
40
40
 
41
- end
41
+ end
@@ -1,29 +1,42 @@
1
1
  require 'tmpdir'
2
2
  require 'osaka'
3
3
 
4
- describe "Integration tests for Keynote and Common Flows" do
5
-
6
- it "Should be able to do a combine with just one file" do
4
+ describe "Integration tests for Keynote and Common Flows", :integration => true do
5
+
6
+ before(:each) do
7
+ @assets_directory = File.join(File.dirname(__FILE__), "assets")
8
+ end
7
9
 
8
- assets_directory = File.join(File.dirname(__FILE__), "assets")
10
+ it "Should be able to do a combine with just one file" do
9
11
 
10
- keynote_file = File.join(assets_directory, "01_first_slides.key")
12
+ keynote_file = File.join(@assets_directory, "01_first_slides.key")
11
13
  Dir.mktmpdir { |dir|
12
14
  results_file = File.join(dir, "results.key")
13
15
  CommonFlows.keynote_combine_files(results_file, keynote_file)
14
- File.exists?(results_file).should == true
16
+ expect(File.exists?(results_file)).to eq true
15
17
  }
16
18
  end
17
19
 
18
20
  it "Should be able to combine multiple files" do
19
- assets_directory = File.join(File.dirname(__FILE__), "assets")
20
21
 
21
22
  Dir.mktmpdir { |dir|
22
23
  results_file = File.join(dir, "results.key")
23
- CommonFlows.keynote_combine_files_from_directory_sorted(results_file, assets_directory)
24
- File.exists?(results_file).should == true
25
- }
24
+ CommonFlows.keynote_combine_files_from_directory_sorted(results_file, @assets_directory)
25
+ expect(File.exists?(results_file)).to eq true
26
+ }
27
+ end
28
+
29
+ it "Should exit with message if files are open" do
26
30
 
31
+ keynote_file = File.join(@assets_directory, "01_first_slides.key")
32
+ keynote = Osaka::Keynote.new
33
+ keynote.open(keynote_file)
34
+
35
+ expect {
36
+ CommonFlows.keynote_combine_files(nil, keynote_file)
37
+ }.to raise_error(Osaka::ApplicationWindowsMustBeClosed, "All Keynote windows must be closed before running this flow")
38
+
39
+ keynote.close
27
40
  end
28
41
 
29
- end
42
+ end
@@ -3,7 +3,7 @@ require 'osaka'
3
3
 
4
4
  describe "Integration tests for Numbers" do
5
5
 
6
- it "Should be able to fill in large index cells" do
6
+ it "Should be able to fill in large index cells", :integration => true do
7
7
 
8
8
  Dir.mktmpdir { |dir|
9
9
 
@@ -14,4 +14,4 @@ describe "Integration tests for Numbers" do
14
14
 
15
15
  end
16
16
 
17
- end
17
+ end
@@ -1,7 +1,7 @@
1
1
  require 'tmpdir'
2
2
  require 'osaka'
3
3
 
4
- describe "Integration of mail merge flow with Pages and Numbers" do
4
+ describe "Integration of mail merge flow with Pages and Numbers", :integration => true do
5
5
 
6
6
 
7
7
  before (:each) do
@@ -10,11 +10,11 @@ describe "Integration of mail merge flow with Pages and Numbers" do
10
10
  @pages_template_filename = File.join(@tempdir, "mail_merge_template.pages")
11
11
  @pdf_output_file = File.join(@tempdir, "output.pdf")
12
12
  end
13
-
13
+
14
14
  after (:each) do
15
15
  FileUtils.remove_entry_secure @tempdir
16
16
  end
17
-
17
+
18
18
  it "Should mail merge the assets and generate a PDF" do
19
19
 
20
20
  Osaka::Numbers.create_document(@numbers_filename) { |doc|
@@ -23,19 +23,19 @@ describe "Integration of mail merge flow with Pages and Numbers" do
23
23
  doc.fill_cell(2, 3, "of Data")
24
24
  doc.fill_cell(2, 4, "in Numbers")
25
25
  }
26
-
26
+
27
27
  Osaka::Pages.create_document(@pages_template_filename) { |doc|
28
28
  doc.set_mail_merge_document(@numbers_filename)
29
- doc.type("Hello World! This is pages. We're going to mail merge!\r\r")
29
+ doc.type("Hello World! This is pages. We're going to mail merge!\r\r")
30
30
  doc.mail_merge_field("Data");
31
31
  }
32
-
32
+
33
33
  CommonFlows::number_and_pages_mail_merge(@numbers_filename, @pages_template_filename, @pdf_output_file)
34
- File.exists?(@pdf_output_file).should == true
35
-
34
+ expect(File.exists?(@pdf_output_file)).to eq true
35
+
36
36
  preview = Osaka::Preview.new
37
37
  preview.open(@pdf_output_file)
38
- preview.pdf_content.should include("Hello World")
38
+ expect(preview.pdf_content).to include("Hello World")
39
39
  preview.close
40
40
  preview.quit
41
41
  end
@@ -0,0 +1,16 @@
1
+ require 'osaka'
2
+
3
+ describe "Integration tests for Preview", :integration => true do
4
+
5
+ before(:each) do
6
+ @assets_directory = File.join(File.dirname(__FILE__), "assets")
7
+ end
8
+
9
+ it "Should be able to open a file and check if there is a certain text" do
10
+ preview = Osaka::Preview.new
11
+ preview.open(File.join(@assets_directory, "document.pdf"))
12
+ expect(preview.pdf_content).to include("Jamaica")
13
+ preview.close
14
+ preview.quit
15
+ end
16
+ end
@@ -1,7 +1,7 @@
1
1
 
2
2
  require 'osaka'
3
3
 
4
- describe "Integration test using TextEdit" do
4
+ describe "Integration test using TextEdit", :integration => true do
5
5
 
6
6
  subject { Osaka::TextEdit.new }
7
7
 
@@ -18,7 +18,7 @@ describe "Integration test using TextEdit" do
18
18
  it "can type in the window" do
19
19
  subject.new_document
20
20
  subject.type("Hello World")
21
- subject.text.should == "Hello World"
21
+ expect(subject.text).to eq "Hello World"
22
22
  subject.close(:dont_save)
23
23
  end
24
24
 
@@ -32,11 +32,11 @@ describe "Integration test using TextEdit" do
32
32
  editor1.type("Typing in window 1")
33
33
  editor2.type("Typing in window 2")
34
34
 
35
- editor1.text.should == "Typing in window 1"
36
- editor2.text.should == "Typing in window 2"
35
+ expect(editor1.text).to eq "Typing in window 1"
36
+ expect(editor2.text).to eq "Typing in window 2"
37
37
 
38
38
  editor1.close(:dont_save)
39
39
  editor2.close(:dont_save)
40
40
  end
41
41
 
42
- end
42
+ end
@@ -2,59 +2,80 @@
2
2
  require "osaka"
3
3
 
4
4
  describe "Common flows in keynote" do
5
+
6
+ def should_shutdown
7
+ expect(mock_keynote).to receive(:save)
8
+ expect(mock_keynote).to receive(:close)
9
+ expect(mock_keynote).to receive(:quit)
10
+ end
5
11
 
6
- let(:mock_keynote) { mock("First keynote")}
12
+ let(:mock_keynote) { double("First keynote")}
7
13
 
14
+ it "Should exit if keynote windows are already open" do
15
+ expect(Osaka::Keynote).to receive(:new).and_return(mock_keynote)
16
+ expect(mock_keynote).to receive(:activate)
17
+ expect(mock_keynote).to receive(:raise_error_on_open_standard_windows)
18
+ .with("All Keynote windows must be closed before running this flow")
19
+ .and_raise(Osaka::ApplicationWindowsMustBeClosed, "All Keynote windows must be closed before running this flow")
20
+
21
+ expect {
22
+ CommonFlows.keynote_combine_files("result.key", "one_file.key")
23
+ }.to raise_error(Osaka::ApplicationWindowsMustBeClosed, "All Keynote windows must be closed before running this flow")
24
+ end
25
+
8
26
  it "Should be able to combine just one single file" do
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)
27
+ expect(Osaka::Keynote).to receive(:new).and_return(mock_keynote)
28
+ expect(mock_keynote).to receive(:activate)
29
+ expect(mock_keynote).to receive(:raise_error_on_open_standard_windows)
30
+ expect(mock_keynote).to receive(:light_table_view)
31
+ expect(mock_keynote).to receive(:open).with("one_file.key")
32
+ expect(mock_keynote).to receive(:save_as).with("result.key")
33
+ should_shutdown
14
34
  CommonFlows.keynote_combine_files("result.key", "one_file.key")
15
35
  end
16
36
 
17
37
  it "Should be able to combine multiple files in one result" do
18
- mock2_keynote = mock("Second keynote")
19
- mock3_keynote = mock("Third keynote")
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)
38
+ mock2_keynote = double("Second keynote")
39
+ mock3_keynote = double("Third keynote")
40
+ expect(Osaka::Keynote).to receive(:new).and_return(mock_keynote, mock2_keynote, mock3_keynote)
41
+ expect(mock_keynote).to receive(:activate)
42
+ expect(mock_keynote).to receive(:raise_error_on_open_standard_windows)
43
+ expect(mock_keynote).to receive(:open).with("one_file.key")
44
+ expect(mock_keynote).to receive(:light_table_view)
45
+ expect(mock_keynote).to receive(:save_as).with("result.key")
46
+ expect(mock_keynote).to receive(:select_all_slides).exactly(2).times
47
+ expect(mock_keynote).to receive(:paste).exactly(2).times
26
48
 
27
-
28
- mock2_keynote.should_receive(:open).with("two_file.key")
29
- mock2_keynote.should_receive(:select_all_slides)
30
- mock2_keynote.should_receive(:copy)
31
- mock2_keynote.should_receive(:close)
49
+ expect(mock2_keynote).to receive(:open).with("two_file.key")
50
+ expect(mock2_keynote).to receive(:select_all_slides)
51
+ expect(mock2_keynote).to receive(:copy)
52
+ expect(mock2_keynote).to receive(:close)
32
53
 
33
- mock3_keynote.should_receive(:open).with("three_file.key")
34
- mock3_keynote.should_receive(:select_all_slides)
35
- mock3_keynote.should_receive(:copy)
36
- mock3_keynote.should_receive(:close)
54
+ expect(mock3_keynote).to receive(:open).with("three_file.key")
55
+ expect(mock3_keynote).to receive(:select_all_slides)
56
+ expect(mock3_keynote).to receive(:copy)
57
+ expect(mock3_keynote).to receive(:close)
37
58
 
38
- mock_keynote.should_receive(:quit)
59
+ should_shutdown
39
60
  CommonFlows.keynote_combine_files("result.key", ["one_file.key", "two_file.key", "three_file.key"])
40
61
  end
41
62
 
42
63
  it "Should be able to combine multiple files from one directory sorted" do
43
64
  files_in_dir = [".", "..", "one.key", "05_file.key", "02key.wrong", "another", "01hey.key", "last"]
44
65
  files_matching = ["./05_file.key", "./01hey.key", "./one.key"]
45
- Dir.should_receive(:new).with(".").and_return(files_in_dir)
46
- CommonFlows.should_receive(:keynote_combine_files).with("results.key", files_matching.sort)
66
+ expect(Dir).to receive(:new).with(".").and_return(files_in_dir)
67
+ expect(CommonFlows).to receive(:keynote_combine_files).with("results.key", files_matching.sort)
47
68
  CommonFlows.keynote_combine_files_from_directory_sorted("results.key")
48
69
  end
49
70
 
50
71
  it "Should be able to combine multiple files from one directory sorted with pattern" do
51
72
  files_in_dir = [".", "..", "05_file.key", "02key.wrong", "another", "01hey.key", "last"]
52
73
  files_in_dir_to_be_used = ["dirname/01hey.key", "dirname/05_file.key"]
53
- mocked_dir = mock("Directory with keynote files")
54
- Dir.should_receive(:new).with("dirname").and_return(mocked_dir)
55
- mocked_dir.should_receive(:entries).and_return(files_in_dir)
56
- CommonFlows.should_receive(:keynote_combine_files).with("results.key", files_in_dir_to_be_used)
74
+ mocked_dir = double("Directory with keynote files")
75
+ expect(Dir).to receive(:new).with("dirname").and_return(mocked_dir)
76
+ expect(mocked_dir).to receive(:entries).and_return(files_in_dir)
77
+ expect(CommonFlows).to receive(:keynote_combine_files).with("results.key", files_in_dir_to_be_used)
57
78
  CommonFlows.keynote_combine_files_from_directory_sorted("results.key", "dirname", /^\d+.*\.key$/)
58
79
  end
59
80
 
60
- end
81
+ end
data/spec/keynote_spec.rb CHANGED
@@ -6,28 +6,38 @@ describe "Osaka::Keynote" do
6
6
  include(*Osaka::OsakaExpectations)
7
7
 
8
8
  subject { Osaka::Keynote.new }
9
- let(:control) {subject.control = mock("RemoteControl").as_null_object}
9
+ let(:control) {subject.control = double("RemoteControl")}
10
10
 
11
11
  it "Should create the correct keynote print dialog" do
12
- subject.create_print_dialog("window").should be_instance_of Osaka::KeynotePrintDialog
12
+ expect(subject.create_print_dialog("window")).to be_instance_of Osaka::KeynotePrintDialog
13
13
  end
14
14
 
15
- it "Should be possible to select all the slides in the default location" do
16
- slides_button_location = at.button("Slides").group(1).outline(1).scroll_area(2).splitter_group(1).splitter_group(1)
17
- expect_exists?(slides_button_location).and_return(true)
18
- expect_click(slides_button_location)
19
- subject.should_receive(:select_all)
15
+ it "Should be possible to select all the slides by switching to light table view" do
16
+ expect(subject).to receive(:light_table_view)
17
+ expect(subject).to receive(:select_all)
20
18
  subject.select_all_slides
21
19
  end
22
-
23
- it "Should be possible to select all the slides in the alternative location" do
24
- slides_button_location = at.button("Slides").group(1).outline(1).scroll_area(2).splitter_group(1).splitter_group(1)
25
- alternative_slides_button_location = at.button("Slides").group(1).outline(1).scroll_area(1).splitter_group(1).splitter_group(1)
26
- expect_exists?(slides_button_location).and_return(false)
27
- expect_click(alternative_slides_button_location)
28
- subject.should_receive(:select_all)
20
+
21
+ it "Should click light table view when the dialog is there" do
22
+ expect(subject.control).to receive(:exists?).and_return(true)
23
+ expect(subject.control).to receive(:click)
24
+ expect(subject).to receive(:select_all)
29
25
  subject.select_all_slides
30
26
  end
31
27
 
28
+ it "Should not click the dialog when it is not there" do
29
+ expect(subject.control).to receive(:exists?).and_return(false)
30
+ expect(subject.control).to receive(:click).exactly(0).times
31
+ expect(subject).to receive(:select_all)
32
+ subject.select_all_slides
33
+ end
34
+
35
+ it "Should ask for and click the light table view menu" do
36
+ light_table_view_selection = at.menu_item("Light Table").menu(1).menu_bar_item("View").menu_bar(1)
37
+ expect_exists?(light_table_view_selection).and_return(true)
38
+ expect_click(light_table_view_selection)
39
+ expect(subject).to receive(:select_all)
40
+ subject.select_all_slides
41
+ end
32
42
 
33
43
  end