Skip to content
Browse files

Added additional unit tests

  • Loading branch information...
1 parent c25f1cd commit f37200ec3681145900f0f4c740a17edd83240f78 Brad Seefeld committed Jun 7, 2011
Showing with 24 additions and 1 deletion.
  1. +1 −0 lib/rgviz/data_table.rb
  2. +1 −1 lib/rgviz/data_table/max_column.rb
  3. +22 −0 spec/rgviz/data_table/max_column_spec.rb
View
1 lib/rgviz/data_table.rb
@@ -5,6 +5,7 @@
require "rgviz/data_table/column_value_filter"
require "rgviz/data_table/column"
require "rgviz/data_table/sum_column"
+require "rgviz/data_table/max_column"
require "rgviz/data_table/order"
module Rgviz
View
2 lib/rgviz/data_table/max_column.rb
@@ -1,6 +1,6 @@
module Rgviz
module DataTable
- class MaxColumn
+ class MaxColumn < Rgviz::DataTable::Column
def evaluate(rows)
max = nil
View
22 spec/rgviz/data_table/max_column_spec.rb
@@ -0,0 +1,22 @@
+require "spec_helper"
+
+describe Rgviz::DataTable::MaxColumn do
+
+ before(:each) do
+ @col = Rgviz::DataTable::MaxColumn.new("a", "max(a)")
+ end
+
+ it "finds the max column" do
+ rows = [{"a" => 1}, {"a" => 3}, {"a" => 1}]
+ @col.evaluate(rows).should == 3
+ end
+
+ it "returns nil when no rows given" do
+ @col.evaluate([]).should be_nil
+ end
+
+ it "returns nil when column does not exist" do
+ rows = [{"b" => 1}, {"b" => 3}, {"b" => 1}]
+ @col.evaluate(rows).should be_nil
+ end
+end

0 comments on commit f37200e

Please sign in to comment.
Something went wrong with that request. Please try again.