Sha256: 18769c9d4fd5fde1261db447694780e8f4555b46c290199182b2c2e9c76d8059

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

require 'json_expressions/rspec'
require 'rack/test'
require 'pp'

require_relative '../lib/restful_objects.rb'

class Array
  def status
    self[0]
  end

  def headers
    self[1]
  end

  def body
    self[2]
  end
end

module Helpers
  def app
    RestfulObjects::Router::Base
  end

  def model
    RestfulObjects::DomainModel.current
  end

  def pretty_print_json(json_string)
    puts JSON.pretty_generate(JSON.parse(json_string))
  end
end

module JsonExpressions
  module RSpec
    module Matchers
      class MatchJsonExpression
        def failure_message_for_should
          "expected:\n#{JSON.pretty_generate @target}\n to match JSON expression:\n#{@expected.inspect}\n\n" + 
            @expected.last_error
        end

        def failure_message_for_should_not
          "expected:\n#{JSON.pretty_generate @target}\n not to match JSON expression:\n#{@expected.inspect}\n"
        end

        def description
          "should equal JSON expression:\n#{@expected.inspect}\n"
        end
      end
    end
  end
end


RSpec::configure do |config|
  config.include(Helpers)
  config.include Rack::Test::Methods
end

JsonExpressions::Matcher.assume_strict_arrays = false
JsonExpressions::Matcher.assume_strict_hashes = false

RestfulObjects::Router::Base.set :show_exceptions, false
RestfulObjects::Router::Base.set :raise_errors,    true

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
restful_objects-0.0.8 spec/spec_helper.rb
restful_objects-0.0.7 spec/spec_helper.rb
restful_objects-0.0.6 spec/spec_helper.rb