Top Level Namespace

Defined Under Namespace

Modules: RackRestRspec Classes: RestService

Instance Method Summary collapse

Instance Method Details

#compare_array_of_hash(expected, actual) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/rack-rest-rspec/matchers/respond_with_data.rb', line 3

def compare_array_of_hash(expected, actual)
  return false unless expected.size == actual.size

  res = true
  actual.each_with_index do |item, index|
    res = false unless item == expected[index]
  end
  res
end

#get_file(file) ⇒ Object



5
6
7
# File 'lib/rack-rest-rspec/helpers/yml.rb', line 5

def get_file(file)
  YAML.load(File.readlines(file).join)
end

#memorize(options) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/rack-rest-rspec/helpers/memorizer.rb', line 5

def memorize(options)
  $store = PStore.new('/tmp/data.pstore')
  $store.transaction do
    options.each do |key, val|
      $store[key] = val
    end
    $store.commit
  end
end

#prepare_array(data) ⇒ Object



13
14
15
# File 'lib/rack-rest-rspec/matchers/respond_with_data.rb', line 13

def prepare_array(data)
  data.instance_of?(Hash) ? [data] : data
end

#retrieve(key) ⇒ Object



15
16
17
18
# File 'lib/rack-rest-rspec/helpers/memorizer.rb', line 15

def retrieve(key)
  $store = PStore.new('/tmp/data.pstore')
  $store.transaction { $store[key] }
end