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
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