spec/wordnet/word_spec.rb in wordnet-1.0.1 vs spec/wordnet/word_spec.rb in wordnet-1.1.0
- old
+ new
@@ -1,41 +1,45 @@
#!/usr/bin/env rspec
require_relative '../helpers'
require 'rspec'
require 'wordnet'
-require 'wordnet/word'
#####################################################################
### C O N T E X T S
#####################################################################
-describe WordNet::Word, :requires_database => true do
+describe 'WordNet::Word', :requires_database do
- let( :lexicon ) { WordNet::Lexicon.new }
+ let( :described_class ) { WordNet::Word }
+ let!( :lexicon ) { WordNet::Lexicon.new($dburi) }
+
context "the Word for 'run'" do
- let( :word ) { lexicon[113377] }
+ let( :word ) { described_class.by_lemma('run').first }
+
it "knows what senses it has" do
senses = word.senses
expect( senses ).to be_an( Array )
expect( senses.count ).to eq( 57 )
expect( senses.first ).to be_a( WordNet::Sense )
end
+
it "knows what synsets it has" do
synsets = word.synsets
# Should have one synset per sense
expect( synsets.size ).to eq( word.senses.size )
expect( synsets.first.senses ).to include( word.senses.first )
end
+
it "has a dataset for selecting noun synsets" do
expect( word.nouns ).to be_a( Sequel::Dataset )
expect( word.nouns.count ).to eq( 16 )
ss = word.nouns.all
expect( ss ).to include(
@@ -44,10 +48,11 @@
lexicon[ :run, 'act of running' ],
lexicon[ :run, 'testing' ]
)
end
+
it "has a dataset for selecting verb synsets" do
expect( word.verbs ).to be_a( Sequel::Dataset )
expect( word.verbs.count ).to eq( 41 )
ss = word.verbs.all
expect( ss ).to include(
@@ -61,12 +66,13 @@
end
context "the Word for 'light'" do
- let( :word ) { lexicon[77458] }
+ let( :word ) { described_class.by_lemma('light').first }
+
it "has a dataset for selecting adjective synsets" do
expect( word.adjectives ).to be_a( Sequel::Dataset )
expect( word.adjectives.count ).to eq( 8 )
ss = word.adjectives.all
expect( ss ).to include(
@@ -74,10 +80,11 @@
lexicon[ :light, 'emit', :adjective ],
lexicon[ :light, 'color' ]
)
end
+
it "has a dataset for selecting adjective-satellite synsets" do
expect( word.adjective_satellites ).to be_a( Sequel::Dataset )
expect( word.adjective_satellites.count ).to eq( 17 )
ss = word.adjective_satellites.all
expect( ss ).to include(
@@ -90,10 +97,11 @@
end
context "the Word for 'lightly'" do
- let( :word ) { lexicon[77549] }
+ let( :word ) { described_class.by_lemma('lightly').first }
+
it "has a dataset for selecting adverb synsets" do
expect( word.adverbs ).to be_a( Sequel::Dataset )
expect( word.adverbs.count ).to eq( 7 )
ss = word.adverbs.all