linguistics 2.0.2 → 2.0.3
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.simplecov +12 -0
- data/ChangeLog +773 -11
- data/History.rdoc +9 -0
- data/Manifest.txt +3 -2
- data/README.rdoc +5 -5
- data/Rakefile +49 -19
- data/examples/generalize_sentence.rb +2 -2
- data/lib/linguistics.rb +4 -4
- data/lib/linguistics/en/articles.rb +1 -1
- data/lib/linguistics/en/conjugation.rb +6 -6
- data/lib/linguistics/en/conjunctions.rb +1 -1
- data/lib/linguistics/en/infinitives.rb +1 -1
- data/lib/linguistics/en/linkparser.rb +11 -11
- data/lib/linguistics/en/numbers.rb +11 -11
- data/lib/linguistics/en/participles.rb +1 -1
- data/lib/linguistics/en/pluralization.rb +16 -16
- data/lib/linguistics/en/wordnet.rb +1 -1
- data/lib/linguistics/languagebehavior.rb +1 -1
- data/spec/{lib/constants.rb → constants.rb} +0 -0
- data/spec/helpers.rb +39 -0
- data/spec/linguistics/en/articles_spec.rb +194 -203
- data/spec/linguistics/en/conjugation_spec.rb +519 -521
- data/spec/linguistics/en/conjunctions_spec.rb +31 -47
- data/spec/linguistics/en/infinitives_spec.rb +193 -207
- data/spec/linguistics/en/linkparser_spec.rb +9 -20
- data/spec/linguistics/en/numbers_spec.rb +289 -302
- data/spec/linguistics/en/participles_spec.rb +6 -20
- data/spec/linguistics/en/pluralization_spec.rb +894 -908
- data/spec/linguistics/en/stemmer_spec.rb +10 -23
- data/spec/linguistics/en/titlecase_spec.rb +3 -13
- data/spec/linguistics/en/wordnet_spec.rb +10 -30
- data/spec/linguistics/en_spec.rb +14 -28
- data/spec/linguistics/inflector_spec.rb +3 -21
- data/spec/linguistics/iso639_spec.rb +28 -37
- data/spec/linguistics/monkeypatches_spec.rb +5 -14
- data/spec/linguistics_spec.rb +11 -30
- metadata +44 -15
- metadata.gz.sig +0 -0
- data/spec/lib/helpers.rb +0 -38
@@ -1,17 +1,8 @@
|
|
1
1
|
#!/usr/bin/env spec -cfs
|
2
2
|
|
3
|
-
|
4
|
-
require 'pathname'
|
5
|
-
basedir = Pathname.new( __FILE__ ).dirname.parent.parent.parent
|
6
|
-
|
7
|
-
libdir = basedir + "lib"
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
10
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
|
-
}
|
3
|
+
require_relative '../../helpers'
|
12
4
|
|
13
5
|
require 'rspec'
|
14
|
-
require 'spec/lib/helpers'
|
15
6
|
|
16
7
|
require 'linguistics'
|
17
8
|
require 'linguistics/en'
|
@@ -21,17 +12,12 @@ require 'linguistics/en/stemmer'
|
|
21
12
|
describe Linguistics::EN::Stemmer do
|
22
13
|
|
23
14
|
before( :all ) do
|
24
|
-
setup_logging()
|
25
15
|
Linguistics.use( :en )
|
26
16
|
end
|
27
17
|
|
28
|
-
after( :all ) do
|
29
|
-
reset_logging()
|
30
|
-
end
|
31
|
-
|
32
18
|
|
33
19
|
it "adds EN::Stemmer to the list of English language modules" do
|
34
|
-
Linguistics::EN::MODULES.include
|
20
|
+
expect( Linguistics::EN::MODULES ).to include( Linguistics::EN::Stemmer )
|
35
21
|
end
|
36
22
|
|
37
23
|
|
@@ -43,7 +29,7 @@ describe Linguistics::EN::Stemmer do
|
|
43
29
|
end
|
44
30
|
|
45
31
|
it "can fetch the stem of a word" do
|
46
|
-
"communication".en.stem.
|
32
|
+
expect( "communication".en.stem ).to eq( 'communic' )
|
47
33
|
end
|
48
34
|
|
49
35
|
end
|
@@ -51,16 +37,17 @@ describe Linguistics::EN::Stemmer do
|
|
51
37
|
|
52
38
|
describe "on a system that doesn't have the 'ruby-stemmer' library" do
|
53
39
|
|
54
|
-
|
40
|
+
it "raises an NotImplementedError when you try to use stemmer functionality" do
|
55
41
|
# If the system *does* have stemmer support, pretend it doesn't.
|
56
42
|
if Linguistics::EN.has_stemmer?
|
57
|
-
|
58
|
-
|
59
|
-
Linguistics::EN::Stemmer.
|
43
|
+
exception = LoadError.new( 'no such file to load -- lingua/stemmer' )
|
44
|
+
|
45
|
+
allow( Linguistics::EN::Stemmer ).to receive( :has_stemmer? ).
|
46
|
+
and_return( false )
|
47
|
+
allow( Linguistics::EN::Stemmer ).to receive( :stemmer_error ).
|
48
|
+
and_return( exception )
|
60
49
|
end
|
61
|
-
end
|
62
50
|
|
63
|
-
it "raises an NotImplementedError when you try to use stemmer functionality" do
|
64
51
|
expect {
|
65
52
|
"communication".en.stem
|
66
53
|
}.to raise_error( LoadError, %r{lingua/stemmer}i )
|
@@ -1,18 +1,9 @@
|
|
1
1
|
#!/usr/bin/env rspec -cfd
|
2
2
|
#coding: utf-8
|
3
3
|
|
4
|
-
|
5
|
-
require 'pathname'
|
6
|
-
basedir = Pathname.new( __FILE__ ).dirname.parent.parent.parent
|
7
|
-
|
8
|
-
libdir = basedir + "lib"
|
9
|
-
|
10
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
11
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
12
|
-
}
|
4
|
+
require_relative '../../helpers'
|
13
5
|
|
14
6
|
require 'rspec'
|
15
|
-
require 'spec/lib/helpers'
|
16
7
|
|
17
8
|
require 'linguistics'
|
18
9
|
require 'linguistics/en'
|
@@ -22,12 +13,11 @@ require 'linguistics/en/titlecase'
|
|
22
13
|
describe Linguistics::EN::TitleCase do
|
23
14
|
|
24
15
|
before( :all ) do
|
25
|
-
setup_logging( :fatal )
|
26
16
|
Linguistics.use( :en )
|
27
17
|
end
|
28
18
|
|
29
|
-
|
30
|
-
|
19
|
+
it "adds EN::TitleCase to the list of English language modules" do
|
20
|
+
Linguistics::EN::MODULES.include?( Linguistics::EN::TitleCase )
|
31
21
|
end
|
32
22
|
|
33
23
|
it "CamelCases 'motion is madness' correctly" do
|
@@ -1,17 +1,8 @@
|
|
1
1
|
#!/usr/bin/env spec -cfs
|
2
2
|
|
3
|
-
|
4
|
-
require 'pathname'
|
5
|
-
basedir = Pathname.new( __FILE__ ).dirname.parent.parent.parent
|
6
|
-
|
7
|
-
libdir = basedir + "lib"
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
10
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
|
-
}
|
3
|
+
require_relative '../../helpers'
|
12
4
|
|
13
5
|
require 'rspec'
|
14
|
-
require 'spec/lib/helpers'
|
15
6
|
|
16
7
|
require 'linguistics'
|
17
8
|
require 'linguistics/en'
|
@@ -21,14 +12,9 @@ require 'linguistics/en/wordnet'
|
|
21
12
|
describe Linguistics::EN::WordNet do
|
22
13
|
|
23
14
|
before( :all ) do
|
24
|
-
setup_logging()
|
25
15
|
Linguistics.use( :en )
|
26
16
|
end
|
27
17
|
|
28
|
-
after( :all ) do
|
29
|
-
reset_logging()
|
30
|
-
end
|
31
|
-
|
32
18
|
|
33
19
|
it "adds EN::WordNet to the list of English language modules" do
|
34
20
|
Linguistics::EN::MODULES.include?( Linguistics::EN::WordNet )
|
@@ -43,37 +29,31 @@ describe Linguistics::EN::WordNet do
|
|
43
29
|
end
|
44
30
|
|
45
31
|
it "can create a WordNet::Synset from a word" do
|
46
|
-
"jackal".en.synset.
|
32
|
+
expect( "jackal".en.synset ).to be_a( WordNet::Synset )
|
47
33
|
end
|
48
34
|
|
49
35
|
it "can load all synsets for a word" do
|
50
36
|
result = "appear".en.synsets
|
51
|
-
result.
|
52
|
-
result.
|
37
|
+
expect( result ).to have( 7 ).members
|
38
|
+
expect( result ).to include( WordNet::Synset[200422090] )
|
53
39
|
end
|
54
40
|
|
55
41
|
end
|
56
42
|
|
57
43
|
|
58
44
|
describe "on a system that doesn't have the 'wordnet' library" do
|
59
|
-
|
45
|
+
|
46
|
+
it "raises the appropriate LoadError when you try to use wordnet functionality" do
|
60
47
|
# If the system *does* have wordnet support, pretend it doesn't.
|
61
48
|
if Linguistics::EN.has_wordnet?
|
62
|
-
@had_wordnet = true
|
63
49
|
error = LoadError.new( "no such file to load -- wordnet" )
|
64
|
-
Linguistics::EN::WordNet.instance_variable_set( :@has_wordnet, false )
|
65
|
-
Linguistics::EN::WordNet.instance_variable_set( :@wn_error, error )
|
66
|
-
end
|
67
|
-
end
|
68
50
|
|
69
|
-
|
70
|
-
|
71
|
-
Linguistics::EN::WordNet.
|
72
|
-
|
51
|
+
allow( Linguistics::EN::WordNet ).to receive( :has_wordnet? ).
|
52
|
+
and_return( false )
|
53
|
+
allow( Linguistics::EN::WordNet ).to receive( :wordnet_error ).
|
54
|
+
and_return( error )
|
73
55
|
end
|
74
|
-
end
|
75
56
|
|
76
|
-
it "raises the appropriate LoadError when you try to use wordnet functionality" do
|
77
57
|
expect {
|
78
58
|
"persimmon".en.synset
|
79
59
|
}.to raise_error( LoadError, %r{wordnet}i )
|
data/spec/linguistics/en_spec.rb
CHANGED
@@ -1,17 +1,8 @@
|
|
1
1
|
#!/usr/bin/env spec -cfs
|
2
2
|
|
3
|
-
|
4
|
-
require 'pathname'
|
5
|
-
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
6
|
-
|
7
|
-
libdir = basedir + "lib"
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
10
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
|
-
}
|
3
|
+
require_relative '../helpers'
|
12
4
|
|
13
5
|
require 'rspec'
|
14
|
-
require 'spec/lib/helpers'
|
15
6
|
|
16
7
|
require 'linguistics'
|
17
8
|
require 'linguistics/en'
|
@@ -21,55 +12,50 @@ require 'linguistics/languagebehavior'
|
|
21
12
|
describe Linguistics::EN do
|
22
13
|
|
23
14
|
before( :all ) do
|
24
|
-
setup_logging( :fatal )
|
25
15
|
Linguistics.use( :en, :proxy => true )
|
26
16
|
include Linguistics::EN
|
27
17
|
end
|
28
18
|
|
29
|
-
after( :all ) do
|
30
|
-
reset_logging()
|
31
|
-
end
|
32
|
-
|
33
19
|
|
34
20
|
it_behaves_like "a Linguistics language module"
|
35
21
|
|
36
22
|
|
37
23
|
it "provides a predicate for testing for the presence of modules by name" do
|
38
|
-
Linguistics::EN.
|
39
|
-
Linguistics::EN.
|
24
|
+
expect( Linguistics::EN ).to_not have_extension( 'nonexistant' )
|
25
|
+
expect( Linguistics::EN ).to have_extension( 'articles' )
|
40
26
|
end
|
41
27
|
|
42
28
|
it "knows that it's not in 'classical' mode by default" do
|
43
|
-
Linguistics::EN.
|
29
|
+
expect( Linguistics::EN ).to_not be_classical()
|
44
30
|
end
|
45
31
|
|
46
32
|
it "can run a single block in classical mode" do
|
47
33
|
Linguistics::EN.in_classical_mode do
|
48
|
-
Linguistics::EN.
|
34
|
+
expect( Linguistics::EN ).to be_classical()
|
49
35
|
end
|
50
36
|
end
|
51
37
|
|
52
38
|
it "handles nested classical blocks correctly" do
|
53
39
|
Linguistics::EN.in_classical_mode do
|
54
40
|
Linguistics::EN.in_classical_mode do
|
55
|
-
Linguistics::EN.
|
41
|
+
expect( Linguistics::EN ).to be_classical()
|
56
42
|
end
|
57
|
-
Linguistics::EN.
|
43
|
+
expect( Linguistics::EN ).to be_classical()
|
58
44
|
end
|
59
|
-
Linguistics::EN.
|
45
|
+
expect( Linguistics::EN ).to_not be_classical()
|
60
46
|
end
|
61
47
|
|
62
48
|
|
63
49
|
it "provides a sprintf-like function for interpolating variables into a String" do
|
64
|
-
"I have %CONJUNCT.".en.lprintf(
|
65
|
-
|
50
|
+
expect( "I have %CONJUNCT.".en.lprintf(["cat", "cat", "dog"]) ).
|
51
|
+
to eq( "I have two cats and a dog." )
|
66
52
|
end
|
67
53
|
|
68
54
|
|
69
55
|
context "lprintf formatters" do
|
70
56
|
|
71
57
|
before( :all ) do
|
72
|
-
@real_formatters = Linguistics::EN.lprintf_formatters
|
58
|
+
@real_formatters = Linguistics::EN.lprintf_formatters.dup
|
73
59
|
end
|
74
60
|
|
75
61
|
before( :each ) do
|
@@ -83,9 +69,9 @@ describe Linguistics::EN do
|
|
83
69
|
|
84
70
|
it "provides a way to register new lprintf formatters with a Symbol" do
|
85
71
|
Linguistics::EN.register_lprintf_formatter :TEST, :plural
|
86
|
-
Linguistics::EN.lprintf_formatters.
|
87
|
-
Linguistics::EN.lprintf_formatters.
|
88
|
-
Linguistics::EN.lprintf_formatters[
|
72
|
+
expect( Linguistics::EN.lprintf_formatters ).to have( 1 ).member
|
73
|
+
expect( Linguistics::EN.lprintf_formatters ).to include( :TEST )
|
74
|
+
expect( Linguistics::EN.lprintf_formatters[:TEST] ).to be_a( Proc )
|
89
75
|
end
|
90
76
|
|
91
77
|
end
|
@@ -1,17 +1,8 @@
|
|
1
1
|
#!/usr/bin/env spec -cfs
|
2
2
|
|
3
|
-
|
4
|
-
require 'pathname'
|
5
|
-
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
6
|
-
|
7
|
-
libdir = basedir + "lib"
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
10
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
|
-
}
|
3
|
+
require_relative '../helpers'
|
12
4
|
|
13
5
|
require 'rspec'
|
14
|
-
require 'spec/lib/helpers'
|
15
6
|
|
16
7
|
require 'linguistics'
|
17
8
|
require 'linguistics/inflector'
|
@@ -19,21 +10,12 @@ require 'linguistics/inflector'
|
|
19
10
|
|
20
11
|
describe Linguistics::Inflector do
|
21
12
|
|
22
|
-
before( :all ) do
|
23
|
-
setup_logging( :fatal )
|
24
|
-
end
|
25
|
-
|
26
|
-
after( :all ) do
|
27
|
-
reset_logging()
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
13
|
it "provides a human-readable representation of the object suitable for debugging" do
|
32
14
|
obj = Object.new
|
33
15
|
result = Linguistics::Inflector.new( :en, obj ).inspect
|
34
16
|
|
35
|
-
result.
|
36
|
-
result.
|
17
|
+
expect( result ).to include( (obj.object_id / 2).to_s(16) )
|
18
|
+
expect( result ).to match( /english-language/i )
|
37
19
|
end
|
38
20
|
|
39
21
|
end
|
@@ -1,18 +1,9 @@
|
|
1
1
|
#!/usr/bin/env spec -cfs
|
2
2
|
#encoding: utf-8
|
3
3
|
|
4
|
-
|
5
|
-
require 'pathname'
|
6
|
-
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
7
|
-
|
8
|
-
libdir = basedir + "lib"
|
9
|
-
|
10
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
11
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
12
|
-
}
|
4
|
+
require_relative '../helpers'
|
13
5
|
|
14
6
|
require 'rspec'
|
15
|
-
require 'spec/lib/helpers'
|
16
7
|
|
17
8
|
require 'linguistics'
|
18
9
|
require 'linguistics/iso639'
|
@@ -22,46 +13,46 @@ describe Linguistics::ISO639 do
|
|
22
13
|
|
23
14
|
# eng||en|English|anglais
|
24
15
|
it "loads simple language codes from its __DATA__ section" do
|
25
|
-
Linguistics::LANGUAGE_CODES.
|
26
|
-
Linguistics::LANGUAGE_CODES[
|
16
|
+
expect( Linguistics::LANGUAGE_CODES ).to have_key( :en )
|
17
|
+
expect( Linguistics::LANGUAGE_CODES[:en] ).to have(3).members
|
27
18
|
|
28
|
-
Linguistics::LANGUAGE_CODES[
|
29
|
-
Linguistics::LANGUAGE_CODES[
|
30
|
-
Linguistics::LANGUAGE_CODES[
|
19
|
+
expect( Linguistics::LANGUAGE_CODES[:en] ).to have_key( :codes )
|
20
|
+
expect( Linguistics::LANGUAGE_CODES[:en][:codes] ).to have(2).members
|
21
|
+
expect( Linguistics::LANGUAGE_CODES[:en][:codes] ).to include("en", "eng")
|
31
22
|
|
32
|
-
Linguistics::LANGUAGE_CODES[
|
33
|
-
Linguistics::LANGUAGE_CODES[
|
34
|
-
Linguistics::LANGUAGE_CODES[
|
35
|
-
Linguistics::LANGUAGE_CODES[
|
23
|
+
expect( Linguistics::LANGUAGE_CODES[:en] ).to have_key( :eng_name )
|
24
|
+
expect( Linguistics::LANGUAGE_CODES[:en][:eng_name] ).to eq( 'English' )
|
25
|
+
expect( Linguistics::LANGUAGE_CODES[:en] ).to have_key( :fre_name )
|
26
|
+
expect( Linguistics::LANGUAGE_CODES[:en][:fre_name] ).to eq( 'anglais' )
|
36
27
|
end
|
37
28
|
|
38
29
|
it "loads language codes with variants from its __DATA__ section" do
|
39
30
|
|
40
31
|
# cze|ces|cs|Czech|tchèque
|
41
|
-
Linguistics::LANGUAGE_CODES.
|
42
|
-
Linguistics::LANGUAGE_CODES[
|
32
|
+
expect( Linguistics::LANGUAGE_CODES ).to have_key( :cs )
|
33
|
+
expect( Linguistics::LANGUAGE_CODES[:cs] ).to have(3).members
|
43
34
|
|
44
|
-
Linguistics::LANGUAGE_CODES[
|
45
|
-
Linguistics::LANGUAGE_CODES[
|
46
|
-
Linguistics::LANGUAGE_CODES[
|
35
|
+
expect( Linguistics::LANGUAGE_CODES[:cs] ).to have_key( :codes )
|
36
|
+
expect( Linguistics::LANGUAGE_CODES[:cs][:codes] ).to have(3).members
|
37
|
+
expect( Linguistics::LANGUAGE_CODES[:cs][:codes] ).to include("cs", "ces", "cze")
|
47
38
|
|
48
|
-
Linguistics::LANGUAGE_CODES[
|
49
|
-
Linguistics::LANGUAGE_CODES[
|
50
|
-
Linguistics::LANGUAGE_CODES[
|
51
|
-
Linguistics::LANGUAGE_CODES[
|
39
|
+
expect( Linguistics::LANGUAGE_CODES[:cs] ).to have_key( :eng_name )
|
40
|
+
expect( Linguistics::LANGUAGE_CODES[:cs][:eng_name] ).to eq( 'Czech' )
|
41
|
+
expect( Linguistics::LANGUAGE_CODES[:cs] ).to have_key( :fre_name )
|
42
|
+
expect( Linguistics::LANGUAGE_CODES[:cs][:fre_name] ).to eq( 'tchèque' )
|
52
43
|
|
53
44
|
# mac|mkd|mk|Macedonian|macédonien
|
54
|
-
Linguistics::LANGUAGE_CODES.
|
55
|
-
Linguistics::LANGUAGE_CODES[
|
45
|
+
expect( Linguistics::LANGUAGE_CODES ).to have_key( :mk )
|
46
|
+
expect( Linguistics::LANGUAGE_CODES[:mk] ).to have( 3 ).members
|
56
47
|
|
57
|
-
Linguistics::LANGUAGE_CODES[
|
58
|
-
Linguistics::LANGUAGE_CODES[
|
59
|
-
Linguistics::LANGUAGE_CODES[
|
48
|
+
expect( Linguistics::LANGUAGE_CODES[:mk] ).to have_key( :codes )
|
49
|
+
expect( Linguistics::LANGUAGE_CODES[:mk][:codes] ).to have(3).members
|
50
|
+
expect( Linguistics::LANGUAGE_CODES[:mk][:codes] ).to include("mk", "mac", "mkd")
|
60
51
|
|
61
|
-
Linguistics::LANGUAGE_CODES[
|
62
|
-
Linguistics::LANGUAGE_CODES[
|
63
|
-
Linguistics::LANGUAGE_CODES[
|
64
|
-
Linguistics::LANGUAGE_CODES[
|
52
|
+
expect( Linguistics::LANGUAGE_CODES[:mk] ).to have_key( :eng_name )
|
53
|
+
expect( Linguistics::LANGUAGE_CODES[:mk][:eng_name] ).to eq( 'Macedonian' )
|
54
|
+
expect( Linguistics::LANGUAGE_CODES[:mk] ).to have_key( :fre_name )
|
55
|
+
expect( Linguistics::LANGUAGE_CODES[:mk][:fre_name] ).to eq( 'macédonien' )
|
65
56
|
|
66
57
|
end
|
67
58
|
|
@@ -1,17 +1,8 @@
|
|
1
1
|
#!/usr/bin/env spec -cfs
|
2
2
|
|
3
|
-
|
4
|
-
require 'pathname'
|
5
|
-
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
6
|
-
|
7
|
-
libdir = basedir + "lib"
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
10
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
|
-
}
|
3
|
+
require_relative '../helpers'
|
12
4
|
|
13
5
|
require 'rspec'
|
14
|
-
require 'spec/lib/helpers'
|
15
6
|
|
16
7
|
require 'linguistics'
|
17
8
|
require 'linguistics/monkeypatches'
|
@@ -21,20 +12,20 @@ describe Array, "extended with Linguistics::ArrayExtensions" do
|
|
21
12
|
|
22
13
|
it "can return a copy of itself with a separator between each element" do
|
23
14
|
ary = %w[one two three]
|
24
|
-
ary.separate( 'and' ).
|
15
|
+
expect( ary.separate( 'and' ) ).to eq([ 'one', 'and', 'two', 'and', 'three' ])
|
25
16
|
end
|
26
17
|
|
27
18
|
it "can return a copy of itself with each element separated by the return value of a block" do
|
28
19
|
ary = %w[thumpy lippy barky tiger]
|
29
20
|
result = ary.separate {|left, right| (left > right) ? '>' : '<' }
|
30
|
-
result.
|
21
|
+
expect( result ).to eq([ 'thumpy', '>', 'lippy', '>', 'barky', '<', 'tiger' ])
|
31
22
|
end
|
32
23
|
|
33
24
|
it "provides a mutator variant of #separate" do
|
34
25
|
ary = %w[one two three]
|
35
26
|
result = ary.separate!( nil )
|
36
|
-
result.
|
37
|
-
result.
|
27
|
+
expect( result ).to equal( ary )
|
28
|
+
expect( result ).to eq([ 'one', nil, 'two', nil, 'three' ])
|
38
29
|
end
|
39
30
|
|
40
31
|
end
|