Tag: 黄瓜

在Ruby On Rails上学习BDD的途径是什么?

我想在Ruby On Rails上启动BDD我应该学习什么? 我对BDD,RSpec或Cucumber一无所知。 什么是最好的学习方法? 教程? 包含“我应该测试什么样的行为?”之类的东西。 等等 谢谢!

轮询时如何修复黄瓜期望错误?

我有帮助sign_in用户。 我正在尝试使用新方法来确保用户使用轮询登录: def sign_in(user, password = ‘111111’) # … click_button ‘sign-in-btn’ eventually(5){ page.should have_content user.username.upcase } end 最后是: module AsyncSupport def eventually(timeout = 2) polling_interval = 0.1 time_limit = Time.now + timeout loop do begin yield rescue Exception => error end return if error.nil? raise error if Time.now >= time_limit sleep polling_interval end end end […]

Selenium找不到类型编号的字段

我在让Cucumber找到HTML5 type=”number”字段时遇到问题。 我不是他们在浏览器中看起来的忠实粉丝,但我有几个字段需要移动设备上的数字键盘,这似乎是获得它的最简单方法。 我正在使用SimpleForm来构建表单,当我设置:as => :text一切正常,但如果我设置:as => :number ,则字段不会被填写。 我没有得到任何错误,该领域只是没有得到填补。 具体来说,当我有这样一个步骤时: And I fill in “application_form_age” with “52” 然后这个标签将不会填写: ​ 但是这个有效: ​ 此外,它只发生在@javascript场景中。 在没有必要使用@javascript并且场景没有启动浏览器的情况下,这也可以正常工作。 事物的版本: capybara (2.2.1) cucumber (1.3.14) selenium-webdriver (2.41.0) simple_form (2.1.1) webrat (0.7.3) Firefox 29.0 我很难过。 我尝试了一堆我的应用程序JS和CSS,看看我正在做的事情是否打破它,但没有运气。 我只是通过强制那些字段在我的测试环境中没有HTML5类型号来修补它,但我不想那样生活。 还有其他人看到这个吗? 我无法找到任何引用它,这使它看起来像我正在做的事情。 但我无法弄明白。

黄瓜,水豚和selenium – 提交没有按钮的表格

我有一个使用Cucumber,capybara和selenium驱动器的测试。 此测试应该转到表单并提交。 正常的文字是 Scenario: Fill form Given I am on the Form page When I fill in “field1” with “value1” And I fill in “field2” with “value2” And I press “OK” Then I should see “Form submited” 问题是我没有表单中的OK按钮,我需要一种方法来执行“form.submit”,而不需要单击任何按钮或链接 – 就像在表单字段中按Enter时一样使用浏览器。 我不知道如何告诉capybara提交表格。 我该怎么做?

黄瓜没有在窗口中显示彩色输出

这可能是非常愚蠢的事情,但我无法解决这个问题。 我将我的黄瓜版本升级到v 0.10.0,现在测试版(在Win 7上运行)没有显示“漂亮”格式化程序的彩色输出。 运行测试时,它会输出以下错误: *** WARNING: You must use ANSICON 1.31 or higher (http://adoxa.110mb.com/ansicon) to get coloured output on Windows 我去过http://adoxa.110mb.com/ansicon,但对我来说,如何升级它并不明显。 有谁知道如何升级我的版本的anscion?

如何修复因编码错误而失败的Ruby脚本:US-ASCII上的“\ xD8”?

运行项目时出现以下错误: cucumber –format junit –guess –out ./ 这是错误: Checkout:workspace / /var/lib/hudson/jobs/PersOC-CucumberTests/workspace – hudson.remoting.LocalChannel@3b815cce Using strategy: Default Last Built Revision: Revision 3dc11ccba9c86308b422d6261ecde95d0a4ae999 (origin/master) Checkout:workspace / /var/lib/hudson/jobs/CucumberTests/workspace – hudson.remoting.LocalChannel@3b815cce Fetching changes from the remote Git repository Fetching upstream changes from /srv/git/cucumber.git Commencing build of Revision 14627f9a6682b82a9b4d64172278a646da358c24 (origin/master) Checking out Revision 14627f9a6682b82a9b4d64172278a646da358c24 (origin/master) [workspace] $ /bin/sh -xe /tmp/hudson6604637626131848657.sh […]

黄瓜:自动步骤文件创建?

当我运行黄瓜时,它会显示我应该定义的可能步骤,这是RSpec书中的一个例子: 1 scenario (1 undefined) 4 steps (4 undefined) 0m0.001s You can implement step definitions for undefined steps with these snippets: Given /^I am not yet playing$/ do pending end When /^I start a new game$/ do pending end Then /^the game should say “Welcome to CodeBreaker”$/ do pending end Then /^the game should say […]

kernel_require.rb:55:在`require’:无法加载此类文件错误

我目前正在使用Ruby版本1.9.3(尽管我在Ruby 2.0.0中遇到了同样的问题)。 在Windows 7 64位上。 我正在关注’The Cucumber Book’并且陷入第7.2章 – “删除重复变换”。 我的文件夹结构如下: \cash_withdrawal \cash_withdrawal\Gemfile \cash_withdrawal\Gemfile.lock \cash_withdrawal\features \cash_withdrawal\features\cash-withdrawal.feature \cash_withdrawal\features\step_definitions \cash_withdrawal\features\step_definitions\cash_withdrawal_steps.rb \cash_withdrawal\features\step_definitions\lib \cash_withdrawal\features\step_definitions\lib\nice_bank.rb \cash_withdrawal\features\support \cash_withdrawal\features\support\env.rb \cash_withdrawal\features\support\transforms.rb \cash_withdrawal\features\support\world_extensions.rb 在我的cash_withdrawal_steps.rb文件中,我有: require ‘CAPTURE_CASH_AMOUNT’ Given /^I have deposited (#{CAPTURE_CASH_AMOUNT}) in my Account$/ do |amount| my_account.deposit(amount) my_account.balance.should eq(amount), “Expected the balance to be #{amount} but it was #{my_account.balance}” end 当我运行cucumber我得到: C:\ Users \ […]

在Cucumber Around Hook中调用Block多次(Ruby)

我试图运行一个场景几(30)次,以获得一个很好的统计样本。 但是块只执行一次; 每个后续时间都会导致场景被调用而不执行(尽管它表示场景确实以大约5毫秒的时间成功完成)。 Around(‘@mass_benchmark’) do |scenario, block| $seconds_taken = “SECONDS TAKEN NOT SET” @time_array = [] 30.times do before_hook(scenario) block.call after_hook(scenario) @time_array << $seconds_taken end write_time_array_to_file(@time_array, scenario_name) end 标签@mass_benchmark执行此块,而不是〜@ mass_benchmark,它只是正常执行场景。 before_hook和after_hook方法复制Before(’〜@ mass_benchmark’)和After(’~mass_benchmark’)钩子(实际上只调用相同的方法)。 变量$ seconds_taken是围绕我正在计时的特定区域设置的。 我没有计时整个测试,只是它的一个关键部分; 测试的其余部分到达那一点,这不是定时部分的一部分,所以我不能只是将定时部分移到此外。 这个问题可能与我在这些方法中所做的事情有关,但据我所知,一切正常(如有良好的put语句所示)。 任何想法都表示赞赏!

将命令行上的变量传递给Cucumber测试

我试图保持黄瓜项目的用户名和密码不受版本控制。 有没有办法在命令行上手动传递变量,如用户名和密码到黄瓜脚本? 我的备份计划是将它们放在YML文件中并将该文件添加到gitignore,这样它们就不会置于版本控制之下。