Introduction
Introduction Statistics Contact Development Disclaimer Help
cleaned up specs - reportable - Fork of reportable required by WarVox, from hdm…
Log
Files
Refs
README
---
commit bbd76660d6b48d0a91aac63178aaa72b95d1a9d3
parent 415849fbf6a05c044df8465162a4218165f1d773
Author: marcoow <[email protected]>
Date: Fri, 12 Dec 2008 01:42:18 +0800
cleaned up specs
Signed-off-by: Marco Otte-Witte <[email protected]>
Diffstat:
M lib/kvlr/reports_as_sparkline/asse… | 2 +-
M lib/kvlr/reports_as_sparkline/grou… | 2 +-
M spec/models/report_method_spec.rb | 42 ++++++++---------------------…
M spec/other/cumulated_report_spec.rb | 8 ++++----
M spec/other/grouping_spec.rb | 55 +++++++++++++++++------------…
M spec/other/report_cache_spec.rb | 42 ++++++++++++++++++-----------…
M spec/other/report_spec.rb | 22 +++++++++++-----------
M spec/other/reporting_period_spec.rb | 127 +++++++++++++++--------------…
8 files changed, 142 insertions(+), 158 deletions(-)
---
diff --git a/lib/kvlr/reports_as_sparkline/asset_tag_helper.rb b/lib/kvlr/repor…
@@ -8,7 +8,7 @@ module Kvlr #:nodoc:
# Renders a sparkline with the given data.
def sparkline_tag(data, options = {})
options.reverse_merge!({:width => 300, :height => 34, :color => '0077C…
- data.collect! { |element| element[1].to_i }
+ data.collect! { |element| element[1].to_s }
image_tag(
"http://chart.apis.google.com/chart?cht=ls&chs=#{options[:width]}x#{…
)
diff --git a/lib/kvlr/reports_as_sparkline/grouping.rb b/lib/kvlr/reports_as_sp…
@@ -16,7 +16,7 @@ module Kvlr #:nodoc:
def date_parts_from_db_string(db_string)
if ActiveRecord::Base.connection.class.to_s == 'ActiveRecord::Connecti…
if @identifier == :hour
- return (db_string[0..9].split('-') + db_string[11..12]).map(&:to_i)
+ return (db_string[0..9].split('-') + [db_string[11..12]]).map(&:to…
elsif @identifier == :day
return db_string[0..9].split('-').map(&:to_i)
elsif @identifier == :week
diff --git a/spec/models/report_method_spec.rb b/spec/models/report_method_spec…
@@ -2,49 +2,27 @@ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
describe Kvlr::ReportsAsSparkline do
- describe 'generated <xyz>_report method' do
-
- it 'should raise an error when called with anything else than a hash' do
- lambda { User.registrations_report(1) }.should raise_error(Argum…
- lambda { User.registrations_report('invalid') }.should raise_error(Argum…
- lambda { User.registrations_report([1, 2]) }.should raise_error(Argum…
- end
-
- it 'should raise an error when called with multiple arguments' do
- lambda { User.registrations_report({ 1 => 2 }, { 3 => 4 }) }.should rais…
- end
-
- it 'should not raise an error when called with a hash' do
- lambda { User.registrations_report({ :limit => 1 }) }.should_not raise_e…
- end
-
- it 'should not raise an error when called without a parameter' do
- lambda { User.registrations_report }.should_not raise_error(ArgumentErro…
- end
-
- end
-
describe 'for inherited models' do
before(:all) do
- User.create!(:login => 'test 1', :created_at => Time.now - 1.week, :pro…
- User.create!(:login => 'test 2', :created_at => Time.now - 2.weeks, :pro…
- SpecialUser.create!(:login => 'test 3', :created_at => Time.now - 2.week…
+ User.create!(:login => 'test 1', :created_at => Time.now - 1.days, :pro…
+ User.create!(:login => 'test 2', :created_at => Time.now - 2.days, :prof…
+ SpecialUser.create!(:login => 'test 3', :created_at => Time.now - 2.days…
end
it 'should include all data when invoked on the base model class' do
result = User.registrations_report.to_a
- result.length.should == 20
- result[7][1].should == 1
- result[14][1].should == 2
+ result.length.should == 10
+ result[1][1].should == 1
+ result[2][1].should == 2
end
- it 'should include all data when invoked on the base model class' do
+ it 'should include only data for instances of the inherited model when inv…
result = SpecialUser.registrations_report.to_a
- result.length.should == 20
- result[14][1].should == 1
+ result.length.should == 10
+ result[2][1].should == 1
end
after(:all) do
@@ -61,7 +39,7 @@ describe Kvlr::ReportsAsSparkline do
end
class User < ActiveRecord::Base
- report_as_sparkline :registrations, :cumulate => true, :limit => 20
+ report_as_sparkline :registrations, :limit => 10
end
class SpecialUser < User; end
diff --git a/spec/other/cumulated_report_spec.rb b/spec/other/cumulated_report_…
@@ -48,7 +48,7 @@ describe Kvlr::ReportsAsSparkline::CumulatedReport do
end
- it 'should return correct data for :aggregation => :count' do
+ it 'should return correct data for aggregation :count' do
@report = Kvlr::ReportsAsSparkline::CumulatedReport.new(User, :regis…
result = @report.run
@@ -58,7 +58,7 @@ describe Kvlr::ReportsAsSparkline::CumulatedReport do
result[3][1].should == 2
end
- it 'should return correct data for :aggregation => :sum' do
+ it 'should return correct data for aggregation :sum' do
@report = Kvlr::ReportsAsSparkline::CumulatedReport.new(User, :regis…
result = @report.run()
@@ -68,7 +68,7 @@ describe Kvlr::ReportsAsSparkline::CumulatedReport do
result[3][1].should == 5
end
- it 'should return correct data with custom conditions for :aggregation…
+ it 'should return correct data for aggregation :count when custom cond…
@report = Kvlr::ReportsAsSparkline::CumulatedReport.new(User, :regis…
result = @report.run(:conditions => ['login IN (?)', ['test 1', 'tes…
@@ -78,7 +78,7 @@ describe Kvlr::ReportsAsSparkline::CumulatedReport do
result[3][1].should == 1
end
- it 'should return correct data with custom conditions for :aggregation…
+ it 'should return correct data for aggregation :sum when custom condit…
@report = Kvlr::ReportsAsSparkline::CumulatedReport.new(User, :regis…
result = @report.run(:conditions => ['login IN (?)', ['test 1', 'tes…
diff --git a/spec/other/grouping_spec.rb b/spec/other/grouping_spec.rb
@@ -42,20 +42,12 @@ describe Kvlr::ReportsAsSparkline::Grouping do
ActiveRecord::Base.connection.stub!(:class).and_return(ActiveRecord::C…
end
- it 'should use date_trunc with trunc "hour" for grouping :hour' do
- Kvlr::ReportsAsSparkline::Grouping.new(:hour).send(:to_sql, 'created_a…
- end
-
- it 'should use date_trunc with trunc "day" for grouping :day' do
- Kvlr::ReportsAsSparkline::Grouping.new(:day).send(:to_sql, 'created_at…
- end
+ for grouping in [:hour, :day, :week, :month] do
- it 'should use date_trunc with trunc "week" for grouping :week' do
- Kvlr::ReportsAsSparkline::Grouping.new(:week).send(:to_sql, 'created_a…
- end
+ it "should use date_trunc with truncation identifier \"#{grouping.to_s…
+ Kvlr::ReportsAsSparkline::Grouping.new(grouping).send(:to_sql, 'crea…
+ end
- it 'should use date_trunc with trunc "month" for grouping :month' do
- Kvlr::ReportsAsSparkline::Grouping.new(:month).send(:to_sql, 'created_…
end
end
@@ -87,21 +79,22 @@ describe Kvlr::ReportsAsSparkline::Grouping do
end
describe '#date_parts_from_db_string' do
-=begin
- for grouping in [[:hour, '2008/12/31/12'], [:day, '2008/12/31'], [:month, …
- it "should split the string with '/' for grouping :#{grouping[0].to_s}" …
- db_string = grouping[1]
+ describe 'for SQLite3' do
- Kvlr::ReportsAsSparkline::Grouping.new(grouping[0]).date_parts_from_db…
+ before do
+ ActiveRecord::Base.connection.stub!(:class).and_return(ActiveRecord::C…
end
- end
-=end
- describe 'for SQLite3' do
+ for grouping in [[:hour, '2008/12/31/12'], [:day, '2008/12/31'], [:month…
+
+ it "should split the string with '/' for grouping :#{grouping[0].to_s}…
+ Kvlr::ReportsAsSparkline::Grouping.new(grouping[0]).date_parts_from_…
+ end
+
+ end
it 'should split the string with "/" and increment the week by 1 for gro…
- ActiveRecord::Base.connection.stub!(:class).and_return(ActiveRecord::C…
db_string = '2008/2'
expected = [2008, 3]
@@ -116,6 +109,10 @@ describe Kvlr::ReportsAsSparkline::Grouping do
ActiveRecord::Base.connection.stub!(:class).and_return(ActiveRecord::C…
end
+ it 'should split the date part of the string with "-" and read out the h…
+ Kvlr::ReportsAsSparkline::Grouping.new(:hour).date_parts_from_db_strin…
+ end
+
it 'should split the date part of the string with "-" for grouping :day'…
Kvlr::ReportsAsSparkline::Grouping.new(:day).date_parts_from_db_string…
end
@@ -124,16 +121,24 @@ describe Kvlr::ReportsAsSparkline::Grouping do
Kvlr::ReportsAsSparkline::Grouping.new(:week).date_parts_from_db_strin…
end
+ it 'should split the date part of the string with "-" and return year an…
+ Kvlr::ReportsAsSparkline::Grouping.new(:month).date_parts_from_db_stri…
+ end
+
end
describe 'for MySQL' do
- it 'should split the string with "/" for grouping :week' do
+ before do
ActiveRecord::Base.connection.stub!(:class).and_return(ActiveRecord::C…
- db_string = '2008/2'
- expected = [2008, 2]
+ end
+
+ for grouping in [[:hour, '2008/12/31/12'], [:day, '2008/12/31'], [:week,…
+
+ it "should split the string with '/' for grouping :#{grouping[0].to_s}…
+ Kvlr::ReportsAsSparkline::Grouping.new(grouping[0]).date_parts_from_…
+ end
- Kvlr::ReportsAsSparkline::Grouping.new(:week).date_parts_from_db_strin…
end
end
diff --git a/spec/other/report_cache_spec.rb b/spec/other/report_cache_spec.rb
@@ -31,7 +31,7 @@ describe Kvlr::ReportsAsSparkline::ReportCache do
}.should raise_error(YieldMatchException)
end
- it 'should read existing data for the report from cache if no_cache' do
+ it 'should read existing data for the report from cache' do
Kvlr::ReportsAsSparkline::ReportCache.should_receive(:find).once.with(
:all,
:conditions => {
@@ -47,10 +47,14 @@ describe Kvlr::ReportsAsSparkline::ReportCache do
Kvlr::ReportsAsSparkline::ReportCache.process(@report, 10) { [] }
end
- it 'should update the cache' do
- Kvlr::ReportsAsSparkline::ReportCache.should_receive(:prepare_result)
+ it 'should prepare the results before it returns them' do
+ new_data = []
+ cached_data = []
+ Kvlr::ReportsAsSparkline::ReportCache.stub!(:find).and_return(cached_dat…
+ last_reporting_period_to_read = Kvlr::ReportsAsSparkline::ReportingPerio…
+ Kvlr::ReportsAsSparkline::ReportCache.should_receive(:prepare_result).on…
- Kvlr::ReportsAsSparkline::ReportCache.process(@report, 10) { [] }
+ Kvlr::ReportsAsSparkline::ReportCache.process(@report, 10) { new_data }
end
it 'should yield the first reporting period if the cache is empty' do
@@ -110,12 +114,12 @@ describe Kvlr::ReportsAsSparkline::ReportCache do
end
it 'should convert the date strings from the newly read data to reporting …
- Kvlr::ReportsAsSparkline::ReportingPeriod.should_receive(:from_db_string…
+ Kvlr::ReportsAsSparkline::ReportingPeriod.should_receive(:from_db_string…
Kvlr::ReportsAsSparkline::ReportCache.send(:prepare_result, @new_data, […
end
- it 'should create a new Kvlr::ReportsAsSparkline::ReportCache with the cor…
+ it 'should create a new Kvlr::ReportsAsSparkline::ReportCache with the cor…
Kvlr::ReportsAsSparkline::ReportCache.should_receive(:new).once.with(
:model_name => @report.klass.to_s,
:report_name => @report.name.to_s,
@@ -128,7 +132,7 @@ describe Kvlr::ReportsAsSparkline::ReportCache do
Kvlr::ReportsAsSparkline::ReportCache.send(:prepare_result, [], [], @las…
end
- it 'should create a new Kvlr::ReportsAsSparkline::ReportCache with the cor…
+ it 'should create a new Kvlr::ReportsAsSparkline::ReportCache with the cor…
Kvlr::ReportsAsSparkline::ReportCache.should_receive(:new).once.with(
:model_name => @report.klass.to_s,
:report_name => @report.name.to_s,
@@ -147,12 +151,6 @@ describe Kvlr::ReportsAsSparkline::ReportCache do
Kvlr::ReportsAsSparkline::ReportCache.send(:prepare_result, @new_data, […
end
- it 'should not save the created Kvlr::ReportsAsSparkline::ReportCache if n…
- @cached.should_not_receive(:save!)
-
- Kvlr::ReportsAsSparkline::ReportCache.send(:prepare_result, @new_data, […
- end
-
it 'should return an array of arrays of Dates and Floats' do
result = Kvlr::ReportsAsSparkline::ReportCache.send(:prepare_result, @ne…
@@ -175,11 +173,21 @@ describe Kvlr::ReportsAsSparkline::ReportCache do
Kvlr::ReportsAsSparkline::ReportCache.send(:prepare_result, @new_data, […
end
- it 'should not update the last cached record if new data has been read for…
- Kvlr::ReportsAsSparkline::ReportingPeriod.stub!(:from_db_string).and_ret…
- @cached.should_not_receive(:update_attributes!)
+ describe 'with no_cache = true' do
+
+ it 'should not save the created Kvlr::ReportsAsSparkline::ReportCache' do
+ @cached.should_not_receive(:save!)
+
+ Kvlr::ReportsAsSparkline::ReportCache.send(:prepare_result, @new_data,…
+ end
+
+ it 'should not update the last cached record if new data has been read f…
+ Kvlr::ReportsAsSparkline::ReportingPeriod.stub!(:from_db_string).and_r…
+ @cached.should_not_receive(:update_attributes!)
+
+ Kvlr::ReportsAsSparkline::ReportCache.send(:prepare_result, @new_data,…
+ end
- Kvlr::ReportsAsSparkline::ReportCache.send(:prepare_result, @new_data, […
end
end
diff --git a/spec/other/report_spec.rb b/spec/other/report_spec.rb
@@ -36,7 +36,7 @@ describe Kvlr::ReportsAsSparkline::Report do
User.create!(:login => 'test 3', :created_at => Time.now - 3.send(gr…
end
- it 'should return correct data for :aggregation => :count' do
+ it 'should return correct data for aggregation :count' do
@report = Kvlr::ReportsAsSparkline::Report.new(User, :registrations,…
result = @report.run.to_a
@@ -46,7 +46,7 @@ describe Kvlr::ReportsAsSparkline::Report do
result[3][1].should == 2
end
- it 'should return correct data for :aggregation => :sum' do
+ it 'should return correct data for aggregation :sum' do
@report = Kvlr::ReportsAsSparkline::Report.new(User, :registrations,…
result = @report.run().to_a
@@ -56,7 +56,7 @@ describe Kvlr::ReportsAsSparkline::Report do
result[3][1].should == 5
end
- it 'should return correct data with custom conditions for :aggregation…
+ it 'should return correct data for aggregation :count when custom cond…
@report = Kvlr::ReportsAsSparkline::Report.new(User, :registrations,…
result = @report.run(:conditions => ['login IN (?)', ['test 1', 'tes…
@@ -66,7 +66,7 @@ describe Kvlr::ReportsAsSparkline::Report do
result[3][1].should == 1
end
- it 'should return correct data with custom conditions for :aggregation…
+ it 'should return correct data for aggregation :sum when custom condit…
@report = Kvlr::ReportsAsSparkline::Report.new(User, :registrations,…
result = @report.run(:conditions => ['login IN (?)', ['test 1', 'tes…
@@ -99,7 +99,7 @@ describe Kvlr::ReportsAsSparkline::Report do
@report.send(:read_data, Time.now)
end
- it 'should build the conditions' do
+ it 'should setup the conditions' do
@report.should_receive(:setup_conditions).once.and_return([])
@report.send(:read_data, Time.now)
@@ -109,19 +109,19 @@ describe Kvlr::ReportsAsSparkline::Report do
describe '.setup_conditions' do
- it 'should return conditions for date_column_name >= begin_at only if no c…
+ it 'should return conditions for date_column_name >= begin_at only when no…
begin_at = Time.now
@report.send(:setup_conditions, begin_at).should == ['created_at >= ?', …
end
- it 'should return conditions for date_column_name >= begin_at only if an e…
+ it 'should return conditions for date_column_name >= begin_at only when an…
begin_at = Time.now
@report.send(:setup_conditions, begin_at, {}).should == ['created_at >= …
end
- it 'should return conditions for date_column_name >= begin_at only if an e…
+ it 'should return conditions for date_column_name >= begin_at only when an…
begin_at = Time.now
@report.send(:setup_conditions, begin_at, []).should == ['created_at >= …
@@ -176,8 +176,8 @@ describe Kvlr::ReportsAsSparkline::Report do
:limit => 100,
:aggregation => :count,
:grouping => :day,
- :date_column_name => 'created_at',
- :value_column_name => 'id',
+ :date_column_name => :created_at,
+ :value_column_name => :id,
:conditions => []
})
}.should_not raise_error(ArgumentError)
@@ -195,7 +195,7 @@ describe Kvlr::ReportsAsSparkline::Report do
lambda { @report.send(:ensure_valid_options, { :grouping => :decade })…
end
- it 'should raise an error if aggregation :sum is spesicied without the n…
+ it 'should raise an error if aggregation :sum is spesicied but no :value…
lambda { @report.send(:ensure_valid_options, { :aggregation => :sum })…
end
diff --git a/spec/other/reporting_period_spec.rb b/spec/other/reporting_period_…
@@ -4,69 +4,57 @@ describe Kvlr::ReportsAsSparkline::ReportingPeriod do
describe '.date_time' do
- describe 'for grouping :hour' do
-
- it 'should return the date and time with minutes = seconds = 0 for group…
- date_time = DateTime.now
- reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr:…
-
- reporting_period.date_time.should == DateTime.new(date_time.year, date…
- end
+ it 'should return the date and time with minutes = seconds = 0 for groupin…
+ date_time = DateTime.now
+ reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr::R…
+ reporting_period.date_time.should == DateTime.new(date_time.year, date_t…
end
- describe 'for grouping :day' do
-
- it 'should return the date part only for grouping :day' do
- date_time = DateTime.now
- reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr:…
-
- reporting_period.date_time.should == date_time.to_date
- end
+ it 'should return the date part only for grouping :day' do
+ date_time = DateTime.now
+ reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr::R…
+ reporting_period.date_time.should == date_time.to_date
end
describe 'for grouping :week' do
- it 'should return the date of the monday of the week date_time is in for…
+ it 'should return the date of the monday of the week date_time is in for…
date_time = DateTime.new(2008, 11, 27)
reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr:…
- reporting_period.date_time.should == DateTime.new(date_time.year, date…
+ reporting_period.date_time.should == Date.new(date_time.year, date_tim…
end
it 'should return the date of the monday of the week date_time is in whe…
date_time = DateTime.new(2008, 11, 24) #this is a monday already, shou…
reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr:…
- reporting_period.date_time.should == DateTime.new(date_time.year, date…
+ reporting_period.date_time.should == Date.new(date_time.year, date_tim…
end
it 'should return the date of the monday of the week date_time is in whe…
date_time = DateTime.new(2008, 11, 1) #this is a saturday
reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr:…
- reporting_period.date_time.should == DateTime.new(date_time.year, 10, …
+ reporting_period.date_time.should == Date.new(2008, 10, 27) # expect t…
end
it 'should return the date of the monday of the week date_time is in whe…
date_time = DateTime.new(2009, 1, 1) #this is a thursday
reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr:…
- reporting_period.date_time.should == DateTime.new(2008, 12, 29) # expe…
+ reporting_period.date_time.should == Date.new(2008, 12, 29) # expect t…
end
end
- describe 'for grouping :month' do
-
- it 'should return the date with day = 1 for grouping :month' do
- date_time = Time.now
- reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr:…
-
- reporting_period.date_time.should == Date.new(date_time.year, date_tim…
- end
+ it 'should return the date with day = 1 for grouping :month' do
+ date_time = Time.now
+ reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr::R…
+ reporting_period.date_time.should == Date.new(date_time.year, date_time.…
end
end
@@ -105,52 +93,36 @@ describe Kvlr::ReportsAsSparkline::ReportingPeriod do
describe '.previous' do
- describe 'for grouping :hour' do
-
- it 'should return a reporting period with date and time one hour before …
- now = Time.now
- reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr:…
- expected = now - 1.hour
-
- reporting_period.previous.date_time.should == DateTime.new(expected.ye…
- end
+ it 'should return a reporting period with date and time one hour before th…
+ now = Time.now
+ reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr::R…
+ expected = now - 1.hour
+ reporting_period.previous.date_time.should == DateTime.new(expected.year…
end
- describe 'for grouping :day' do
-
- it 'should return a reporting period with date one day before the curren…
- now = Time.now
- reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr:…
- expected = now - 1.day
-
- reporting_period.previous.date_time.should == Date.new(expected.year, …
- end
+ it 'should return a reporting period with date one day before the current …
+ now = Time.now
+ reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr::R…
+ expected = now - 1.day
+ reporting_period.previous.date_time.should == Date.new(expected.year, ex…
end
- describe 'for grouping :week' do
-
- it 'should return a reporting period with date one week before the curre…
- now = DateTime.now
- reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr:…
- expected = reporting_period.date_time - 1.week
-
- reporting_period.previous.date_time.should == Date.new(expected.year, …
- end
+ it 'should return a reporting period with date one week before the current…
+ now = DateTime.now
+ reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr::R…
+ expected = reporting_period.date_time - 1.week
+ reporting_period.previous.date_time.should == Date.new(expected.year, ex…
end
- describe 'for grouping :month' do
-
- it 'should return a reporting period with date one month before the curr…
- now = Time.now
- reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr:…
- expected = reporting_period.date_time - 1.month
-
- reporting_period.previous.date_time.should == Date.new(expected.year, …
- end
+ it 'should return a reporting period with date of the first day in the mon…
+ now = Time.now
+ reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr::R…
+ expected = reporting_period.date_time - 1.month
+ reporting_period.previous.date_time.should == Date.new(expected.year, ex…
end
end
@@ -173,6 +145,20 @@ describe Kvlr::ReportsAsSparkline::ReportingPeriod do
(reporting_period1 == reporting_period2).should == false
end
+ it 'should return true for 2 reporting periods with the same grouping but …
+ reporting_period1 = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr::…
+ reporting_period2 = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr::…
+
+ (reporting_period1 == reporting_period2).should == true
+ end
+
+ it 'should return false for 2 reporting periods with the same grouping but…
+ reporting_period1 = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr::…
+ reporting_period2 = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr::…
+
+ (reporting_period1 == reporting_period2).should == false
+ end
+
end
describe '#first' do
@@ -182,7 +168,7 @@ describe Kvlr::ReportsAsSparkline::ReportingPeriod do
DateTime.stub!(:now).and_return(@now)
end
- it 'should return a reporting period with the date part of (DateTime.now -…
+ it 'should return a reporting period with the date part of (DateTime.now -…
reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.first(Kvlr:…
expected = @now - 3.hours
@@ -196,7 +182,14 @@ describe Kvlr::ReportsAsSparkline::ReportingPeriod do
reporting_period.date_time.should == Date.new(expected.year, expected.mo…
end
- it 'should return a reporting period with the date of monday of the week a…
+ it 'should return a reporting period with the date of the first day of the…
+ DateTime.stub!(:now).and_return(DateTime.new(2008, 12, 31, 0, 0, 0))
+ reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.first(Kvlr:…
+
+ reporting_period.date_time.should == DateTime.new(2008, 9, 1)
+ end
+
+ it 'should return a reporting period with the date of the monday of the we…
DateTime.stub!(:now).and_return(DateTime.new(2008, 12, 31, 0, 0, 0)) #we…
reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.first(Kvlr:…
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.