Sha256: dd5b569137ad78e3c446c5205ce9ca470cf8270a18f9175d9eaf51cf4179bc8e

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

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

include MarketBot::Android

test_developer_id = 'Zynga'

def stub_hydra(hydra)
  test_src_pages = []
  test_src_pages[0] = read_file(File.dirname(__FILE__), 'data', "developer-zynga.txt")

  response = Typhoeus::Response.new(:code => 200, :headers => '', :body => test_src_pages[0])
  url = "https://play.google.com/store/apps/developer?id=Zynga&hl=en"
  Typhoeus.stub(url).and_return(response)
end

def check_results(results)
  it 'should return valid results' do
    results.length.should == 24
    results[0][:title].should == "New Words With Friends"
  end
end

describe 'developer' do
  context 'Construction' do
    it 'should copy params' do
      dev = Developer.new(test_developer_id)
      dev.identifier.should == test_developer_id
    end

    it 'should copy optional params' do
      hydra = Typhoeus::Hydra.new
      dev = Developer.new(test_developer_id, :hydra => hydra)
      dev.hydra.should equal(hydra)
    end
  end

  describe 'Updating' do
    context 'Quick API' do
      stub_hydra(Typhoeus::Hydra.hydra)
      dev = Developer.new(test_developer_id)
      dev.instance_variable_set('@hydra', Typhoeus::Hydra.hydra)
      dev.update

      check_results(dev.results)
    end

    context 'Batch API' do
      hydra = Typhoeus::Hydra.new
      stub_hydra(hydra)
      dev = Developer.new(test_developer_id, :hydra => hydra)
      dev.enqueue_update
      hydra.run

      check_results(dev.results)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
market_bot-0.14.0 spec/market_bot/android/developer_spec.rb
market_bot-0.13.0 spec/market_bot/android/developer_spec.rb
market_bot-0.12.2 spec/market_bot/android/developer_spec.rb