dancroak-webster 0.4.3 → 0.4.4
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/lib/webster.rb +5 -12
- data/test/webster_test.rb +5 -7
- metadata +1 -1
data/lib/webster.rb
CHANGED
@@ -1,18 +1,11 @@
|
|
1
|
-
|
1
|
+
module Webster
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
attr_accessor :dictionary
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@dictionary = []
|
9
|
-
File.open(DICTIONARY_FILE) do |file|
|
10
|
-
@dictionary = file.readlines.collect { |word| word.chomp }
|
11
|
-
end
|
3
|
+
DICTIONARY = File.open(File.join(File.dirname(__FILE__), 'words')) do |file|
|
4
|
+
file.readlines.collect {|each| each.chomp}
|
12
5
|
end
|
13
|
-
|
6
|
+
|
14
7
|
def random
|
15
|
-
|
8
|
+
DICTIONARY[rand(DICTIONARY.size)]
|
16
9
|
end
|
17
10
|
|
18
11
|
end
|
data/test/webster_test.rb
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'rubygems'
|
3
3
|
require 'shoulda'
|
4
|
-
require 'quietbacktrace'
|
5
|
-
require 'redgreen'
|
6
4
|
require File.join(File.dirname(__FILE__), "..", "lib", "webster")
|
7
5
|
|
8
6
|
class WebsterTest < Test::Unit::TestCase
|
9
7
|
|
8
|
+
include Webster
|
9
|
+
|
10
10
|
context "#dictionary" do
|
11
11
|
setup do
|
12
|
-
@
|
13
|
-
@dictionary = @webster.dictionary
|
12
|
+
@dictionary = Webster::DICTIONARY
|
14
13
|
@blacklist = %w(bastaard bastard bastardly bastardy bedamn bitch damnable damnably damnation
|
15
14
|
damnatory damned damner damnify damnii damning damningly damnonii damnous damnously
|
16
15
|
shita shitepoke shother shittah shittim undamned undamning undamn
|
@@ -29,8 +28,7 @@ class WebsterTest < Test::Unit::TestCase
|
|
29
28
|
|
30
29
|
context "#random" do
|
31
30
|
setup do
|
32
|
-
@
|
33
|
-
@random = @webster.random
|
31
|
+
@random = random
|
34
32
|
end
|
35
33
|
|
36
34
|
should "be a word" do
|
@@ -54,7 +52,7 @@ class WebsterTest < Test::Unit::TestCase
|
|
54
52
|
end
|
55
53
|
|
56
54
|
should "be a word in the dictionary" do
|
57
|
-
assert
|
55
|
+
assert Webster::DICTIONARY.include?(@random)
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|