Sha256: d76db283f1f1fec9e7a4bfab43c93e45a7db013378731d5a4222aa0c5147b31d

Contents?: true

Size: 1.32 KB

Versions: 22

Compression:

Stored size: 1.32 KB

Contents

require "rubygems"
require "bundler"
Bundler.setup

require 'rspec'
require 'artifice'

$: << File.join(File.dirname(__FILE__), '..', 'lib')
require 'socialcastr'

RSpec.configure do |config|
  config.before :each do 
    Socialcastr.configuration.reset
  end
end
def generate_fake_endpoint(response, code=200)
  return proc { |env|
    [code, {"Content-Type"  => "text/html",
           "X-Test-Method" => env["REQUEST_METHOD"],
           "X-Test-Input"  => env["rack.input"].read,
           "X-Test-Scheme" => env["rack.url_scheme"],
           "X-Test-Host"   => env["HTTP_HOST"] || env["SERVER_NAME"],
           "X-Test-Port"   => env["SERVER_PORT"]},
      [response]
    ]
  }
end

def configure_socialcastr
    Socialcastr.configuration do |c|
      c.username = "demo"
      c.password = "password"
      c.domain   = "demo.socialcast.com"
    end
end

def fake_socialcast_api_for(type, &block)
  configure_socialcastr
  case type
  when :message
    responsefile = "message.xml"
  when :messages
    responsefile = "messages.xml"
  end
  response = File.read(File.join(File.dirname(__FILE__), 'fixtures', responsefile))
  endpoint = generate_fake_endpoint(response)
  if block
    Artifice.activate_with(generate_fake_endpoint(response)) do
      block.call
    end
  else
    Artifice.activate_with(generate_fake_endpoint(response))
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
socialcastr-0.2.17 spec/spec_helper.rb
socialcastr-0.2.16 spec/spec_helper.rb
socialcastr-0.2.15 spec/spec_helper.rb
socialcastr-0.2.14 spec/spec_helper.rb
socialcastr-0.2.13 spec/spec_helper.rb
socialcastr-0.2.12 spec/spec_helper.rb
socialcastr-0.2.11 spec/spec_helper.rb
socialcastr-0.2.10 spec/spec_helper.rb
socialcastr-0.2.9 spec/spec_helper.rb
socialcastr-0.2.8 spec/spec_helper.rb
socialcastr-0.2.7 spec/spec_helper.rb
socialcastr-0.2.6 spec/spec_helper.rb
socialcastr-0.2.5 spec/spec_helper.rb
socialcastr-0.2.4 spec/spec_helper.rb
socialcastr-0.2.3 spec/spec_helper.rb
socialcastr-0.2.2 spec/spec_helper.rb
socialcastr-0.2.1 spec/spec_helper.rb
socialcastr-0.2.0 spec/spec_helper.rb
socialcastr-0.1.3 spec/spec_helper.rb
socialcastr-0.1.2 spec/spec_helper.rb