osaka 0.4.12 → 0.4.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b98f479a2e3a76f17e9727eacb616a4668126f06
4
- data.tar.gz: 2cc8d297e7bc54fa57120ba557988582ffc27874
3
+ metadata.gz: f35e5efb876b09d8cb875ab2a27f0e6b6f1a0fca
4
+ data.tar.gz: 9048faf743ba238257751678a6592acf4c49b2ea
5
5
  SHA512:
6
- metadata.gz: f269e4e1d5fbf49387ffe48a7adfec8881f221e13b73800d550b9da99809af18bbc1e401f281ede9b9462588e97f21407acd2b0a4c81318e8815e0e9f27380be
7
- data.tar.gz: f8ad1bf37387d5b294c7d86e39cd7aaf2e7fc104743abb1eb6c994d5a76d245a25228cfdabe4744b8c11f4436187161b67baa2f052da5e1a5750a4e6b513c641
6
+ metadata.gz: 9e7bd9f36d4bdc7492965cbdcb742fcac627fd7e091d6f614e1458ceae25ac3a14ced4a0a460b702a86808dca4d017811f269950d1a84d827f41ff98b4bf055f
7
+ data.tar.gz: ed0e9e6ee4310cd7ff794047d917cc2ddc307fb3e1140d35a76d15c7ed63ba5117b8a87a5682c550b225b7d469a85c07e134ddd2f4442ddaea35991dc2b0e710
@@ -132,5 +132,9 @@ module Osaka
132
132
  def expect_until_not_exists!(element)
133
133
  expect(control).to receive(:until_not_exists!).with(element).and_yield
134
134
  end
135
+
136
+ def expect_mac_version_before(version_name)
137
+ expect(control).to receive(:mac_version_before).with(version_name)
138
+ end
135
139
  end
136
140
  end
@@ -1,19 +1,23 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Osaka
4
-
4
+
5
5
  class Preview < TypicalApplication
6
-
6
+
7
7
  attr_accessor :control
8
-
8
+
9
9
  def initialize
10
10
  super "Preview"
11
11
  end
12
-
12
+
13
13
  def pdf_content
14
- control.get!("value", at.static_text(1).scroll_area(1).splitter_group(1))
14
+ if control.mac_version_before(:el_capitain)
15
+ control.get!("value", at.static_text(1).scroll_area(1).splitter_group(1))
16
+ else
17
+ control.get!("value", at.static_text(1).group(1).scroll_area(1).splitter_group(1))
18
+ end
15
19
  end
16
-
20
+
17
21
  def open(filename)
18
22
  control.click_menu_bar(at.menu_item("Open…"), "File").wait_until_exists(at.window("Open"))
19
23
  new_window = do_and_wait_for_new_window {
@@ -21,6 +25,6 @@ module Osaka
21
25
  }
22
26
  control.set_current_window(new_window)
23
27
  end
24
-
28
+
25
29
  end
26
30
  end
@@ -245,9 +245,8 @@ module Osaka
245
245
  @base_location.to_s.empty? || window_list.index(current_window_name).nil?
246
246
  end
247
247
 
248
- def mac_version
249
- @mac_version_string ||= Osaka::ScriptRunner.execute("system version of (system info)").strip
250
- @mac_version ||= case @mac_version_string
248
+ def mac_version_string_to_name(mac_version_string)
249
+ case mac_version_string
251
250
  when /^10.6.*/
252
251
  :snow_leopard
253
252
  when /^10.7.*/
@@ -256,15 +255,43 @@ module Osaka
256
255
  :mountain_lion
257
256
  when /^10.10.*/
258
257
  :yosemite
258
+ when /^10.11.*/
259
+ :el_capitain
259
260
  else
260
261
  :other
261
- end
262
+ end
263
+ end
264
+
265
+ def mac_version_name_to_number(mac_version_name)
266
+ case mac_version_name
267
+ when :snow_leopard
268
+ 10.6
269
+ when :lion
270
+ 10.7
271
+ when :mountain_lion
272
+ 10.8
273
+ when :yosemite
274
+ 10.10
275
+ when :el_capitain
276
+ 10.11
277
+ else
278
+ :other
279
+ end
280
+ end
281
+
282
+ def mac_version
283
+ mac_version_string_to_name(mac_version_string)
284
+ end
262
285
 
286
+ def mac_version_before(mac_version_name)
287
+ current_mac_version_string = Osaka::ScriptRunner.execute("system version of (system info)").strip
288
+ current_mac_version_number = mac_version_name_to_number(mac_version_string_to_name(current_mac_version_string))
289
+ before_mac_version_number = mac_version_name_to_number(mac_version_name)
290
+ current_mac_version_number < before_mac_version_number
263
291
  end
264
292
 
265
293
  def mac_version_string
266
- mac_version
267
- @mac_version_string
294
+ Osaka::ScriptRunner.execute("system version of (system info)").strip
268
295
  end
269
296
 
270
297
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Osaka
3
- VERSION = "0.4.12"
3
+ VERSION = "0.4.13"
4
4
  end
Binary file
@@ -2,9 +2,9 @@
2
2
  require 'osaka'
3
3
 
4
4
  describe "Wrapper around the defaults app which can be used for storing and retrieving preferences" do
5
-
5
+
6
6
  before (:each) do
7
- @worldclock_widget = <<-END_OF_DUMP
7
+ @worldclock_widget = <<-END_OF_DUMP
8
8
  {
9
9
  "0000000000000002-city" = 44;
10
10
  "0000000000000002-continent" = 1;
@@ -13,18 +13,18 @@ describe "Wrapper around the defaults app which can be used for storing and retr
13
13
  }
14
14
  END_OF_DUMP
15
15
  end
16
-
16
+
17
17
  it "Can retrieve the settings from a domain (A domain is usually an application)" do
18
18
  expect(Osaka::CommandRunner).to receive(:run).with("defaults read widget-com.apple.widget.worldclock").and_return(@worldclock_widget)
19
19
  settings = DefaultsSystem.new("widget-com.apple.widget.worldclock")
20
20
  expect(settings["city"]).to eq "44"
21
21
  end
22
-
22
+
23
23
  it "Can set settings on a domain" do
24
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)
25
+ expect(Osaka::CommandRunner).to receive(:run).with("defaults write com.osaka key value").and_return(@worldclock_widget)
26
26
  settings = DefaultsSystem.new("com.osaka")
27
27
  settings["key"] = "value"
28
28
  end
29
-
29
+
30
30
  end
@@ -7,9 +7,10 @@ describe "Integration tests for Preview", :integration => true do
7
7
  end
8
8
 
9
9
  it "Should be able to open a file and check if there is a certain text" do
10
+ Osaka::ScriptRunner::enable_debug_prints
10
11
  preview = Osaka::Preview.new
11
12
  preview.open(File.join(@assets_directory, "document.pdf"))
12
- expect(preview.pdf_content).to include("Jamaica")
13
+ expect(preview.pdf_content).to include("Hungary")
13
14
  preview.close
14
15
  preview.quit
15
16
  end
@@ -2,26 +2,32 @@
2
2
  require 'osaka'
3
3
 
4
4
  describe "Preview application for reading PDFs" do
5
-
5
+
6
6
  include(*Osaka::OsakaExpectations)
7
7
 
8
8
  subject { Osaka::Preview.new }
9
9
  let(:control) { subject.control = double("RemoteControl", :mac_version => :mountain_lion)}
10
10
 
11
- it "Can get the text context of a PDF document" do
11
+ it "Can get the text context of a PDF document (pre el capitain)" do
12
+ expect_mac_version_before(:el_capitain).and_return(true)
12
13
  expect_get!("value", at.static_text(1).scroll_area(1).splitter_group(1)).and_return("Blah")
13
14
  expect(subject.pdf_content).to eq "Blah"
14
15
  end
15
-
16
+
17
+ it "Can get the text context of a PDF document (post el capitain)" do
18
+ expect_mac_version_before(:el_capitain).and_return(false)
19
+ expect_get!("value", at.static_text(1).group(1).scroll_area(1).splitter_group(1)).and_return("Blah")
20
+ expect(subject.pdf_content).to eq "Blah"
21
+ end
22
+
16
23
  it "Can open a PDF file via the menu instead of the AppleScript 'open' as that one is buggy" do
17
-
18
24
  expect_click_menu_bar(at.menu_item("Open…"), "File")
19
25
  expect_wait_until_exists(at.window("Open"))
20
- expect(subject).to receive(:do_and_wait_for_new_window).and_yield.and_return("window name")
26
+ expect(subject).to receive(:do_and_wait_for_new_window).and_yield.and_return("window name")
21
27
  expect(subject).to receive(:select_file_from_open_dialog).with("dir/filename", at.window("Open"))
22
28
  expect_set_current_window("window name")
23
29
 
24
30
  subject.open("dir/filename")
25
31
  end
26
-
32
+
27
33
  end
@@ -38,6 +38,10 @@ describe "Osaka::RemoteControl" do
38
38
  it "Can get the OS version (lion)" do
39
39
  expect_execute_osascript("system version of (system info)").and_return("10.7.4\n")
40
40
  expect(subject.mac_version).to eq :lion
41
+ end
42
+
43
+ it "Can get the OS version (lion) string" do
44
+ expect_execute_osascript("system version of (system info)").and_return("10.7.4\n")
41
45
  expect(subject.mac_version_string).to eq "10.7.4"
42
46
  end
43
47
 
@@ -51,10 +55,25 @@ describe "Osaka::RemoteControl" do
51
55
  expect(subject.mac_version).to eq :snow_leopard
52
56
  end
53
57
 
54
- it "Can get the OS version (snow leopard)" do
58
+ it "Can get the OS version (el capitain)" do
59
+ expect_execute_osascript("system version of (system info)").and_return("10.11\n")
60
+ expect(subject.mac_version).to eq :el_capitain
61
+ end
62
+
63
+ it "Can get the OS version (other)" do
55
64
  expect_execute_osascript("system version of (system info)").and_return("1\n")
56
65
  expect(subject.mac_version).to eq :other
57
66
  end
67
+
68
+ it "OSVersion in before a certain version" do
69
+ expect_execute_osascript("system version of (system info)").and_return("10.10\n")
70
+ expect(subject.mac_version_before(:el_capitain)).to eq true
71
+ end
72
+
73
+ it "OSVersion in before a certain version" do
74
+ expect_execute_osascript("system version of (system info)").and_return("10.11\n")
75
+ expect(subject.mac_version_before(:el_capitain)).to eq false
76
+ end
58
77
  end
59
78
 
60
79
  context "Able to compare different remote controls" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osaka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.12
4
+ version: 0.4.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bas Vodde
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2016-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake