Sha256: 9d3ed5fd2971ae643f69fd795a2dcdd4d7df99ddfd73768552184be6487be4a0

Contents?: true

Size: 1.57 KB

Versions: 23

Compression:

Stored size: 1.57 KB

Contents

# -*- encoding : utf-8 -*-

def register_uri(name, uri_full)
  uri = URI.parse(uri_full)
  unless File.exists?("./test/fixtures/uri_#{name}.fake")
    pp "downloading new fixture from #{uri_full}"
    system "curl -s -i -G -d \"#{uri.query}\" #{uri.host}:#{uri.port}#{uri.path} > ./test/fixtures/uri_#{name}.fake" 
  end
  FakeWeb.register_uri(:get, "#{uri_full}", :response => "./test/fixtures/uri_#{name}.fake")
  #p "added #{@count_uries} url to fake web"
end

def register_uri_post(name, uri_full)
  uri = URI.parse(uri_full)
  if File.exists?("./test/fixtures_post_body/#{name}.txt")
    unless File.exists?("./test/fixtures/#{name}.fake")
      pp "downloading new fixture from POST #{uri_full}"
      system "curl -s -d \"@test/fixtures_post_body/post_body_#{name}.txt\" #{uri.host}:#{uri.port}#{uri.path} > ./test/fixtures/uri_#{name}.fake" 
    end
    body = ""
    File.open("./test/fixtures/uri_#{name}.fake", "r:UTF-8") do |fo|
      while( line = fo.gets) do
        body += line
      end
    end
    FakeWeb.register_uri(:post, "#{uri_full}", :body => body)
  else
    puts "YOU NEED TO CREATE FILE: test/fixtures_post_body/post_body_#{name}.txt which will contain POST body"
  end
  #p "added #{@count_uries} url to fake web"
end


#reports
#register_uri("foreman_report", "http://127.0.0.1:8877/report/foreman_report/adwords/ataxo/6170748009/1072676132/ALL_TIME")

#register_uri_post("refinery_relations_ataxo", "http://refinery.stage.internal.ataxo.com/relations/ataxo")

FakeWeb.allow_net_connect = true
p "FakeWeb registered and set to allow net connection: #{FakeWeb.allow_net_connect?}"

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
sklik-api-0.1.6 test/fake_web.rb
sklik-api-0.1.5 test/fake_web.rb
sklik-api-0.1.4 test/fake_web.rb
sklik-api-0.1.3 test/fake_web.rb
sklik-api-0.1.2 test/fake_web.rb
sklik-api-0.1.1 test/fake_web.rb
sklik-api-0.1.0 test/fake_web.rb
sklik-api-0.0.16 test/fake_web.rb
sklik-api-0.0.15 test/fake_web.rb
sklik-api-0.0.14 test/fake_web.rb
sklik-api-0.0.13 test/fake_web.rb
sklik-api-0.0.12 test/fake_web.rb
sklik-api-0.0.11 test/fake_web.rb
sklik-api-0.0.10 test/fake_web.rb
sklik-api-0.0.9 test/fake_web.rb
sklik-api-0.0.8 test/fake_web.rb
sklik-api-0.0.7 test/fake_web.rb
sklik-api-0.0.6 test/fake_web.rb
sklik-api-0.0.5 test/fake_web.rb
sklik-api-0.0.4 test/fake_web.rb