class Level
Public Class Methods
new(levels)
click to toggle source
# File lib/cucumber-rest-bdd/level.rb, line 14 def initialize(levels) arr = [] while matches = /^ (?:for|in|on) ([^"]+?)(?: with (?:key|id))? "([^"]*)"/.match(levels) levels = levels[matches[0].length, levels.length] item = { resource: get_resource(matches[1]), id: matches[2] } item[:id] = item[:id].to_i if item[:id].match(/^\d+$/) arr.append(item) end @urls = arr.reverse end
Public Instance Methods
hash()
click to toggle source
# File lib/cucumber-rest-bdd/level.rb, line 32 def hash hash = {} @urls.each{ |l| hash[get_field("#{get_field(l[:resource]).singularize}_id")] = l[:id] } hash end
last_hash()
click to toggle source
# File lib/cucumber-rest-bdd/level.rb, line 38 def last_hash last = @urls.last if !last.nil? key = get_field("#{get_field(last[:resource]).singularize}_id") return { key => last[:id] } end return {} end
to_s()
click to toggle source
# File lib/cucumber-rest-bdd/level.rb, line 49 def to_s self.url end
url()
click to toggle source
# File lib/cucumber-rest-bdd/level.rb, line 28 def url @urls.map{ |l| "#{l[:resource]}/#{l[:id]}/"}.join() end