Sha256: b5b490c3a7aacafa44f18a96d172c24653141a3d2bed5d14156ca0a47c08c14e

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 KB

Contents

require 'rubygems' if RUBY_VERSION < '1.9.2'
require 'rack'     if RUBY_VERSION < '1.9.2' # autoload broken in 1.8?
require 'rest-graph'

# need to require this before webmock in order to enable mocking in em-http
require 'em-http-request'

require 'rr'
require 'webmock'
require 'bacon'

# for testing lighten (serialization)
require 'yaml'

include RR::Adapters::RRMethods
include WebMock::API
WebMock.disable_net_connect!
Bacon.summary_on_exit

module TestHelper
  module_function
  def ensure_rollback
    yield

  ensure # the defaults should remain the same!
    RestGraph.send(:extend, RestGraph::DefaultAttributes.dup)

    TestHelper.attrs_no_callback.each{ |name|
      RestGraph.new.send(name).should ==
        RestGraph::DefaultAttributes.send("default_#{name}")
    }
  end

  def normalize_query query
    '?' + query[1..-1].split('&').sort.join('&')
  end

  def normalize_url url
    url.sub(/\?.+/){ |query| TestHelper.normalize_query(query) }
  end

  def attrs_no_callback
    RestGraph::Attributes.reject{ |attr|
      attr.to_s =~ /_handler/
    }
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rest-graph-2.0.3 test/common.rb
rest-graph-2.0.2 test/common.rb
rest-graph-2.0.1 test/common.rb
rest-graph-2.0.0 test/common.rb
rest-graph-1.9.1 test/common.rb
rest-graph-1.9.0 test/common.rb
rest-graph-1.8.0 test/common.rb
rest-graph-1.7.0 test/common.rb