Sha256: dc97db152336283bdbc1de017885c50a64151b867aa2f550d2ece3bd8f0cddf6

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

require 'test/unit'
require 'shoulda'
require 'fakeweb'

require 'rapidshare-ext'

class Test::Unit::TestCase

  # don't allow internet connections for testing (we should use fixtures, except
  # integration testing)
  FakeWeb.allow_net_connect = false

  def read_fixture(filename, extension = 'txt')
    # add extension to file unless it already has it
    filename += ".#{extension}" unless (filename =~ /\.\w+$/)

    File.read File.expand_path(File.dirname(__FILE__) + "/fixtures/#{filename}")
  end

  # general setup, can be overriden or extended in specific tests
  #
  def setup
    @cookie = 'F0EEB41B38363A41F0D125102637DB7236468731F8DB760DC57934B4714C8D13'

    # mock http requests for login into Rapidshare
    #
    FakeWeb.register_uri(:get,
      'https://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=getaccountdetails&login=valid_login&password=valid_password&withcookie=1&cookie=',
      :body => read_fixture('getaccountdetails_valid.txt')
    )

    FakeWeb.register_uri(:get,
      "https://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=getaccountdetails&cookie=#{@cookie}",
      :body => read_fixture('getaccountdetails_valid.txt')
    )

    @rs = Rapidshare::API.new(:login => 'valid_login', :password => 'valid_password')
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rapidshare-ext-0.0.2 test/test_helper.rb
rapidshare-ext-0.0.1 test/test_helper.rb