Module: GraphitiGql::SpecHelper

Extended by:
ActiveSupport::Concern
Defined in:
lib/graphiti_gql/spec_helper.rb

Defined Under Namespace

Modules: ScopeTrackable

Instance Method Summary collapse

Instance Method Details

#gid(*ids) ⇒ Object



77
78
79
# File 'lib/graphiti_gql/spec_helper.rb', line 77

def gid(*ids)
  resource.gid(*ids)
end

#gql_datetime(timestamp, precise = false) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/graphiti_gql/spec_helper.rb', line 62

def gql_datetime(timestamp, precise = false)
  if precise
    timestamp.utc.round(10).iso8601(6)
  else
    DateTime.parse(timestamp.to_s).iso8601
  end
end

#jsonObject



98
99
100
# File 'lib/graphiti_gql/spec_helper.rb', line 98

def json
  @json ||= result.response
end

#proxyObject



70
71
72
73
74
75
# File 'lib/graphiti_gql/spec_helper.rb', line 70

def proxy
  q = defined?(query) ? query : nil
  with_pagination = respond_to?(:with_pagination) ? send(:with_pagination) : false
  opts = { with_pagination: with_pagination }
  resource.gql(params.merge(fields: fields), ctx, q, opts)
end

#resultObject



94
95
96
# File 'lib/graphiti_gql/spec_helper.rb', line 94

def result
  @result ||= run!
end

#runObject



81
82
83
84
85
86
87
# File 'lib/graphiti_gql/spec_helper.rb', line 81

def run
  lambda do
    instance = proxy
    instance.run!
    instance
  end
end

#run!Object



89
90
91
92
# File 'lib/graphiti_gql/spec_helper.rb', line 89

def run!
  @json = nil
  @result = run.call
end