Ruby on rails 3 没有黄瓜的整合测试?

Ruby on rails 3 没有黄瓜的整合测试?,ruby-on-rails-3,cucumber,rspec2,Ruby On Rails 3,Cucumber,Rspec2,我正在用Rspec和Cucumber创建一个应用程序。我的应用程序使用了大量的Javascript和Ajax,它可以工作,但是。。。我在Cucumber和Javascript方面总是有很多问题。另外,它非常慢。对于每次发布,它都会启动firefox,对于每个场景,它都必须登录我的站点。我想我可以使用mock和rspec作为登录部分(???) 你认为使用黄瓜比RSpec/水豚肉(也许还有牛排)更好吗?忘记黄瓜更快吗?在我的公司,我们用Rspec+Capybara取代了Cucumber,我认为它更快

我正在用Rspec和Cucumber创建一个应用程序。我的应用程序使用了大量的Javascript和Ajax,它可以工作,但是。。。我在Cucumber和Javascript方面总是有很多问题。另外,它非常慢。对于每次发布,它都会启动firefox,对于每个场景,它都必须登录我的站点。我想我可以使用mock和rspec作为登录部分(???)


你认为使用黄瓜比RSpec/水豚肉(也许还有牛排)更好吗?忘记黄瓜更快吗?在我的公司,我们用Rspec+Capybara取代了Cucumber,我认为它更快、更简洁。大部分测试的所有代码都在一个地方,这也使得调试更容易。

在我的公司,我们用Rspec+Capybara代替Cucumber,我认为它更快、更简洁。大部分测试的所有代码都在一个地方,这也使得调试更容易。

我的公司也使用rspec/cucumber。如果硒的速度是一个瓶颈,你可以尝试以下方法

不确定它是否有用,但我们也使用了一个登录宏,它只在javascript请求期间点击登录页面

def login_user
  let(:current_user) { Factory.create(:user) }

  before(:each) do
    if example.options[:js]
      visit new_user_session_path
      fill_in 'Email', :with => current_user.email
      fill_in 'Password', :with => current_user.password
      click_button 'Sign In'
    else
      page.driver.post user_session_path, 'user[email]' => current_user.email, 'user[password]' => current_user.password
    end
  end
end

我的公司也使用rspec/黄瓜。如果硒的速度是一个瓶颈,你可以尝试以下方法

不确定它是否有用,但我们也使用了一个登录宏,它只在javascript请求期间点击登录页面

def login_user
  let(:current_user) { Factory.create(:user) }

  before(:each) do
    if example.options[:js]
      visit new_user_session_path
      fill_in 'Email', :with => current_user.email
      fill_in 'Password', :with => current_user.password
      click_button 'Sign In'
    else
      page.driver.post user_session_path, 'user[email]' => current_user.email, 'user[password]' => current_user.password
    end
  end
end

你说得对。我用rspec转换了所有的测试,速度更快。你说得对。我用rspec转换了所有的测试,速度更快。我喜欢这个想法。但是上面的代码放在哪里呢?另外,before(:each)做什么,代码如何知道“example”对象是什么?我是BDD的新手,所以我试着把我头脑中所有的活动部分整合起来。我喜欢这个想法。但是上面的代码放在哪里呢?另外,before(:each)做什么,代码如何知道“example”对象是什么?我是BDD的新手,所以我正在尝试将我头脑中所有活动的部分整合在一起。