Skip to content

Commit

Permalink
Added additional unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Brad Seefeld committed Jun 7, 2011
1 parent c25f1cd commit f37200e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/rgviz/data_table.rb
Expand Up @@ -5,6 +5,7 @@
require "rgviz/data_table/column_value_filter" require "rgviz/data_table/column_value_filter"
require "rgviz/data_table/column" require "rgviz/data_table/column"
require "rgviz/data_table/sum_column" require "rgviz/data_table/sum_column"
require "rgviz/data_table/max_column"
require "rgviz/data_table/order" require "rgviz/data_table/order"


module Rgviz module Rgviz
Expand Down
2 changes: 1 addition & 1 deletion lib/rgviz/data_table/max_column.rb
@@ -1,6 +1,6 @@
module Rgviz module Rgviz
module DataTable module DataTable
class MaxColumn class MaxColumn < Rgviz::DataTable::Column


def evaluate(rows) def evaluate(rows)
max = nil max = nil
Expand Down
22 changes: 22 additions & 0 deletions 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.