Sha256: d49c7b2b4c8f9ef1d7ab3fffe16493c28a93f1f9d4ed9cc61ad52b21c24f0f8e

Contents?: true

Size: 919 Bytes

Versions: 9

Compression:

Stored size: 919 Bytes

Contents

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

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

include RR::Adapters::RRMethods
include WebMock
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

9 entries across 9 versions & 1 rubygems

Version Path
rest-graph-1.4.5 test/common.rb
rest-graph-1.4.4 test/common.rb
rest-graph-1.4.3 test/common.rb
rest-graph-1.4.2 test/common.rb
rest-graph-1.4.1 test/common.rb
rest-graph-1.4.0 test/common.rb
rest-graph-1.3.0 test/common.rb
rest-graph-1.2.1 test/common.rb
rest-graph-1.2.0 test/common.rb