Class: Omise::Testing::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/omise/testing/resource.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, path, key) ⇒ Resource

Returns a new instance of Resource.



8
9
10
11
12
# File 'lib/omise/testing/resource.rb', line 8

def initialize(url, path, key)
  @uri = URI.parse(url)
  @uri.path = [@uri.path, path].join
  @key = key
end

Instance Method Details

#delete(attributes = {}) ⇒ Object



22
23
24
# File 'lib/omise/testing/resource.rb', line 22

def delete(attributes = {})
  Omise::Util.load_response(read_file("delete"))
end

#get(attributes = {}) ⇒ Object



14
15
16
# File 'lib/omise/testing/resource.rb', line 14

def get(attributes = {})
  Omise::Util.load_response(read_file("get"))
end

#patch(attributes = {}) ⇒ Object



18
19
20
# File 'lib/omise/testing/resource.rb', line 18

def patch(attributes = {})
  Omise::Util.load_response(read_file("patch"))
end

#post(attributes = {}) ⇒ Object



26
27
28
# File 'lib/omise/testing/resource.rb', line 26

def post(attributes = {})
  Omise::Util.load_response(read_file("post"))
end

#read_file(verb) ⇒ Object



30
31
32
33
34
35
# File 'lib/omise/testing/resource.rb', line 30

def read_file(verb)
  File.read(File.expand_path(File.join(
    Omise::LIB_PATH, "..", "test", "fixtures",
    [@uri.host, @uri.path, "-#{verb}.json"].join
  )))
end