Tag: 黄瓜

为什么我的Cucumber测试在使用Selenium时失败了?

我正在测试一个带有Cucumber / Capybara组合的Rails 3应用程序。 我也试图使用Selenium来测试一些特定于JavaScript的场景,但遇到了我不明白的奇怪困难。 我在Cucumber / Capybara的经历非常低,我对Selenium的经验是零。 这是场景: Scenario: Browsing events Given many events exist And I am on the events page Then I should see a list of 15 events When I follow the first event Then I should be on the event page And I should see a google map And I […]

在RSpec中是否存在与Cucumber的“情景”相同或者我使用RSpec的错误方式?

我对Cucumber的情景的简洁性和实用性印象深刻,它们是测试不同情况的一种很好的方式。 例如黄瓜情景 Feature: Manage Users In order to manage user details As a security enthusiast I want to edit user profiles only when authorized Scenario Outline: Show or hide edit profile link Given the following user records | username | password | admin | | bob | secret | false | | admin | secret […]

Rails / Cucumber / Webrat:redirect_to,flash 无效

我是Cucumber的新手,并且一直在踩着Ryan Bates的转播。 http://railscasts.com/episodes/155-beginning-with-cucumber 不幸的是,我的场景在railscast通过的地方失败了。 具体来说,它是失败的步骤: Then I should see “New Article Created.” 我怀疑它可能与我们正在使用的gem的不同版本有关,目前我有最新版本。 它给我以下错误: *然后我应该看到“创建新文章”。 期望以下元素的内容包括“New Article Created。”: Title Content (Spec :: Expectations :: ExpectationNotMetError)./ feature /^(?:|I )should see “([^\”]*)”$/’ features/manage_articles.feature:18:in step_definitions /web_steps.rb:144:in /^(?:|I )should see “([^\”]*)”$/’ features/manage_articles.feature:18:in然后我应该看到“New Article Created。”’* 这是来源: manage_articles.feature Feature: Manage Articles Scenario: Create Valid Article Given I have no articles And […]

如何解决Capybara :: ElementNotFound错误

我遇到了以下问题,这是我第一次使用水豚,请你知道如何解决这个问题,谢谢 我使用rails 3.0.0和以下gem gem ‘rails’, ‘3.0.0’ gem ‘capybara’ gem ‘database_cleaner’ gem ‘cucumber-rails’ gem ‘cucumber’ gem ‘rspec-rails’ gem ‘spork’ gem ‘launchy’ 我在Senario中有以下内容 When I go to the new customer page And I fill in “Email” with “john@example.com” 在我的customer_steps.rb我有 When /^I fill in “([^”]*)” with “([^”]*)”$/ do |arg1, arg2| fill_in arg1, :with => arg2 end 在我看来 – […]

除了在Rails测试中使用Capybara和RSpec之外,Steak还能添加什么?

我正在努力了解牛排的必要性。 我得到它像Cucumber,除了你可以使用纯ruby而不是像Cucumber一样将你的英语语言规范映射到ruby,但是它说它主要是在RSpec DSL周围增加一个包装,并让你使用它 取自: http : //jeffkreeftmeijer.com/2010/steak-because-cucumber-is-for-vegetarians/ module Spec::Example::ExampleGroupMethods alias scenario example alias background before end module Spec::DSL::Main alias feature describe end 这就是全部? 我从例子中可以看出,你仍然在使用Capybara和RSpec匹配器进行繁重的工作。那么为什么不直接使用Capybara和RSpec而不是在它上面添加像Steak这样的复杂function呢? 英语语言接受规范描述是唯一的价值主张,还是我错过了其他什么? 谢谢

如何在Rails / Capybara / Cucumber或Rspec中测试post

我正在使用rspec,黄瓜和水豚,我正在寻找一种方法来测试恶意用户无法破解表单然后发布到他/她没有权限的url。 我已经在cancan中设置了我的权限,这样“应该”可以工作,但是,我可以测试它的唯一方法是自己黑客攻击表单。 如何自动进行此类测试? 有了webrat,我可以用rspec进行unit testing put :update, :user_id => @user.id, :id => @user_achievement.id response.should contain(“Error, you don’t have permission to access that!”) 然而,在水豚中,访问只是看起来似乎。 我找不到办法做到这一点,我已经google了无处不在。 任何帮助将不胜感激,谢谢

使用capybara / rails运行selenium时,如何配置服务器?

通常我在端口3000使用rails dev服务器。 Capybara / Cucumber使用Capybara.server_port = 31337 。 如果我从默认驱动程序切换到selenium,它看起来像是尝试在端口80上连接。 我想了解: 使用selenium时,是否需要在测试环境中单独实例化测试服务器。 如果上述问题的答案是肯定的,我怎样才能做到这一点,这样我就可以在网络驱动程序之间无缝切换,而无需不断更改内容? 如果有人有一个env.rb配置的例子,请帮助我告诉我! 谢谢! 克里斯。

黄瓜故事的会话变量

我正在为一个“注册”应用程序编写一些Cucumber故事,该应用程序有许多步骤。 而不是写一个Huuuuuuuge故事来同时覆盖所有步骤,这将是不好的 ,我宁愿像普通用户一样在控制器中完成每个动作。 我的问题在于我将在第一步中创建的帐户ID存储为会话变量,因此当访问步骤2,步骤3等时,将加载现有的注册数据。 我知道能够在RSpec规范中访问controller.session[..]但是当我尝试在Cucumber故事中执行此操作时,它失败并出现以下错误(并且,我也读过某个地方这是一个反模式等等…): 使用controller.session [:whatever]或session [:whatever] You have a nil object when you didn’t expect it! The error occurred while evaluating nil.session (NoMethodError) 使用会话(:无论如何) wrong number of arguments (1 for 0) (ArgumentError) 因此,似乎加入会话存储是不可能的。 我想知道的是,是否有可能(我猜哪个会是最好的……): 模拟会话商店等 在控制器和存根中有一个方法(例如, get_registration ,它分配一个实例变量……) 我查看了RSpec书(好吧,浏览过)并浏览了WebRat等,但我还没有真正找到问题的答案…… 为了进一步澄清,注册过程更像是一个状态机 – 例如用户在注册完成之前通过四个步骤前进 – 因此“登录”实际上不是一个选项(它打破了网站工作原理的模型) )… 在我对控制器的规范中,我能够根据会话var加载对方法的调用 – 但是我不确定’antipattern’行是否也适用于存根和模拟? 谢谢!

如何在Rails 3中使用Cucumber / Capybara在页面上找到图像

我正在使用Cucumber / Capybara和Rails 3,我试图在上传后validation图像的存在。 我不知道如何检查图像的url来validation它。 我有以下情况: Scenario: Create new listing Given I am on the new listing page When I fill in “listing_name” with “Amy Johnson Photography” And I attach the file “features/support/test_image.jpg” to “listing_images_attributes_0_photo” And I press “Create” Then I should see “Amy Johnson Photography” And I should see the image “test_image.jpg” 除了最后一步,一切都过去了。 我已经尝试过这个用于我的步骤定义,如果它是页面上的文本,则效果很好,但不适用于图像url: […]

如何找到未使用的黄瓜步骤

我和Cucumber一起工作了大约一年,并且一直在不断重构function和步骤定义。 我在许多文件中定义了大量的步骤,我不禁觉得不再需要其中许多文件。 有没有办法找到哪些黄瓜步骤定义不再使用?