Created
February 7, 2012 01:17
-
-
Save regedarek/1756398 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The whole code is here: https://github.com/regedarek/soup-client/blob/tests/spec/soup_spec.rb