Skip to content

Instantly share code, notes, and snippets.

@regedarek
Created February 7, 2012 01:17
Show Gist options
  • Save regedarek/1756398 to your computer and use it in GitHub Desktop.
Save regedarek/1756398 to your computer and use it in GitHub Desktop.
require 'faraday'
require 'forwardable'
module Soup
class Agent
extend Forwardable
def initialize(domain = 'https://www.soup.io/')
@agent ||= faraday(domain)
end
def_delegators :@agent, :get, :post, :response_headers, :body, :status
def faraday(domain)
Faraday.new(url: domain) do |builder|
builder.use Faraday::Request::UrlEncoded
builder.use Faraday::Response::Logger
builder.use Faraday::Adapter::NetHttp
end
end
end
end
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Soup Agent" do
before do
@agent = Soup::Agent.new
end
it "should connect to soup.io" do
@host.should == "www.soup.io"
end
end
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
require 'soup-client'
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
RSpec.configure do |config|
end
@regedarek
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment