Skip to content

Commit

Permalink
spec/libcdb/reader_spec.rb, spec/spec_helper.rb: Shorten string value…
Browse files Browse the repository at this point in the history
…s, allow for variable TEST_DATA size.
  • Loading branch information
blackwinter committed Apr 25, 2013
1 parent d38f7fb commit c0de7a4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
30 changes: 15 additions & 15 deletions spec/libcdb/reader_spec.rb
Expand Up @@ -68,11 +68,11 @@
end end


it "should know if it doesn't have a key" do it "should know if it doesn't have a key" do
@db.should_not have_key('key3') @db.should_not have_key('k3')
end end


it "should know if it doesn't have a value" do it "should know if it doesn't have a value" do
@db.should_not have_value('value3.2') @db.should_not have_value('v3.2')
end end


it "should dump itself" do it "should dump itself" do
Expand Down Expand Up @@ -108,11 +108,11 @@
end end


it "should know its size" do it "should know its size" do
@db.size.should == 11 @db.size.should == TEST_DATA.size
end end


it "should know its total" do it "should know its total" do
@db.total.should == 56 @db.total.should == TEST_DATA.values.flatten.size
end end


it "should know its keys" do it "should know its keys" do
Expand All @@ -124,27 +124,27 @@
end end


it "should know if it has a key" do it "should know if it has a key" do
@db.should have_key('key3') @db.should have_key('k3')
end end


it "should know if it doesn't have a key" do it "should know if it doesn't have a key" do
@db.should_not have_key('key33') @db.should_not have_key('none')
end end


it "should know if it has a value" do it "should know if it has a value" do
@db.should have_value('value3.2') @db.should have_value('v3.2')
end end


it "should know if it doesn't have a value" do it "should know if it doesn't have a value" do
@db.should_not have_value('value33.22') @db.should_not have_value('none')
end end


it "should get a single value" do it "should get a single value" do
@db['key1'].should == 'value1.1' @db['k1'].should == 'v1.1'
end end


it "should not get non-existent value" do it "should not get non-existent value" do
@db['key33'].should be_nil @db['none'].should be_nil
end end


it "should get each value" do it "should get each value" do
Expand All @@ -162,21 +162,21 @@
end end


it "should get last value" do it "should get last value" do
@db.fetch_last('key10').should == 'value10.10' @db.fetch_last('k10').should == 'v10.10'
end end


it "should find the key for a value" do it "should find the key for a value" do
@db.key('value3.2').should == 'key3' @db.key('v3.2').should == 'k3'
end end


it "should not find the key for a non-existent value" do it "should not find the key for a non-existent value" do
@db.key('value33.22').should be_nil @db.key('none').should be_nil
end end


it "should dump records for key" do it "should dump records for key" do
d = [] d = []
@db.each_dump('key3') { |e| d << e } @db.each_dump('k3') { |e| d << e }
d.should == %w[+4,8:key3->value3.1 +4,8:key3->value3.2 +4,8:key3->value3.3] d.should == %w[+2,4:k3->v3.1 +2,4:k3->v3.2 +2,4:k3->v3.3]
end end


it "should convert itself into a hash" do it "should convert itself into a hash" do
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Expand Up @@ -8,8 +8,8 @@
TEST_DATA = {} TEST_DATA = {}


1.upto(10) { |i| 1.upto(10) { |i|
v = TEST_DATA["key#{i}"] = [] v = TEST_DATA["k#{i}"] = []
1.upto(i) { |j| v << "value#{i}.#{j}" } 1.upto(i) { |j| v << "v#{i}.#{j}" }
} }


TEST_DATA['a' * 1024] = Array('b' * 1024 ** 2) TEST_DATA['a' * 1024] = Array('b' * 1024 ** 2)
Expand Down

0 comments on commit c0de7a4

Please sign in to comment.