public
Description: StatWhore is for the stat addict in all of us. Eventually it will become a ruby wrapper for several web stat services apis. Initially, it will cover Google Analytics and Feedburner.
Homepage: http://rubyforge.org/projects/statwhore/
Clone URL: git://github.com/jnunemaker/statwhore.git
Click here to lend your support to: statwhore and make a donation at www.pledgie.com !
jnunemaker (author)
Wed Jul 30 20:16:23 -0700 2008
commit  b0fb0ab88397831ab49ad0ce70a321de4483efea
tree    4769e6c58798fb87340a47cf6650d7c24358f2f2
parent  be06c44ff61159cf037388ad38940e0055b3791c
statwhore / spec / statwhore_google_analytics_account_spec.rb
100644 39 lines (30 sloc) 1.551 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require File.dirname(__FILE__) + '/spec_helper.rb'
 
describe "Statwhore::Google::Analytics::Account" do
  
  describe "being initialized" do
    
    it "should accept :name as key" do
      a = Statwhore::Google::Analytics::Account.new(:name => 'test')
      a.name.should == 'test'
    end
    
    it "should accept :account_id as key" do
      a = Statwhore::Google::Analytics::Account.new(:account_id => '12341234')
      a.account_id.should == '12341234'
    end
    
  end
  
  it "should be able to find all accounts for user" do
    html = open(File.dirname(__FILE__) + '/fixtures/analytics_account_find_all.html').read
    Statwhore::Google::Analytics::Account.should_receive(:get).and_return(html)
    accounts = Statwhore::Google::Analytics::Account.find_all
    accounts.collect(&:name).should == %w[alumni.nd.edu webgroup.nd.edu]
    accounts.collect(&:account_id).should == %w[1254221 344381].map(&:to_i)
  end
  
  it "should be able to find profiles for an account" do
    html = open(File.dirname(__FILE__) + '/fixtures/analytics_profile_find_all.html').read
    Statwhore::Google::Analytics::Profile.should_receive(:get).and_return(html)
    accounts = Statwhore::Google::Analytics::Account.new(:name => 'alumni.nd.edu', :account_id => '1254221').profiles
    accounts.collect(&:name).should == ["pray.nd.edu"]
  end
  
  it "should print kind of pretty" do
    account = Statwhore::Google::Analytics::Account.new(:name => 'alumni.nd.edu', :account_id => '1254221')
    account.to_s.should == "alumni.nd.edu (1254221)"
  end
  
end