Module: Calabash::Cucumber::Core

Included in:
KeyboardHelpers, Location, Operations, TestsHelpers, WaitHelpers
Defined in:
lib/calabash-cucumber/core.rb

Constant Summary collapse

DATA_PATH =
File.expand_path(File.dirname(__FILE__))
CAL_HTTP_RETRY_COUNT =
3
RETRYABLE_ERRORS =
[HTTPClient::TimeoutError,
HTTPClient::KeepAliveDisconnected,
Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ECONNABORTED,
Errno::ETIMEDOUT]

Instance Method Summary collapse

Instance Method Details

#backdoor(sel, arg) ⇒ Object


482
483
484
485
486
487
488
489
490
491
492
493
# File 'lib/calabash-cucumber/core.rb', line 482

def backdoor(sel, arg)
  json = {
      :selector => sel,
      :arg => arg
  }
  res = http({:method => :post, :path => 'backdoor'}, json)
  res = JSON.parse(res)
  if res['outcome'] != 'SUCCESS'
    screenshot_and_raise "backdoor #{json} failed because: #{res['reason']}\n#{res['details']}"
  end
  res['result']
end

#background(secs) ⇒ Object


271
272
273
# File 'lib/calabash-cucumber/core.rb', line 271

def background(secs)
  set_user_pref("__calabash_action", {:action => :background, :duration => secs})
end

#calabash_exitObject


495
496
497
498
499
500
501
502
503
504
# File 'lib/calabash-cucumber/core.rb', line 495

def calabash_exit
  # Exiting the app shuts down the HTTP connection and generates ECONNREFUSED,
  # or HTTPClient::KeepAliveDisconnected
  # which needs to be suppressed.
  begin
    http({:method =>:post, :path => 'exit', :retryable_errors => RETRYABLE_ERRORS - [Errno::ECONNREFUSED,HTTPClient::KeepAliveDisconnected]})
  rescue Errno::ECONNREFUSED, HTTPClient::KeepAliveDisconnected
    []
  end
end

#cell_swipe(options = {}) ⇒ Object


146
147
148
# File 'lib/calabash-cucumber/core.rb', line 146

def cell_swipe(options={})
  playback("cell_swipe", options)
end

#client_versionObject


35
36
37
# File 'lib/calabash-cucumber/core.rb', line 35

def client_version
  Calabash::Cucumber::VERSION
end

#current_rotationObject

Current position of home button


227
228
229
# File 'lib/calabash-cucumber/core.rb', line 227

def current_rotation
  @current_rotation
end

#default_deviceObject


538
539
540
# File 'lib/calabash-cucumber/core.rb', line 538

def default_device
  @calabash_launcher && @calabash_launcher.device
end

#flash(uiquery, *args) ⇒ Object


27
28
29
# File 'lib/calabash-cucumber/core.rb', line 27

def flash(uiquery, *args)
  map(uiquery, :flash, *args)
end

#http(options, data = nil) ⇒ Object


551
552
553
554
555
556
557
558
559
560
561
562
563
564
# File 'lib/calabash-cucumber/core.rb', line 551

def http(options, data=nil)
  options[:uri] = url_for(options[:path])
  options[:method] = options[:method] || :get
  if data
    if options[:raw]
      options[:body] = data
    else
      options[:body] = data.to_json
    end
  end
  res = make_http_request(options)
  res.force_encoding("UTF-8") if res.respond_to?(:force_encoding)
  res
end

#init_request(url) ⇒ Object


621
622
623
624
625
626
627
628
629
630
# File 'lib/calabash-cucumber/core.rb', line 621

def init_request(url)
  http = HTTPClient.new
  http.connect_timeout = 15
  http.send_timeout = 15
  http.receive_timeout = 15
  if ENV['DEBUG_HTTP'] and (ENV['DEBUG_HTTP'] != "0")
    http.debug_dev = $stdout
  end
  http
end

#interpolate(recording, options = {}) ⇒ Object


427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
# File 'lib/calabash-cucumber/core.rb', line 427

def interpolate(recording, options={})
  data = load_playback_data(recording)

  post_data = %Q|{"events":"#{data}"|
  post_data<< %Q|,"start":"#{escape_quotes(options[:start])}"| if options[:start]
  post_data<< %Q|,"end":"#{escape_quotes(options[:end])}"| if options[:end]
  post_data<< %Q|,"offset_start":#{options[:offset_start].to_json}| if options[:offset_start]
  post_data<< %Q|,"offset_end":#{options[:offset_end].to_json}| if options[:offset_end]
  post_data << "}"

  res = http({:method => :post, :raw => true, :path => 'interpolate'}, post_data)

  res = JSON.parse(res)
  if res['outcome'] != 'SUCCESS'
    screenshot_and_raise "interpolate failed because: #{res['reason']}\n#{res['details']}"
  end
  res['results']
end

#load_playback_data(recording_name, options = {}) ⇒ Object


357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# File 'lib/calabash-cucumber/core.rb', line 357

def load_playback_data(recording_name, options={})
  os = options["OS"] || ENV["OS"]
  device = options["DEVICE"] || ENV["DEVICE"] || "iphone"

  unless os
    if @calabash_launcher && @calabash_launcher.active?
      major = @calabash_launcher.ios_major_version
    else
      major = Calabash::Cucumber::SimulatorHelper.ios_major_version
    end

    unless major
      raise <<EOF
    Unable to determine iOS major version
    Most likely you have updated your calabash-cucumber client
    but not your server. Please follow closely:

https://github.com/calabash/calabash-ios/wiki/B1-Updating-your-Calabash-iOS-version

    If you are running version 0.9.120+ then please report this message as a bug.
EOF
    end
    os = "ios#{major}"
  end

  rec_dir = ENV['PLAYBACK_DIR'] || "#{Dir.pwd}/playback"

  recording = recording_name_for(recording_name, os, device)
  data = load_recording(recording, rec_dir)

  if data.nil? and os=="ios6"
    recording = recording_name_for(recording_name, "ios5", device)
    data = load_recording(recording, rec_dir)
  end

  if data.nil? and device=='ipad'
    if ENV['FULL_CONSOLE_OUTPUT'] == '1'
      puts "Unable to find recording for #{os} and #{device}. Trying with #{os} iphone"
    end
    recording = recording_name_for(recording_name, os, 'iphone')
    data = load_recording(recording, rec_dir)
  end


  if data.nil?
    screenshot_and_raise "Playback not found: #{recording} (searched for #{recording} in #{Dir.pwd}, #{rec_dir}, #{DATA_PATH}/resources"
  end

  data
end

#load_recording(recording, rec_dir) ⇒ Object


343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/calabash-cucumber/core.rb', line 343

def load_recording(recording, rec_dir)
  data = nil
  if (File.exists?(recording))
    data = File.read(recording)
  elsif (File.exists?("features/#{recording}"))
    data = File.read("features/#{recording}")
  elsif (File.exists?("#{rec_dir}/#{recording}"))
    data = File.read("#{rec_dir}/#{recording}")
  elsif (File.exists?("#{DATA_PATH}/resources/#{recording}"))
    data = File.read("#{DATA_PATH}/resources/#{recording}")
  end
  data
end

#macro(txt) ⇒ Object


15
16
17
18
19
20
21
# File 'lib/calabash-cucumber/core.rb', line 15

def macro(txt)
  if self.respond_to? :step
    step(txt)
  else
    Then txt
  end
end

#make_http_request(options) ⇒ Object


579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
# File 'lib/calabash-cucumber/core.rb', line 579

def make_http_request(options)

  body = nil
  retryable_errors = options[:retryable_errors] || RETRYABLE_ERRORS
  CAL_HTTP_RETRY_COUNT.times do |count|
    begin
      if not @http
        @http = init_request(options)
      end
      if options[:method] == :post
        body = @http.post(options[:uri], options[:body]).body
      else
        body = @http.get(options[:uri], options[:body]).body
      end
      break
    rescue Exception => e

      if retryable_errors.include?(e) || retryable_errors.any?{|c| e.is_a?(c)}

        if count < CAL_HTTP_RETRY_COUNT-1
          if e.is_a?(HTTPClient::TimeoutError)
            sleep(3)
          else
            sleep(0.5)
          end
          @http.reset_all
          @http=nil
          STDOUT.write "Retrying.. #{e.class}: (#{e})\n"
          STDOUT.flush
        else
          puts "Failing... #{e.class}"
          raise e
        end
      else
        raise e
      end
    end
  end

  body
end

#map(query, method_name, *method_args) ⇒ Object


506
507
508
509
510
511
512
513
514
515
516
517
518
519
# File 'lib/calabash-cucumber/core.rb', line 506

def map(query, method_name, *method_args)
  operation_map = {
      :method_name => method_name,
      :arguments => method_args
  }
  res = http({:method => :post, :path => 'map'},
             {:query => query, :operation => operation_map})
  res = JSON.parse(res)
  if res['outcome'] != 'SUCCESS'
    screenshot_and_raise "map #{query}, #{method_name} failed because: #{res['reason']}\n#{res['details']}"
  end

  res['results']
end

#move_wheel(opts = {}) ⇒ Object


285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/calabash-cucumber/core.rb', line 285

def move_wheel(opts={})
  q = opts[:query] || "pickerView"
  wheel = opts[:wheel] || 0
  dir = opts[:dir] || :down

  raise "Wheel index must be non negative" if wheel < 0
  raise "Only up and down supported :dir (#{dir})" unless [:up, :down].include?(dir)

  if ENV['OS'] == "ios4"
    playback "wheel_#{dir}", :query => "#{q} pickerTable index:#{wheel}"
  else
    playback "wheel_#{dir}", :query => "#{q} pickerTableView index:#{wheel}"
  end

end

#perform(*args) ⇒ Object


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/calabash-cucumber/core.rb', line 39

def perform(*args)
  if args.length == 1
    #simple selector
    hash = args.first
    q = hash[:on]
    hash = hash.dup
    hash.delete(:on)
    args = [hash]
  elsif args.length == 2
    q = args[1][:on]
    if args[0].is_a? Hash
      args = [args[0]]
    else
      args = args[0]
    end
  end
  map(q, :query, *args)
end

#picker(opts = {:query => "pickerView", :action => :texts}) ⇒ Object


301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/calabash-cucumber/core.rb', line 301

def picker(opts={:query => "pickerView", :action => :texts})
  raise "Not implemented" unless opts[:action] == :texts

  q = opts[:query]

  check_element_exists(q)

  comps = query(q, :numberOfComponents).first
  row_counts = []
  texts = []
  comps.times do |i|
    row_counts[i] = query(q, :numberOfRowsInComponent => i).first
    texts[i] = []
  end

  row_counts.each_with_index do |row_count, comp|
    row_count.times do |i|
      #view = query(q,[{:viewForRow => 0}, {:forComponent => 0}],:accessibilityLabel).first
      spec = [{:viewForRow => i}, {:forComponent => comp}]
      view = query(q, spec).first
      if view
        txt = query(q, spec, :accessibilityLabel).first
      else
        txt = query(q, :delegate, [{:pickerView => :view},
                                   {:titleForRow => i},
                                   {:forComponent => comp}]).first
      end
      texts[comp] << txt
    end
  end
  texts
end

#pinch(in_out, options = {}) ⇒ Object


218
219
220
221
222
223
224
# File 'lib/calabash-cucumber/core.rb', line 218

def pinch(in_out, options={})
  file = "pinch_in"
  if in_out.to_sym==:out
    file = "pinch_out"
  end
  playback(file, options)
end

#playback(recording, options = {}) ⇒ Object


408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/calabash-cucumber/core.rb', line 408

def playback(recording, options={})
  data = load_playback_data(recording)

  post_data = %Q|{"events":"#{data}"|
  post_data<< %Q|,"query":"#{escape_quotes(options[:query])}"| if options[:query]
  post_data<< %Q|,"offset":#{options[:offset].to_json}| if options[:offset]
  post_data<< %Q|,"reverse":#{options[:reverse]}| if options[:reverse]
  post_data<< %Q|,"prototype":"#{options[:prototype]}"| if options[:prototype]
  post_data << "}"

  res = http({:method => :post, :raw => true, :path => 'play'}, post_data)

  res = JSON.parse(res)
  if res['outcome'] != 'SUCCESS'
    screenshot_and_raise "playback failed because: #{res['reason']}\n#{res['details']}"
  end
  res['results']
end

#prepare_dialog_action(opts = {:dialog => nil, :answer => "Ok"}) ⇒ Object


275
276
277
278
279
280
281
282
283
# File 'lib/calabash-cucumber/core.rb', line 275

def prepare_dialog_action(opts={:dialog => nil, :answer => "Ok"})
  if opts[:dialog].nil? || opts[:dialog].length < 1
    raise ":dialog must be specified as a non-empty string (used as regexp to match dialog text)"
  end
  txt = opts[:answer] || 'Ok'
  set_user_pref("__calabash_action", {:action => :dialog,
                                      :text => opts[:dialog],
                                      :answer => txt})
end

#query(uiquery, *args) ⇒ Object


23
24
25
# File 'lib/calabash-cucumber/core.rb', line 23

def query(uiquery, *args)
  map(uiquery, :query, *args)
end

#query_all(uiquery, *args) ⇒ Object


58
59
60
61
62
63
64
# File 'lib/calabash-cucumber/core.rb', line 58

def query_all(uiquery, *args)
  unless ENV['CALABASH_NO_DEPRECATION'] == '1'
    puts "query_all is deprecated. Use the new all/visible feature."
    puts "see: https://github.com/calabash/calabash-ios/wiki/05-Query-syntax"
  end
  map("all #{uiquery}", :query, *args)
end

#record_beginObject


446
447
448
# File 'lib/calabash-cucumber/core.rb', line 446

def record_begin
  http({:method => :post, :path => 'record'}, {:action => :start})
end

#record_end(file_name) ⇒ Object


450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
# File 'lib/calabash-cucumber/core.rb', line 450

def record_end(file_name)
  res = http({:method => :post, :path => 'record'}, {:action => :stop})
  File.open("_recording.plist", 'wb') do |f|
    f.write res
  end

  device = ENV['DEVICE'] || 'iphone'
  os = ENV['OS']

  unless os
    major = Calabash::Cucumber::SimulatorHelper.ios_major_version
    unless major
      raise <<EOF
    Unable to determine iOS major version
    Most likely you have updated your calabash-cucumber client
    but not your server. Please follow closely:

https://github.com/calabash/calabash-ios/wiki/B1-Updating-your-Calabash-iOS-version

    If you are running version 0.9.120+ then please report this message as a bug.
EOF
    end
    os = "ios#{major}"
  end

  file_name = "#{file_name}_#{os}_#{device}.base64"
  system("/usr/bin/plutil -convert binary1 -o _recording_binary.plist _recording.plist")
  system("openssl base64 -in _recording_binary.plist -out #{file_name}")
  system("rm _recording.plist _recording_binary.plist")
  file_name
end

#recording_name_for(recording_name, os, device) ⇒ Object


334
335
336
337
338
339
340
# File 'lib/calabash-cucumber/core.rb', line 334

def recording_name_for(recording_name, os, device)
  if !recording_name.end_with? ".base64"
    "#{recording_name}_#{os}_#{device}.base64"
  else
    recording_name
  end
end

#rotate(dir) ⇒ Object


231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/calabash-cucumber/core.rb', line 231

def rotate(dir)
  @current_rotation = @current_rotation || :down
  rotate_cmd = nil
  case dir
    when :left then
      if @current_rotation == :down
        rotate_cmd = "left_home_down"
        @current_rotation = :right
      elsif @current_rotation == :right
        rotate_cmd = "left_home_right"
        @current_rotation = :up
      elsif @current_rotation == :left
        rotate_cmd = "left_home_left"
        @current_rotation = :down
      elsif @current_rotation == :up
        rotate_cmd = "left_home_up"
        @current_rotation = :left
      end
    when :right then
      if @current_rotation == :down
        rotate_cmd = "right_home_down"
        @current_rotation = :left
      elsif @current_rotation == :left
        rotate_cmd = "right_home_left"
        @current_rotation = :up
      elsif @current_rotation == :right
        rotate_cmd = "right_home_right"
        @current_rotation = :down
      elsif @current_rotation == :up
        rotate_cmd = "right_home_up"
        @current_rotation = :right
      end
  end

  if rotate_cmd.nil?
    screenshot_and_raise "Does not support rotating #{dir} when home button is pointing #{@current_rotation}"
  end
  playback("rotate_#{rotate_cmd}")
end

#scroll(uiquery, direction) ⇒ Object


150
151
152
153
154
# File 'lib/calabash-cucumber/core.rb', line 150

def scroll(uiquery, direction)
  views_touched=map(uiquery, :scroll, direction)
  screenshot_and_raise "could not find view to scroll: '#{uiquery}', args: #{direction}" if views_touched.empty?
  views_touched
end

#scroll_to_cell(options = {:query => "tableView", :row => 0, :section => 0, :scroll_position => :top, :animate => true}) ⇒ Object


164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/calabash-cucumber/core.rb', line 164

def scroll_to_cell(options={:query => "tableView",
                            :row => 0,
                            :section => 0,
                            :scroll_position => :top,
                            :animate => true})
  uiquery = options[:query] || "tableView"
  row = options[:row]
  sec = options[:section]
  if row.nil? or sec.nil?
    raise "You must supply both :row and :section keys to scroll_to_cell"
  end

  args = []
  if options.has_key?(:scroll_position)
    args << options[:scroll_position]
  else
    args << "top"
  end
  if options.has_key?(:animate)
    args << options[:animate]
  end
  views_touched=map(uiquery, :scrollToRow, row.to_i, sec.to_i, *args)

  if views_touched.empty? or views_touched.member? "<VOID>"
    screenshot_and_raise "Unable to scroll: '#{uiquery}' to: #{options}"
  end
  views_touched
end

#scroll_to_row(uiquery, number) ⇒ Object


156
157
158
159
160
161
162
# File 'lib/calabash-cucumber/core.rb', line 156

def scroll_to_row(uiquery, number)
  views_touched=map(uiquery, :scrollToRow, number)
  if views_touched.empty? or views_touched.member? "<VOID>"
    screenshot_and_raise "Unable to scroll: '#{uiquery}' to: #{number}"
  end
  views_touched
end

#scroll_to_row_with_mark(row_id, options = {:query => 'tableView', :scroll_position => :middle, :animate => true}) ⇒ Object


194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/calabash-cucumber/core.rb', line 194

def scroll_to_row_with_mark(row_id, options={:query => 'tableView',
                                             :scroll_position => :middle,
                                             :animate => true})
  uiquery = options[:query] || 'tableView'

  args = []
  if options.has_key?(:scroll_position)
    args << options[:scroll_position]
  else
    args << 'middle'
  end
  if options.has_key?(:animate)
    args << options[:animate]
  end

  views_touched=map(uiquery, :scrollToRowWithMark, row_id, *args)

  if views_touched.empty? or views_touched.member? '<VOID>'
    msg = options[:failed_message] || "Unable to scroll: '#{uiquery}' to: #{options}"
    screenshot_and_raise msg
  end
  views_touched
end

#send_uia_command(opts = {}) ⇒ Object

Raises:

  • (ArgumentError)

542
543
544
545
546
547
548
# File 'lib/calabash-cucumber/core.rb', line 542

def send_uia_command(opts ={})
  run_loop = opts[:run_loop] || (@calabash_launcher && @calabash_launcher.active? && @calabash_launcher.run_loop)
  command = opts[:command]
  raise ArgumentError, 'please supply :run_loop or instance var @calabash_launcher' unless run_loop
  raise ArgumentError, 'please supply :command' unless command
  RunLoop.send_command(run_loop, opts[:command])
end

#server_versionObject


31
32
33
# File 'lib/calabash-cucumber/core.rb', line 31

def server_version
  JSON.parse(http(:path => 'version'))
end

#start_test_server_in_background(args = {}) ⇒ Object

args :app for device bundle id, for sim path to app


524
525
526
527
528
529
530
# File 'lib/calabash-cucumber/core.rb', line 524

def start_test_server_in_background(args={})
  target = args[:device_target] || :simulator
  stop_test_server
  @calabash_launcher = Calabash::Cucumber::Launcher.new(target)
  @calabash_launcher.relaunch(args)

end

#stop_test_serverObject


532
533
534
535
536
# File 'lib/calabash-cucumber/core.rb', line 532

def stop_test_server
  if @calabash_launcher
     @calabash_launcher.stop
  end
end

#swipe(dir, options = {}) ⇒ Object


101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/calabash-cucumber/core.rb', line 101

def swipe(dir, options={})
  dir = dir.to_sym
  @current_rotation = @current_rotation || :down
  if @current_rotation == :left
    case dir
      when :left then
        dir = :down
      when :right then
        dir = :up
      when :up then
        dir = :left
      when :down then
        dir = :right
      else
    end
  end
  if @current_rotation == :right
    case dir
      when :left then
        dir = :up
      when :right then
        dir = :down
      when :up then
        dir = :right
      when :down then
        dir = :left
      else
    end
  end
  if @current_rotation == :up
    case dir
      when :left then
        dir = :right
      when :right then
        dir = :left
      when :up then
        dir = :down
      when :down then
        dir = :up
      else
    end
  end
  playback("swipe_#{dir}", options)
end

#touch(uiquery, options = {}) ⇒ Object


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/calabash-cucumber/core.rb', line 66

def touch(uiquery, options={})
  if (uiquery.is_a?(Array))
    raise "No elements to touch in array" if uiquery.empty?
    uiquery = uiquery.first
  end
  if (uiquery.is_a?(Hash))
    offset_x = 0
    offset_y = 0
    if options[:offset]
      offset_x += options[:offset][:x] || 0
      offset_y += options[:offset][:y] || 0
    end
    x = offset_x
    y = offset_y
    rect = uiquery["rect"] || uiquery[:rect]
    if rect
      x += rect['center_x'] || rect[:center_x] || rect[:x] || 0
      y += rect['center_y'] || rect[:center_y] || rect[:y] || 0
    else
      x += uiquery['center_x'] || uiquery[:center_x] || uiquery[:x] || 0
      y += uiquery['center_y'] || uiquery[:center_y] || uiquery[:y] || 0
    end

    options[:offset] = {:x => x, :y => y}
    return touch(nil, options)
  end

  options[:query] = uiquery
  views_touched = playback("touch", options)
  unless uiquery.nil?
    screenshot_and_raise "could not find view to touch: '#{uiquery}', args: #{options}" if views_touched.empty?
  end
  views_touched
end

#url_for(verb) ⇒ Object


567
568
569
570
571
572
573
574
575
576
577
# File 'lib/calabash-cucumber/core.rb', line 567

def url_for(verb)
  url = URI.parse(ENV['DEVICE_ENDPOINT']|| "http://localhost:37265")
  path = url.path
  if path.end_with? "/"
    path = "#{path}#{verb}"
  else
    path = "#{path}/#{verb}"
  end
  url.path = path
  url
end