aboutsummaryrefslogtreecommitdiffstats
path: root/Framework/MASShortcutBinderTests.m
diff options
context:
space:
mode:
authorTomáš Znamenáček2015-03-05 14:32:51 +0100
committerTomáš Znamenáček2015-03-05 14:32:51 +0100
commit7bbaed62276c60c2e83b35b4329f795149be27fc (patch)
tree63cd4a75013325647c23f517362e4e574d45720b /Framework/MASShortcutBinderTests.m
parentfdc43c1cd33fa0f7c0251268055ad9a7812249d1 (diff)
downloadMASShortcut-7bbaed62276c60c2e83b35b4329f795149be27fc.tar.bz2
Removed support for dots and spaces in user defaults keys (#64).
I could find no way to make the feature work, so I have pulled it from the code. I have also inserted asserts to warn library users who would attempt to use illegal characters in user defaults keys in the future. In short, you want your user defaults keys to be something identifier-like.
Diffstat (limited to 'Framework/MASShortcutBinderTests.m')
-rw-r--r--Framework/MASShortcutBinderTests.m21
1 files changed, 6 insertions, 15 deletions
diff --git a/Framework/MASShortcutBinderTests.m b/Framework/MASShortcutBinderTests.m
index 35542d4..ab8383e 100644
--- a/Framework/MASShortcutBinderTests.m
+++ b/Framework/MASShortcutBinderTests.m
@@ -95,22 +95,13 @@ static NSString *const SampleDefaultsKey = @"sampleShortcut";
@"Bind shortcut using a default value.");
}
-// The connection between user defaults and shortcuts is implemented
-// using Cocoa Bindings where the dot symbol (“.”) has a special meaning.
-// This means we have to escape the dot symbol used in defaults keys,
-// otherwise things blow up. Details at <http://git.io/x5YS>.
-- (void) testBindingsWithDotSymbol
+// See issue #64 <http://git.io/x5YS> for rationale and discussion.
+- (void) testIllegalSymbolsInBindingNames
{
- static NSString *const SampleDefaultsKeyWithDotSymbol = @"sample.Shortcut";
- MASShortcut *shortcut = [MASShortcut shortcutWithKeyCode:1 modifierFlags:1];
- XCTAssertNoThrow([_binder bindShortcutWithDefaultsKey:SampleDefaultsKeyWithDotSymbol toAction:^{}],
- @"Binding a shortcut to a defaults key with a dot symbol must not throw.");
- [_defaults setObject:[NSKeyedArchiver archivedDataWithRootObject:shortcut] forKey:SampleDefaultsKeyWithDotSymbol];
- XCTAssertTrue([_monitor isShortcutRegistered:shortcut],
- @"Read a shortcut value using a defaults key with a dot symbol.");
- [_binder breakBindingWithDefaultsKey:SampleDefaultsKeyWithDotSymbol];
- XCTAssertFalse([_monitor isShortcutRegistered:shortcut],
- @"Breaking a binding with a dot symbol.");
+ XCTAssertThrows([_binder bindShortcutWithDefaultsKey:@"foo.bar" toAction:^{}],
+ @"Throw for illegal binding symbols: a dot (“.”).");
+ XCTAssertThrows([_binder bindShortcutWithDefaultsKey:@"foo bar" toAction:^{}],
+ @"Throw for illegal binding symbols: a space (“ ”).");
}
@end