0
  • 如何在黄瓜测试中使用 where 条件?
  • 我需要测试重置密码功能。

下面是我的代码

  Given /^I have successfully requested a password reset "(.*?)" and enter "(.*?)"$/ do |url, username|
    visit url
    fill_in "username", :with => username
    click_button "Request"
    @current_user = User.find_by_username!(username)
    click link("http://localhost:3000/edit/"#{@current_user.token}"/password")
  end

但我有一个错误

uninitialized constant User (NameError)

支持/env.rb

require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'rspec'

Capybara.register_driver :selenium do |app|
  Capybara::Selenium::Driver.new(app, :browser => :firefox)
end


Capybara.run_server = false
Capybara.default_driver = :selenium
Capybara.default_selector = :css

module Helpers
  def without_resynchronize
    page.driver.options[:resynchronize] = false
    yield
    page.driver.options[:resynchronize] = true
  end
end

World(Capybara::DSL, Helpers)
4

0 回答 0