jnunemaker / statwhore

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.

This URL has Read+Write access

statwhore / spec / statwhore_google_analytics_account_spec.rb
23919fa1 » jnunemaker 2008-03-08 switched to rspec, got it w... 1 require File.dirname(__FILE__) + '/spec_helper.rb'
2
3 describe "Statwhore::Google::Analytics::Account" do
4
5 describe "being initialized" do
6
7 it "should accept :name as key" do
8 a = Statwhore::Google::Analytics::Account.new(:name => 'test')
9 a.name.should == 'test'
10 end
11
12 it "should accept :account_id as key" do
13 a = Statwhore::Google::Analytics::Account.new(:account_id => '12341234')
14 a.account_id.should == '12341234'
15 end
16
17 end
18
19 it "should be able to find all accounts for user" do
20 html = open(File.dirname(__FILE__) + '/fixtures/analytics_account_find_all.html').read
21 Statwhore::Google::Analytics::Account.should_receive(:get).and_return(html)
22 accounts = Statwhore::Google::Analytics::Account.find_all
23 accounts.collect(&:name).should == %w[alumni.nd.edu webgroup.nd.edu]
24 accounts.collect(&:account_id).should == %w[1254221 344381].map(&:to_i)
25 end
26
27 it "should be able to find profiles for an account" do
28 html = open(File.dirname(__FILE__) + '/fixtures/analytics_profile_find_all.html').read
29 Statwhore::Google::Analytics::Profile.should_receive(:get).and_return(html)
30 accounts = Statwhore::Google::Analytics::Account.new(:name => 'alumni.nd.edu', :account_id => '1254221').profiles
31 accounts.collect(&:name).should == ["pray.nd.edu"]
32 end
33
34 it "should print kind of pretty" do
35 account = Statwhore::Google::Analytics::Account.new(:name => 'alumni.nd.edu', :account_id => '1254221')
36 account.to_s.should == "alumni.nd.edu (1254221)"
37 end
38
39 end