Sha256: 539ea2f070ef2b7746544f9dca7e8e3387a31ee95d4a286766622a5a78a80f2b

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'mitamirri'

describe "LeadsReport" do

  before :all do
    @args = {
      :site => 'www.foo.com',
      :time_period => 'past month',
    }
    TrackableSession.stubs(:search).returns([])
    @report = Mitamirri::LeadsReport.new(@args)
  
  end
  
  it 'initializes with arguments' do
    @report.site.should == @args[:site]
    @report.time_period.should == @args[:time_period]
    @report.start_date.should == (Time.zone.now - 4.weeks).beginning_of_week
    @report.end_date.to_s(:concise).should == Time.zone.now.to_s(:concise)
  end

  it 'calculates its dates' do
    @report.dates.map{|d| d.to_s(:concise)}.should == [
      (Time.zone.now - 4.weeks).beginning_of_week.to_s(:concise),
      (Time.zone.now - 3.weeks).beginning_of_week.to_s(:concise),
      (Time.zone.now - 2.weeks).beginning_of_week.to_s(:concise),
      (Time.zone.now - 1.weeks).beginning_of_week.to_s(:concise),
      Time.zone.now.to_s(:concise),
    ]
  end
  
  it 'creates a Lead object from arguments' do
    _lead = Mitamirri::LeadsReport::Lead.new(:stats => ['foo'])
    _lead.stats.should == ['foo']
  end
  
  it 'creates a LeadStats object from arguments' do
    _stat = Mitamirri::LeadsReport::LeadStat.new(:date => Time.zone.now.end_of_week, :leads => 3, :conversion_rate => 50.0)
    _stat.date.should == Time.zone.now.end_of_week
    _stat.leads.should == 3
    _stat.conversion_rate.should == 50.0
    _stat.short_date.should == Time.zone.now.end_of_week.to_s(:concise)
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mitamirri-0.13.8 spec/lib/leads_report_spec.rb