spec/classes/report_spec.rb in reportable-1.1.2 vs spec/classes/report_spec.rb in reportable-1.2.0
- old
+ new
@@ -1,6 +1,6 @@
-require File.join(File.dirname(__FILE__), '..', 'spec_helper')
+require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))),'spec_helper')
describe Saulabs::Reportable::Report do
before do
@report = Saulabs::Reportable::Report.new(User, :registrations)
@@ -54,17 +54,17 @@
end
it 'should return an array of the same length as the specified limit when :live_data is false' do
@report = Saulabs::Reportable::Report.new(User, :cumulated_registrations, :limit => 10, :live_data => false)
- @report.run.length.should == 10
+ @report.run.to_a.length.should == 10
end
it 'should return an array of the same length as the specified limit + 1 when :live_data is true' do
@report = Saulabs::Reportable::Report.new(User, :cumulated_registrations, :limit => 10, :live_data => true)
- @report.run.length.should == 11
+ @report.run.to_a.length.should == 11
end
for grouping in [:hour, :day, :week, :month] do
describe "for grouping :#{grouping.to_s}" do
@@ -96,11 +96,11 @@
@report = Saulabs::Reportable::Report.new(User, :registrations,
:grouping => grouping,
:limit => 10,
:end_date => @end_date
)
- @result = @report.run
+ @result = @report.run.to_a
end
it "should start with the reporting period (end_date - limit.#{grouping.to_s})" do
@result.first[0].should == Saulabs::Reportable::ReportingPeriod.new(@grouping, @end_date - 9.send(grouping)).date_time
end
@@ -125,10 +125,10 @@
@report = Saulabs::Reportable::Report.new(User, :registrations,
:grouping => grouping,
:limit => 10,
:live_data => live_data
)
- @result = @report.run
+ @result = @report.run.to_a
end
it "should be an array starting reporting period (Time.now - limit.#{grouping.to_s})" do
@result.first[0].should == Saulabs::Reportable::ReportingPeriod.new(@grouping, Time.now - 10.send(grouping)).date_time
end