step "there is a fresh database with a user and supplier" do
    CouchPotato.couchrest_database.recreate!
    create_confirmed_supplier 'supplier@mozo.bar'
    create_user 'user@mozo.bar'
end

step "I click on translation :translation" do |translation_key|
  text = I18n.t(translation_key)
  click_on text
end

step "I click on selector :selector" do |selector|
  find(selector).click
end

step 'I visit :path' do |path|
  visit path
end

step "I wait :number second/seconds" do |number|
  sleep number.to_f
end

placeholder :number do
  # match /[-+]?\d+(\.\d+)?/ do |number_string|
  match /\d+\.?\d?/ do |number_string|
    number_string.to_f
  end
end

step "I open the debugger" do
  binding.pry
end

step 'I reload the page' do
  case Capybara.current_driver
  when :selenium then page.driver.browser.navigate.refresh()
  when :poltergeist
    visit page.current_url
    sleep 1
    #steps = 0
    #r = page.evaluate_script 'window.ember_ready'
    #while !r and steps < 20
      #sleep 0.1
      #r = page.evaluate_script 'window.ember_ready'
      #steps += 1
    #end
  else
    visit page.current_url
  end
end
