spec/csv/table/table_spec.rb in smart_csv-0.0.6 vs spec/csv/table/table_spec.rb in smart_csv-0.0.7
- old
+ new
@@ -1,8 +1,8 @@
require 'smart_csv'
-describe "Check class CSV::Table" do
+describe CSV::Table do
let(:csv_data) {"id,firstname,lastname\n1,One,One\n2,Two,Two\n4,Four,Four\n5,Five,Five\n6,One,One"}
let(:parse_data) { CSV.parse(csv_data, {:col_sep => ',', :headers => true}) }
@@ -18,9 +18,29 @@
parse_data.where('firstname' => 'One').where_not('id' => '6').size.should eql(1)
end
it "should select records with id greater than 2" do
parse_data.gt('id', 2).size.should eq(3)
+ end
+
+ it "should select records with id greater than or equal to 2" do
+ parse_data.ge('id', 2).size.should eq(4)
+ end
+
+ it "should select records with id less than 2" do
+ parse_data.lt('id', 2).size.should eq(1)
+ end
+
+ it "should select records with id less than or equal to 2" do
+ parse_data.le('id', 2).size.should eq(2)
+ end
+
+ it "should select records with firstname equal to 'Four'" do
+ parse_data.eq('firstname', 'Four').size.should eq(1)
+ end
+
+ it "should select records with firstname not equal to 'Four'" do
+ parse_data.ne('firstname', 'Four').size.should eq(4)
end
it "should correct delete records" do
parse_data.size.should eql(5)
parse_data.delete_all