Sha256: fd56f63d29b0a7312129b316bee49837e9396c5df1c08c1a761678a380752846

Contents?: true

Size: 1.31 KB

Versions: 10

Compression:

Stored size: 1.31 KB

Contents

require File.join(File.dirname(__FILE__), '..', '..', '/test_helper')

class TestReport
  extend Garb::Resource
end

# Most of the resource testing is done as a part of ReportTest
class ResourceTest < MiniTest::Unit::TestCase

  context "A class with Garb::Resource mixed in" do
    should "get results from GA" do
      profile = stub(:is_a? => true)
      TestReport.expects(:send_request_for_body).returns('xml')
      Garb::ReportResponse.expects(:new).with('xml').returns(mock(:results => 'analytics'))

      assert_equal 'analytics', TestReport.results(profile)
    end

    should "get results from GA using a specific user session" do
      profile = '123'
      session = Garb::Session.new
      TestReport.expects(:send_request_for_body).returns('xml')
      Garb::ReportResponse.expects(:new).with('xml').returns(mock(:results => 'analytics'))
      Garb::Profile.expects(:first).with(profile, session).returns(mock('Garb::Profile'))

      assert_equal 'analytics', TestReport.results(profile, :session => session)
    end

    should "return an empty result set if profile is invalid" do
      profile = '123'
      TestReport.expects(:send_request_for_body).never
      Garb::ReportResponse.expects(:new).never

      Garb::Profile.expects(:first).returns(nil)
      assert_equal [], TestReport.results(profile)
    end
  end
end

Version data entries

10 entries across 10 versions & 4 rubygems

Version Path
garb-0.7.5 test/unit/garb/resource_test.rb
shingara-garb-0.7.6 test/unit/garb/resource_test.rb
garb-no-activesupport-0.7.4 test/unit/garb/resource_test.rb
garb-0.7.4 test/unit/garb/resource_test.rb
garb-no-activesupport-0.7.3 test/unit/garb/resource_test.rb
garb-0.7.3 test/unit/garb/resource_test.rb
garb-0.7.2 test/unit/garb/resource_test.rb
garb-0.7.1 test/unit/garb/resource_test.rb
garb-authsub-0.7.0 test/unit/garb/resource_test.rb
garb-0.7.0 test/unit/garb/resource_test.rb