Tag: webrat

黄瓜:找到带有标签文字X的输入?

在Cucumber中,我正在尝试创建这样的步骤: Then I should see “Example business name” in the “Business name” input 我希望将“商家名称”输入定义为“标签有文字的输入”商业名称。“ 这是我到目前为止所做的步骤: Then /^I should see “([^”]*)” in the “([^”]*)” input$/ do |content, labeltext| # Not sure what to put here end 在jQuery中,我会查找带有该文本的标签,查看其“for”属性,并找到带有该id的输入。 但到目前为止我在Cucumber中看到的唯一选择器是这些: within(“input:nth-child(#{pos.to_i}”) 和 page.should have_content(‘foo’) 任何人都可以使用Webrat / Capybara选择器语法建议解决方案吗?

没有黄瓜的Rspec集成测试?

有没有办法在不使用Cucumber的情况下使用Rspec进行集成测试? 我更喜欢使用普通的旧Webrat。 谢谢。

authlogic flash 没有显示在黄瓜webrat步骤中

我正在使用黄瓜运行BDD步骤来实现我的autlogic登录行为。 Scenario: log in Given a registered user: “test@test.com” with password: “p@ssword” exists And I am on the homepage When I follow “Log in” And I fill in “Username” with “test@test.com” And I fill in “Password” with “p@ssword” And I open the page And I press “Login” And I open the page Then I should […]

黄瓜:从表中选择一个元素进行删除或添加

我在使用ruby on rails开发的应用程序中有下表: 我想在黄瓜中创建一个测试,我从表中选择一个用户并将其删除或编辑。 我不知道这个步骤定义是什么。 我希望能够做到这样的事情: Feature: User Manegement In order to manage users As an admin I want to see a users list and change user properties Background: Given the following activated users exists | name | email | | Alice Hunter | alice.hunter@example.com | | Bob Hunter | bob.hunter@example.com | And the following […]

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 […]

黄瓜故事的会话变量

我正在为一个“注册”应用程序编写一些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’行是否也适用于存根和模拟? 谢谢!

Webrat和Rails:在click_button之后使用assert_contain给我“你被重定向”

我正在使用webrat为rails应用程序编写集成测试。 填写表单后,用户按下提交并创建一个帐户。 click_button “Submit” assert_contain “Your Account Has Been Created” 但是,测试失败: expected the following element’s content to include “Your Account Has Been Created”: You are being redirected. is not true. 通常要遵循重定向我会使用post_via_redirect,但仅仅看一下Webrat的例子,click_button后跟assert_contain应该有效 我刚刚开始使用Webrat,所以我错过了一些明显的东西吗? 为什么我坚持使用重定向响应? 谢谢! 德布

使用webrat对sinatra app进行验收测试失败

我正在尝试使用minitest和webrat测试ruby身份validation应用程序但是会出错。 visit ‘/’等测试失败,错误Status 200 expected but was 404. 包含fill_in :email, :with => “first@company.com”等代码的测试失败并显示错误Could not find field: :email 。 我读了几本sinatra,测试和webrat文档和论坛。 其中一些是旧的,并建议像Sinatra :: Default,但github.com/brynary/webrat/wiki/sinatra , 建立一个由Webrat测试和大师学习 驱动的Sinatra应用程序 :Sinatra内部是新的,但他们仍然失败。 基本上,我不喜欢rspec,黄瓜等句子般的语法,但确实想做行为驱动的开发。 我真的很喜欢最小的语法,包括测试和输出,这就是我为BDD选择webrat的原因。 如果我错过了期望webrat满足验收测试要求,请告诉我我应该使用这个框架或那个框架。 除此之外,主文件和测试文件的第一部分如下。 我希望有人可以解释我,我错过了什么? test_file里面 require “test/unit” require “minitest/autorun” require “rack/test” require ‘webrat’ require_relative “../lib/kimsin.rb” Webrat.configure do |config| config.mode = :rack end ENV[“RACK_ENV”] = “test” class KimsinTests “first@company.com” […]

使用Webrat进行测试时如何处理cookie?

我正在使用Webrat为基于Sinatra的应用程序编写Cucumber测试。 对于某些测试,我需要实现一个类似的场景 Given I am logged in as admin When I am visiting “/” Then I should see “Settings” 我定义了这样的步骤: Given /^I am logged in as “(.+)”$/ do |user| visit “/login” fill_in “login”, :with => user fill_in “password”, :with => “123456” click_button “Login” end When /^I am viewing “(.+)”$/ do |url| visit(url) end Then /^I […]

黄瓜+ Webrat + Selenium指南

我一直在使用Cucumber和Webrat。 我现在需要开始编写涉及AJAX交互的行为,所以我在考虑使用Selenium适配器进行Webrat。 有人能指出安装和配置selenium + webrat + cucumber的简单和更新的分步指南吗? 我希望能够将javascript场景与非JavaScript场景混合使用。