diff options
| author | Josh Hagins | 2016-10-23 21:41:35 -0400 |
|---|---|---|
| committer | GitHub | 2016-10-23 21:41:35 -0400 |
| commit | 5d1412aba156408bba4134ebb3e2eb8af7efacfc (patch) | |
| tree | e370b3efc351d48911a96a2c8f7e768e68201d2a | |
| parent | fcaa042736df01036ff116a4cc45520f1c958d8f (diff) | |
| parent | b8ec62bf25de7b90fe5461a1d537e33c62aac204 (diff) | |
| download | brew-5d1412aba156408bba4134ebb3e2eb8af7efacfc.tar.bz2 | |
Merge pull request #1357 from reitermarkus/refactor-accessibility-test
Refactor accessibility test.
| -rw-r--r-- | Library/Homebrew/cask/test/cask/accessibility_test.rb | 98 |
1 files changed, 50 insertions, 48 deletions
diff --git a/Library/Homebrew/cask/test/cask/accessibility_test.rb b/Library/Homebrew/cask/test/cask/accessibility_test.rb index 8da8937fe..7c6484dd4 100644 --- a/Library/Homebrew/cask/test/cask/accessibility_test.rb +++ b/Library/Homebrew/cask/test/cask/accessibility_test.rb @@ -3,73 +3,75 @@ require "test_helper" # TODO: this test should be named after the corresponding class, once # that class is abstracted from installer.rb. describe "Accessibility Access" do - before do - cask = Hbc.load("with-accessibility-access") - with_fake_command = { command: Hbc::FakeSystemCommand } - @installer = Hbc::Installer.new(cask, with_fake_command) - end + let(:cask) { Hbc.load("with-accessibility-access") } + let(:with_fake_command) { { command: Hbc::FakeSystemCommand } } + let(:installer) { Hbc::Installer.new(cask, with_fake_command) } describe "install" do it "can enable accessibility access" do - MacOS.stubs(version: MacOS::Version.new("10.9")) - - @installer.stubs(bundle_identifier: "com.example.BasicCask") - - Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "--", "/usr/bin/sqlite3", Hbc.tcc_db, "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);"] - ) - shutup do - @installer.enable_accessibility_access + MacOS.stub :version, MacOS::Version.new("10.9") do + installer.stub :bundle_identifier, "com.example.BasicCask" do + Hbc::FakeSystemCommand.expects_command( + ["/usr/bin/sudo", "-E", "--", "/usr/bin/sqlite3", Hbc.tcc_db, "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);"] + ) + shutup do + installer.enable_accessibility_access + end + end end end - it "can enable accessibility access in macOS releases prior to Mavericks" do - MacOS.stubs(version: MacOS::Version.new("10.8")) - Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "--", "/usr/bin/touch", Hbc.pre_mavericks_accessibility_dotfile] - ) - shutup do - @installer.enable_accessibility_access + it "can enable accessibility access in macOS releases prior to Mavericks" do + MacOS.stub :version, MacOS::Version.new("10.8") do + Hbc::FakeSystemCommand.expects_command( + ["/usr/bin/sudo", "-E", "--", "/usr/bin/touch", Hbc.pre_mavericks_accessibility_dotfile] + ) + shutup do + installer.enable_accessibility_access + end end end - it "warns about enabling accessibility access on new macOS releases" do - MacOS.stubs(version: MacOS::Version.new("10.12")) - - @installer.stubs(bundle_identifier: "com.example.BasicCask") - capture_io { @installer.enable_accessibility_access }[1] - .must_match("Warning: Accessibility access cannot be enabled automatically on this version of macOS.") + it "warns about enabling accessibility access on new macOS releases" do + MacOS.stub :version, MacOS::Version.new("10.12") do + installer.stub :bundle_identifier, "com.example.BasicCask" do + capture_io { installer.enable_accessibility_access }[1] + .must_match("Warning: Accessibility access cannot be enabled automatically on this version of macOS.") + end + end end end describe "uninstall" do it "can disable accessibility access" do - MacOS.stubs(version: MacOS::Version.new("10.9")) - - @installer.stubs(bundle_identifier: "com.example.BasicCask") - - Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "--", "/usr/bin/sqlite3", Hbc.tcc_db, "DELETE FROM access WHERE client='com.example.BasicCask';"] - ) - shutup do - @installer.disable_accessibility_access + MacOS.stub :version, MacOS::Version.new("10.9") do + installer.stub :bundle_identifier, "com.example.BasicCask" do + Hbc::FakeSystemCommand.expects_command( + ["/usr/bin/sudo", "-E", "--", "/usr/bin/sqlite3", Hbc.tcc_db, "DELETE FROM access WHERE client='com.example.BasicCask';"] + ) + shutup do + installer.disable_accessibility_access + end + end end end - it "warns about disabling accessibility access on old macOS releases" do - MacOS.stubs(version: MacOS::Version.new("10.8")) - - @installer.stubs(bundle_identifier: "com.example.BasicCask") - capture_io { @installer.disable_accessibility_access }[1] - .must_match("Warning: Accessibility access cannot be disabled automatically on this version of macOS.") + it "warns about disabling accessibility access on old macOS releases" do + MacOS.stub :version, MacOS::Version.new("10.8") do + installer.stub :bundle_identifier, "com.example.BasicCask" do + capture_io { installer.disable_accessibility_access }[1] + .must_match("Warning: Accessibility access cannot be disabled automatically on this version of macOS.") + end + end end - it "warns about disabling accessibility access on new macOS releases" do - MacOS.stubs(version: MacOS::Version.new("10.12")) - - @installer.stubs(bundle_identifier: "com.example.BasicCask") - capture_io { @installer.disable_accessibility_access }[1] - .must_match("Warning: Accessibility access cannot be disabled automatically on this version of macOS.") + it "warns about disabling accessibility access on new macOS releases" do + MacOS.stub :version, MacOS::Version.new("10.12") do + installer.stub :bundle_identifier, "com.example.BasicCask" do + capture_io { installer.disable_accessibility_access }[1] + .must_match("Warning: Accessibility access cannot be disabled automatically on this version of macOS.") + end + end end end end |
