Tag: 黄瓜

何时在BDD循环中从黄瓜切换到rspec以进行登录过程

我还在尝试理解BDD循环中cucumber和rspec的组合。 我为一个非常简单的登录系统定义了以下场景: Feature: Log in In order to get access to the application As a user I want to log in Scenario: User logs in successfully Given I exist as a user When I go to the login page And I fill in “username” with “gabrielhilal” And I fill in “password” with “secret” And I […]

我如何在Capybara w / selenium中使用ruby-debug

我们让Capybara使用selenium驱动程序但是当我尝试在步骤中使用“调试器”时它不太有效。 例如,在调试控制台中输入’page’有效,但输入’page.body’挂起。 在尝试使用akephalos驱动程序的调试器时,我们也很奇怪。 使用akephalos我们无法输入调试提示…实际上我们可以,但是你必须多次按键才能在终端中随机显示一个字母。 做’Ctrl-C’让我们输入,但是我们得到了’DRb connection … something’之类的错误(抱歉再也没有确切的错误)。 我认为问题是像selenium和akephalos这样的驱动程序在同一个进程中运行测试和服务器,它会混淆ruby-debug。 我将尝试单独运行服务器(脚本/服务器测试)并使用Capybara.app_host =’http:// localhost:3000’来查看是否会产生影响。 我尝试使用akephalos,但由于它刚刚启动了另一个进程内服务器,所以无法实现。 是否有人使用与Capybara和selenium的ruby-debug? 这对其他人有用吗? 我错过了一些明显的东西吗

运行Cucumber测试时Rails应用程序的端口

有没有办法在测试中获得在黄瓜测试期间运行rails应用程序的端口? 我试过Capybara.server_port,但那是零。 谢谢。

在开发黄瓜测试时是否可以关闭ActionMailer电子邮件?

目前,我的本地开发环境设置为能够发送实际的电子邮件。 因此,正在进行交付,并且ActionMailer::Base.deliveries表中没有任何内容。 是否可以在黄瓜测试中禁用电子邮件发送? 如果是这样,这样做的语法是什么? 或者有更好的方法来测试发送的电子邮件吗? authentication_steps.rb: Then /^I should receive a confirmation email$/ do email = ActionMailer::Base.deliveries.last email.subject.should == “Welcome to our website!” end 应用程序/配置/ development.rb … # Don’t care if the mailer can’t send config.action_mailer.raise_delivery_errors = true config.action_mailer.perform_deliveries = true # Setup for local testing of emails using gmail test account config.action_mailer.delivery_method = :smtp […]

如何使用Cucumber-Capybara断言是否存在闪存变量?

我正在使用Cucumber和Capybara运行Rails 3.0.7项目,我有一个步骤定义,检查是否存在flash [:error]: Then /^I should be able to see the main page properly$/ do current_path.should == “/” flash[:error].should == nil end 当我进行黄瓜测试时,我收到错误 And I should be able to see the main page properly # features/step_definitions/user_auth_steps.rb:17 undefined method `flash’ for nil:NilClass (NoMethodError) ./features/step_definitions/user_auth_steps.rb:19:in `/^I should be able to see the main page properly$/’ features/user_auth.feature:10:in `And […]

如何使用Rails,Cucumber和Capybara测试Dropzone.js上传?

我有一个使用Cucumber和Capybara进行测试的Rails项目。 我有一个使用Dropzone.js的文件上传页面。 我的上传工作很有用,可以使用对话框或拖放。 测试是另一回事。 我的表格中有以下字段: 但是,在步骤定义中,我尝试了一些查找和附加文件数据的方法,但它们都不起作用。 我试过fill_in: fill_in “photo_image”, with: photo 我试过用css选择器找到: find(‘#photo_image’).set photo 我试过用xpath找到: find(:xpath, “//input[@id=’photo_image’]”).set photo 但他们都没有看到隐藏的领域。 Unable to find css “#photo_image” (Capybara::ElementNotFound) Unable to find xpath “//input[@id=’photo_image’]” (Capybara::ElementNotFound) Unable to find field “photo_image” (Capybara::ElementNotFound) 有没有可以使用Dropzone.js处理上传的测试方法还是没有希望?

无效选项: – autospec

/usr/local/bin/ruby -rrubygems -e “require ‘redgreen'” /usr/local/lib/ruby/gems/1.8/gems/rspec-1.3.0/bin/spec –autospec -O spec/spec.opts invalid option: –autospec Test::Unit automatic runner. Usage: -e [options] [– untouched arguments] which spec says “/usr/local/bin/spec” which autospec says “/usr/local/bin/autospec” /usr/local/bin/spec –help includes –autospec option in the list. 我在这里想念的是什么?

这个Cucumber错误消息是什么意思?

我运行cucumber features并得到: Using the default profile… can’t activate builder (~> 2.1.2, runtime) for [“activemodel-3.0.5”, “actionpack-3.0.5”, “railties-3.0.5”], already activated builder-3.0.0 for [“cucumber-0.10.2”] (Gem::LoadError) 这里有什么问题,我该如何解决? 谢谢。

运行function时不会自动加载黄瓜步骤

我最近在我的机器上更新了Cucumbergem(’cucumber’和’cucumber-rails’)并遇到了几个问题。 我目前正在争斗的是,Cucumber没有自动加载我的function的任何已定义步骤。 这导致我的命令行告诉我“我可以为我的function中使用的每个步骤实现这些片段的未定义步骤的步骤定义”。 我跑了: cucumber –verbose ……并且可以看到以下内容: 代码:* vendor / plugins / paperclip / cucumber / paperclip_steps.rb 但是,除非我指定要加载的文件,否则Cucumber不会加载任何步骤: cucumber -r features/step_definitions/web_steps.rb 我认为这可能只是我在我的应用程序结构中的“step_definitions”文件夹中创建的自定义步骤文件,但看起来标准的“web_steps”文件也没有被加载。 非常感谢任何遇到过这个问题的人或者知道为什么会这样。 谢谢。

阿鲁巴黄瓜试验(ruby1.9.2)

我刚刚安装了aruba gem,它是黄瓜的延伸。 它允许您测试命令行应用程序 – 比如Rails中的生成器(但是,正如文档所指出的,您可以将它用于任何cmd应用程序)。 我一直关注这篇关于使用它的关键实验室文章 ,但由于某种原因它没有超越第一步:第一步是绿色(创建应用程序),但是下一步尝试cd test_app并且可以’找到它并失败。 Given I run “rails new test_app” # features/step_definitions/aruba_steps.rb:95 And I cd to “test_app” # features/step_definitions/aruba_steps.rb:91 tmp/aruba/test_app is not a directory. (RuntimeError) ./features/step_definitions/aruba_steps.rb:92:in `/^I cd to “([^”]*)”$/’ features/generators.feature:9:in `And I cd to “test_app”‘ 看起来应用程序文件夹实际上并没有被创建,虽然查看基础目录我可以看到tmp / aruba / folding 是 。 在探索源头一段时间后,我无法想出任何原因。 有没有其他人有这个gem的经验,发现了同样的事情? 是否有任何不错的BDD替代方案来测试发电机或佣金任务等? 进一步回答Ryans: 一旦我将以下内容添加到features/support/env.rb (从base rails目录开始): Before […]