LittleWeasel 1.0.2 → 1.1.0

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.
data/.idea/.rakeTasks CHANGED
@@ -4,4 +4,4 @@ You are allowed to:
4
4
  1. Remove rake task
5
5
  2. Add existing rake tasks
6
6
  To add existing rake tasks automatically delete this file and reload the project.
7
- --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build LittleWeasel-1.0.1.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install LittleWeasel-1.0.1.gem into system gems" fullCmd="install" taksId="install" /><RakeTask description="Create tag v1.0.1 and build and push LittleWeasel-1.0.1.gem to Rubygems" fullCmd="release" taksId="release" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /></RakeGroup></Settings>
7
+ --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build LittleWeasel-1.1.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install LittleWeasel-1.1.0.gem into system gems" fullCmd="install" taksId="install" /><RakeTask description="Create tag v1.1.0 and build and push LittleWeasel-1.1.0.gem to Rubygems" fullCmd="release" taksId="release" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /></RakeGroup></Settings>
data/.idea/workspace.xml CHANGED
@@ -4,14 +4,18 @@
4
4
  <list default="true" id="34d4ec05-51d8-442a-84a5-75b5005cedf0" name="Default" comment="">
5
5
  <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/.rakeTasks" afterPath="$PROJECT_DIR$/.idea/.rakeTasks" />
6
6
  <change type="MODIFICATION" beforePath="$PROJECT_DIR$/Gemfile" afterPath="$PROJECT_DIR$/Gemfile" />
7
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/LittleWeasel.rb" afterPath="$PROJECT_DIR$/lib/LittleWeasel.rb" />
8
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/spec/checker/checker_spec.rb" afterPath="$PROJECT_DIR$/spec/checker/checker_spec.rb" />
9
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/LittleWeasel/version.rb" afterPath="$PROJECT_DIR$/lib/LittleWeasel/version.rb" />
10
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
7
11
  </list>
8
12
  <ignored path="LittleWeasel.iws" />
9
13
  <ignored path=".idea/workspace.xml" />
10
14
  <file path="/Dummy.txt" changelist="34d4ec05-51d8-442a-84a5-75b5005cedf0" time="1372805608148" ignored="false" />
11
- <file path="/LittleWeasel.rb" changelist="34d4ec05-51d8-442a-84a5-75b5005cedf0" time="1372810862469" ignored="false" />
15
+ <file path="/LittleWeasel.rb" changelist="34d4ec05-51d8-442a-84a5-75b5005cedf0" time="1372859178934" ignored="false" />
12
16
  <file path="/spec_helper.rb" changelist="34d4ec05-51d8-442a-84a5-75b5005cedf0" time="1371776194745" ignored="false" />
13
17
  <file path="/little_weasel.rb" changelist="34d4ec05-51d8-442a-84a5-75b5005cedf0" time="1371781900009" ignored="false" />
14
- <file path="/checker_spec.rb" changelist="34d4ec05-51d8-442a-84a5-75b5005cedf0" time="1372298875670" ignored="false" />
18
+ <file path="/checker_spec.rb" changelist="34d4ec05-51d8-442a-84a5-75b5005cedf0" time="1372858412116" ignored="false" />
15
19
  <file path="/checker.rb" changelist="34d4ec05-51d8-442a-84a5-75b5005cedf0" time="1371778535451" ignored="false" />
16
20
  <file path="/LittleWeasel.gemspec" changelist="34d4ec05-51d8-442a-84a5-75b5005cedf0" time="1371779509067" ignored="false" />
17
21
  <file path="/.gitignore" changelist="34d4ec05-51d8-442a-84a5-75b5005cedf0" time="1371780237152" ignored="false" />
@@ -108,34 +112,34 @@
108
112
  <file leaf-file-name="LittleWeasel.rb" pinned="false" current="false" current-in-tab="false">
109
113
  <entry file="file://$PROJECT_DIR$/lib/LittleWeasel.rb">
110
114
  <provider selected="true" editor-type-id="text-editor">
111
- <state line="56" column="5" selection-start="1825" selection-end="1825" vertical-scroll-proportion="0.0">
115
+ <state line="71" column="14" selection-start="2270" selection-end="2916" vertical-scroll-proportion="0.0">
112
116
  <folding />
113
117
  </state>
114
118
  </provider>
115
119
  </entry>
116
120
  </file>
117
- <file leaf-file-name="Gemfile" pinned="false" current="true" current-in-tab="true">
118
- <entry file="file://$PROJECT_DIR$/Gemfile">
121
+ <file leaf-file-name="README.md" pinned="false" current="false" current-in-tab="false">
122
+ <entry file="file://$PROJECT_DIR$/README.md">
119
123
  <provider selected="true" editor-type-id="text-editor">
120
- <state line="7" column="13" selection-start="149" selection-end="149" vertical-scroll-proportion="0.22012578">
124
+ <state line="24" column="0" selection-start="452" selection-end="452" vertical-scroll-proportion="0.0">
121
125
  <folding />
122
126
  </state>
123
127
  </provider>
124
128
  </entry>
125
129
  </file>
126
- <file leaf-file-name="version.rb" pinned="false" current="false" current-in-tab="false">
130
+ <file leaf-file-name="version.rb" pinned="false" current="true" current-in-tab="true">
127
131
  <entry file="file://$PROJECT_DIR$/lib/LittleWeasel/version.rb">
128
132
  <provider selected="true" editor-type-id="text-editor">
129
- <state line="2" column="18" selection-start="64" selection-end="64" vertical-scroll-proportion="0.0">
133
+ <state line="2" column="18" selection-start="64" selection-end="64" vertical-scroll-proportion="0.062893085">
130
134
  <folding />
131
135
  </state>
132
136
  </provider>
133
137
  </entry>
134
138
  </file>
135
- <file leaf-file-name="README.md" pinned="false" current="false" current-in-tab="false">
136
- <entry file="file://$PROJECT_DIR$/README.md">
139
+ <file leaf-file-name="checker_spec.rb" pinned="false" current="false" current-in-tab="false">
140
+ <entry file="file://$PROJECT_DIR$/spec/checker/checker_spec.rb">
137
141
  <provider selected="true" editor-type-id="text-editor">
138
- <state line="23" column="112" selection-start="451" selection-end="451" vertical-scroll-proportion="0.0">
142
+ <state line="122" column="63" selection-start="3700" selection-end="3700" vertical-scroll-proportion="-35.307693">
139
143
  <folding />
140
144
  </state>
141
145
  </provider>
@@ -170,11 +174,11 @@
170
174
  <option value="$PROJECT_DIR$/test/spec.opts" />
171
175
  <option value="$PROJECT_DIR$/spec/.rspec" />
172
176
  <option value="$PROJECT_DIR$/.rspec" />
177
+ <option value="$PROJECT_DIR$/Gemfile" />
173
178
  <option value="$PROJECT_DIR$/spec/checker/checker_spec.rb" />
174
179
  <option value="$PROJECT_DIR$/lib/LittleWeasel.rb" />
175
- <option value="$PROJECT_DIR$/lib/LittleWeasel/version.rb" />
176
180
  <option value="$PROJECT_DIR$/README.md" />
177
- <option value="$PROJECT_DIR$/Gemfile" />
181
+ <option value="$PROJECT_DIR$/lib/LittleWeasel/version.rb" />
178
182
  </list>
179
183
  </option>
180
184
  </component>
@@ -232,6 +236,38 @@
232
236
  <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
233
237
  </PATH_ELEMENT>
234
238
  </PATH>
239
+ <PATH>
240
+ <PATH_ELEMENT>
241
+ <option name="myItemId" value="LittleWeasel" />
242
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
243
+ </PATH_ELEMENT>
244
+ <PATH_ELEMENT>
245
+ <option name="myItemId" value="LittleWeasel" />
246
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
247
+ </PATH_ELEMENT>
248
+ <PATH_ELEMENT>
249
+ <option name="myItemId" value="spec" />
250
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
251
+ </PATH_ELEMENT>
252
+ </PATH>
253
+ <PATH>
254
+ <PATH_ELEMENT>
255
+ <option name="myItemId" value="LittleWeasel" />
256
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
257
+ </PATH_ELEMENT>
258
+ <PATH_ELEMENT>
259
+ <option name="myItemId" value="LittleWeasel" />
260
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
261
+ </PATH_ELEMENT>
262
+ <PATH_ELEMENT>
263
+ <option name="myItemId" value="spec" />
264
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
265
+ </PATH_ELEMENT>
266
+ <PATH_ELEMENT>
267
+ <option name="myItemId" value="checker" />
268
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
269
+ </PATH_ELEMENT>
270
+ </PATH>
235
271
  <PATH>
236
272
  <PATH_ELEMENT>
237
273
  <option name="myItemId" value="LittleWeasel" />
@@ -288,7 +324,7 @@
288
324
  <recent name="$PROJECT_DIR$/test" />
289
325
  </key>
290
326
  </component>
291
- <component name="RunManager" selected="Gem Command.Start Yard Server">
327
+ <component name="RunManager" selected="RSpec.checker_spec">
292
328
  <configuration default="true" type="CommandRunConfigurationType" factoryName="Gem Command">
293
329
  <module name="" />
294
330
  <COMMAND_RUN_CONFIGURATION NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
@@ -480,7 +516,7 @@
480
516
  </component>
481
517
  <component name="ToolWindowManager">
482
518
  <frame x="0" y="22" width="1440" height="874" extended-state="0" />
483
- <editor active="false" />
519
+ <editor active="true" />
484
520
  <layout>
485
521
  <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
486
522
  <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
@@ -490,7 +526,7 @@
490
526
  <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39920425" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
491
527
  <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
492
528
  <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
493
- <window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.33023873" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
529
+ <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.33023873" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
494
530
  <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
495
531
  <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
496
532
  <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
@@ -560,7 +596,22 @@
560
596
  </component>
561
597
  <component name="XDebuggerManager">
562
598
  <breakpoint-manager>
563
- <option name="time" value="5" />
599
+ <breakpoints>
600
+ <line-breakpoint enabled="true" type="ruby-line">
601
+ <url>file://$PROJECT_DIR$/spec/checker/checker_spec.rb</url>
602
+ <line>133</line>
603
+ <option name="timeStamp" value="5" />
604
+ </line-breakpoint>
605
+ <line-breakpoint enabled="true" type="ruby-line">
606
+ <url>file://$PROJECT_DIR$/spec/checker/checker_spec.rb</url>
607
+ <line>134</line>
608
+ <option name="timeStamp" value="6" />
609
+ </line-breakpoint>
610
+ </breakpoints>
611
+ <breakpoints-dialog>
612
+ <breakpoints-dialog />
613
+ </breakpoints-dialog>
614
+ <option name="time" value="7" />
564
615
  </breakpoint-manager>
565
616
  </component>
566
617
  <component name="editorHistoryManager">
@@ -609,51 +660,51 @@
609
660
  <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="-352.64462" />
610
661
  </provider>
611
662
  </entry>
612
- <entry file="file://$PROJECT_DIR$/LittleWeasel.gemspec">
663
+ <entry file="file://$PROJECT_DIR$/Gemfile.lock">
613
664
  <provider selected="true" editor-type-id="text-editor">
614
- <state line="11" column="95" selection-start="550" selection-end="550" vertical-scroll-proportion="0.0">
665
+ <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="-0.16352202">
615
666
  <folding />
616
667
  </state>
617
668
  </provider>
618
669
  </entry>
619
- <entry file="file://$PROJECT_DIR$/spec/checker/checker_spec.rb">
670
+ <entry file="file://$PROJECT_DIR$/Gemfile">
620
671
  <provider selected="true" editor-type-id="text-editor">
621
- <state line="10" column="37" selection-start="268" selection-end="268" vertical-scroll-proportion="0.0">
672
+ <state line="7" column="13" selection-start="149" selection-end="149" vertical-scroll-proportion="0.0">
622
673
  <folding />
623
674
  </state>
624
675
  </provider>
625
676
  </entry>
626
- <entry file="file://$PROJECT_DIR$/lib/LittleWeasel/version.rb">
677
+ <entry file="file://$PROJECT_DIR$/LittleWeasel.gemspec">
627
678
  <provider selected="true" editor-type-id="text-editor">
628
- <state line="2" column="18" selection-start="64" selection-end="64" vertical-scroll-proportion="0.0">
679
+ <state line="11" column="95" selection-start="550" selection-end="550" vertical-scroll-proportion="0.0">
629
680
  <folding />
630
681
  </state>
631
682
  </provider>
632
683
  </entry>
633
- <entry file="file://$PROJECT_DIR$/lib/LittleWeasel.rb">
684
+ <entry file="file://$PROJECT_DIR$/spec/checker/checker_spec.rb">
634
685
  <provider selected="true" editor-type-id="text-editor">
635
- <state line="56" column="5" selection-start="1825" selection-end="1825" vertical-scroll-proportion="0.0">
686
+ <state line="122" column="63" selection-start="3700" selection-end="3700" vertical-scroll-proportion="-35.307693">
636
687
  <folding />
637
688
  </state>
638
689
  </provider>
639
690
  </entry>
640
- <entry file="file://$PROJECT_DIR$/README.md">
691
+ <entry file="file://$PROJECT_DIR$/lib/LittleWeasel.rb">
641
692
  <provider selected="true" editor-type-id="text-editor">
642
- <state line="23" column="112" selection-start="451" selection-end="451" vertical-scroll-proportion="0.0">
693
+ <state line="71" column="14" selection-start="2270" selection-end="2916" vertical-scroll-proportion="0.0">
643
694
  <folding />
644
695
  </state>
645
696
  </provider>
646
697
  </entry>
647
- <entry file="file://$PROJECT_DIR$/Gemfile.lock">
698
+ <entry file="file://$PROJECT_DIR$/README.md">
648
699
  <provider selected="true" editor-type-id="text-editor">
649
- <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="-0.16352202">
700
+ <state line="24" column="0" selection-start="452" selection-end="452" vertical-scroll-proportion="0.0">
650
701
  <folding />
651
702
  </state>
652
703
  </provider>
653
704
  </entry>
654
- <entry file="file://$PROJECT_DIR$/Gemfile">
705
+ <entry file="file://$PROJECT_DIR$/lib/LittleWeasel/version.rb">
655
706
  <provider selected="true" editor-type-id="text-editor">
656
- <state line="7" column="13" selection-start="149" selection-end="149" vertical-scroll-proportion="0.22012578">
707
+ <state line="2" column="18" selection-start="64" selection-end="64" vertical-scroll-proportion="0.062893085">
657
708
  <folding />
658
709
  </state>
659
710
  </provider>
data/lib/LittleWeasel.rb CHANGED
@@ -20,7 +20,7 @@ module LittleWeasel
20
20
 
21
21
  # The constructor
22
22
  def initialize
23
- @options = {exclude_alphabet: false}
23
+ @options = {exclude_alphabet: false, strip_whitespace: false}
24
24
  @alphabet_exclusion_list = %w{ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z }
25
25
  @dictionary = Hash.new(1)
26
26
  load
@@ -33,10 +33,29 @@ module LittleWeasel
33
33
  # method are applied for this query only.
34
34
  #
35
35
  # @return [Boolean] true if *word* exists, false otherwise.
36
+ #
37
+ # @example
38
+ #
39
+ # LittleWeasel::Checker.instance.exists?('C') # true (default options, :exclude_alphabet => false)
40
+ # LittleWeasel::Checker.instance.exists?('A', {exclude_alphabet:true}) # false
41
+ # LittleWeasel::Checker.instance.exists?('X', {exclude_alphabet:false}) # true
42
+ # LittleWeasel::Checker.instance.exists?('Hello') # true
43
+ # LittleWeasel::Checker.instance.exists?('Hello World') # false, two words does not a single word make :)
44
+ #
45
+ # LittleWeasel::Checker.instance.exists?(' Hello ') # false (default options, :strip_whitespace => false)
46
+ # LittleWeasel::Checker.instance.exists?(' Yes ', {strip_whitespace:true}) # true
47
+ # LittleWeasel::Checker.instance.exists?('No ', {strip_whitespace:false}) # false
48
+ # LittleWeasel::Checker.instance.exists?('Hell o', {strip_whitespace:true}) # false, strip_whitespace only removes leading and trailing spaces
49
+ #
36
50
  def exists?(word, options=nil)
37
51
  options = options || @options
38
52
 
39
- return false if word.nil? || !word.is_a?(String)
53
+ return false unless word.is_a?(String)
54
+
55
+ word.strip! if options[:strip_whitespace]
56
+
57
+ return false if word.empty?
58
+
40
59
  return false if options[:exclude_alphabet] && word.length == 1 && @alphabet_exclusion_list.include?(word.upcase)
41
60
 
42
61
  dictionary.has_key? word
@@ -48,6 +67,8 @@ module LittleWeasel
48
67
  # Options set via this property apply to all subsequent queries.
49
68
  # @option options [Boolean] :exclude_alphabet (false) If false, letters of the alphabet are considered words.
50
69
  # For example, LittleWeasel::Checker.instance.exists?('A'), will return true.
70
+ # @option options [Boolean] :strip_whitespace (false) If true, leading and trailing spaces are removed before checking to see if the word exists.
71
+ # For example, LittleWeasel::Checker.instance.exists?(' Hello ', {strip_whitespace:true}), will return true.
51
72
  #
52
73
  # @return [Hash] The options
53
74
  #
@@ -58,6 +79,15 @@ module LittleWeasel
58
79
  # LittleWeasel::Checker.instance.options({exclude_alphabet:false})
59
80
  # LittleWeasel::Checker.instance.exists?('A') # true
60
81
  #
82
+ # LittleWeasel::Checker.instance.options({strip_whitespace:false})
83
+ # LittleWeasel::Checker.instance.exists?(' Hello ') # false
84
+ # LittleWeasel::Checker.instance.exists?('No ') # false
85
+ # LittleWeasel::Checker.instance.exists?(' No') # false
86
+ #
87
+ # LittleWeasel::Checker.instance.options({strip_whitespace:true})
88
+ # LittleWeasel::Checker.instance.exists?(' Yes ') # true
89
+ # LittleWeasel::Checker.instance.exists?('Hell o') # false, strip_whitespace only removes leading and trailing spaces
90
+ #
61
91
  def options=(options)
62
92
  @options = options
63
93
  end
@@ -1,4 +1,4 @@
1
1
  # The version of this gem
2
2
  module LittleWeasel
3
- VERSION = "1.0.2"
3
+ VERSION = "1.1.0"
4
4
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- describe LittleWeasel do
3
+ describe 'LittleWeasel Inline Options Tests' do
4
4
 
5
5
  before do
6
6
  @spell = LittleWeasel::Checker.instance
@@ -14,6 +14,18 @@ describe LittleWeasel do
14
14
  @spell.exists?('apple').should == true
15
15
  end
16
16
 
17
+ it 'should return false for valid word with leading spaces by default' do
18
+ @spell.exists?(' apple').should == false
19
+ end
20
+
21
+ it 'should return false for valid word with trailing spaces by default' do
22
+ @spell.exists?('apple ').should == false
23
+ end
24
+
25
+ it 'should return false for valid word with leading and trailing spaces by default' do
26
+ @spell.exists?(' apple ').should == false
27
+ end
28
+
17
29
  it 'should return false for invalid word' do
18
30
  @spell.exists?('appel').should == false
19
31
  end
@@ -48,6 +60,30 @@ describe LittleWeasel do
48
60
  @spell.exists?('h', {exclude_alphabet: false}).should == true
49
61
  end
50
62
 
63
+ it 'should return false for valid word with leading spaces' do
64
+ @spell.exists?(' apple', {strip_whitespace: false}).should == false
65
+ end
66
+
67
+ it 'should return false for valid word with trailing spaces' do
68
+ @spell.exists?('apple ', {strip_whitespace: false}).should == false
69
+ end
70
+
71
+ it 'should return false for valid word with leading and trailing spaces' do
72
+ @spell.exists?(' apple ', {strip_whitespace: false}).should == false
73
+ end
74
+
75
+ it 'should return true for valid word with leading spaces' do
76
+ @spell.exists?(' apple', {strip_whitespace: true}).should == true
77
+ end
78
+
79
+ it 'should return true for valid word with trailing spaces' do
80
+ @spell.exists?('apple ', {strip_whitespace: true}).should == true
81
+ end
82
+
83
+ it 'should return true for valid word with leading and trailing spaces' do
84
+ @spell.exists?(' apple ', {strip_whitespace: true}).should == true
85
+ end
86
+
51
87
  # TODO: Profile
52
88
  it "shouldn't take forever to find a lot of words" do
53
89
  words = %w{ all bad cap dad eat fad glad had inch jump kind lend monster on put quiet run sad tape under vector was xenophobe yes zebra }
@@ -57,4 +93,58 @@ describe LittleWeasel do
57
93
  words.each { |word| @spell.exists?(word).should == true }
58
94
  end
59
95
 
96
+ end
97
+
98
+ describe 'LittleWeasel Global Options Tests' do
99
+
100
+ before (:all) do
101
+ @spell = LittleWeasel::Checker.instance
102
+ @spell.options = {exclude_alphabet: true, strip_whitespace: true}
103
+ end
104
+
105
+ it 'should create a LittleWeasel object' do
106
+ @spell.should be_an_instance_of LittleWeasel::Checker
107
+ end
108
+
109
+ it 'should return true for valid word' do
110
+ @spell.exists?('apple').should == true
111
+ end
112
+
113
+ it 'should return false for invalid word' do
114
+ @spell.exists?('appel').should == false
115
+ end
116
+
117
+ it 'should return false for nil' do
118
+ @spell.exists?(nil).should == false
119
+ end
120
+
121
+ it 'should return false for non-String' do
122
+ @spell.exists?(:word).should == false
123
+ end
124
+
125
+ it 'should return false if option exclude_alphabet is true, and word is a letter' do
126
+ @spell.exists?('x').should == false
127
+ @spell.exists?('X').should == false
128
+ end
129
+
130
+ it 'should use options passed to exist? but not override global options' do
131
+ @spell.exists?('h', {exclude_alphabet: false}).should == true
132
+ @spell.exists?('h').should == false
133
+
134
+ @spell.exists?(' h ', {exclude_alphabet: false, strip_whitespace: true}).should == true
135
+ @spell.exists?(' h ').should == false
136
+ end
137
+
138
+ it 'should return true for valid word with leading spaces' do
139
+ @spell.exists?(' apple').should == true
140
+ end
141
+
142
+ it 'should return true for valid word with trailing spaces' do
143
+ @spell.exists?('apple ').should == true
144
+ end
145
+
146
+ it 'should return true for valid word with leading and trailing spaces' do
147
+ @spell.exists?(' apple ').should == true
148
+ end
149
+
60
150
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: LittleWeasel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: