jjzjj

cucumber

全部标签

ruby - cucumber 的路由问题

我正在使用rails3和cucumber,除了这个小问题,一切都很顺利GivenIamonthe"editautomobile"pageNoroutematches{:controller=>"automobiles",:action=>"edit"}(ActionController::RoutingError)现在路径在paths.rb中设置为edit_automobile_path在routes.rb中我有汽车作为资源,我搭建了它所以请告诉我我遗漏了什么,清楚地定义了路线并且匹配,因为我运行了rake路线并看到了路线。请指出正确的方向 最佳答案

ruby - 如何使用 cucumber 在场景之间共享状态

我有一个功能“从外部网站导入文章”。在我的第一个场景中,我测试从外部网站导入链接列表。Feature:ImportingarticlesfromexternalwebsiteScenario:Searchingarticlesonexample.comandreturnthelinksGiventhereisanImporterAnditsURLis"http://example.com"Whenwesearchfor"demo"ThentheImportershouldreturn25linksAndoneofthelinksshouldbe"http://example.com/d

ruby - capybara 无法通过 id 找到元素

capybara找不到在我的cucumber测试中用它的id标记。当我save_and_open_page时,我能够看到该元素.但我无法通过has_css?找到它或find:pry(#)>page.html.scan(/notice_sent/).count=>1pry(#)>page.html.scan(/id=\"notice_sent\"/).count=>1pry(#)>page.find('#notice_sent')Capybara::ElementNotFound:Unabletofindcss"#notice_sent"from/Users/me/.gem/ruby/2

ruby - 如何预期失败的步骤并传递 cucumber 中的失败?

我们想测试cucumber的步骤定义。我们希望能够检查的一件事是我们期望失败的测试实际上失败了。为此,我们想编写我们知道会失败的场景并将它们添加到我们的测试套件中,但标记或以其他方式表示它们以便当且仅当它们失败时它们“通过”。如何解决这个问题? 最佳答案 您应该测试负面状态。失败的步骤只是通过步骤的倒数。所以做这样的事情:Then/ishouldnotbetrue/dosome_value.should_notbe_trueend这就是我进行失败测试的方式。您还可以捕获异常等,并验证block是否确实抛出该异常lambdadosom

ruby - 如何在 Cucumber 的功能名称中使用空格

我正在使用Windows并尝试运行一个现有的功能包,该功能包最初是在MacOS上构建的,这允许他们通过使用带空格的"\"来解决问题。我正在使用Ruby2.2.3和Cucumber。功能名称包含空格,我无法更改它。我尝试使用""和''来绕过空白,但每次都有同样的问题。这是问题的一个例子。如果我运行:cucumberfeatures/'Namecontainingwhitespaces.feature'它工作正常。但是当我运行时:cucumber-pmy_profile和cucumber.yml包含:my_profile:features/'Namecontainingwhitespace

ruby - 使用 cucumber/aruba/timecop : How to inject the context 测试命令行应用程序

以下场景几乎概括了我的问题:Scenario:problemswithsubprocessesGiventhedateis01/01/201210:31WhenIrun`ruby-e"putsTime.now"`Thentheoutputshouldcontain"10:31"它归结为当我运行ruby​​-e"putsTime.now"时启动一个子进程,从而使我所有的Timecop.freezestub无效,因为他们只在主要过程中工作。我需要以某种方式将当前上下文“注入(inject)”到运行的命令中,但我似乎无法想出任何东西。我在这里尝试不可能的事情吗?步骤:require'time

ruby - 堆栈级别太深(SystemStackError)

我有Sinatra应用程序,需要测试我的应用程序。features/support/env.rb:require_relative"../../application"require"capybara"require"capybara/cucumber"require"rspec"WorlddoCapybara.app=ApplicationincludeCapybara::DSLincludeRSpec::Matchersendfeatures/one.feature:Feature:TesthomepageInordertomakesurepeoplecanopenmysiteIw

ruby - 如何在 Cucumber 表(多行参数)中使用正则表达式来区分表?

我正在使用场景表(multilinesteparguments)使用内置的.diff来使用cucumber检查来自屏幕的一些数据!CucumberAST表上的方法。我想检查内容是否与正则表达式匹配。Scenario:OneThenthetableappearsas:|One|Two|Three||/\d+/|/\d+/|/\d+/|实际的表格看起来像|One|Two|Three||123|456|789|这个场景翻译成“只要有几个数字,我不在乎”失败的示例步骤实现:Then/^thetableappearsas:$/do|expected_table|actual_table=[['O

ruby-on-rails - rails 上的 ruby 。 bundler 。 cucumber 。 rake 中止!命令失败,状态为 (1)

我在Rails3中使用Bundler和Cucumber时遇到问题。当我运行$rakecucumber时,我得到以下输出:bundleexec/usr/local/bin/ruby-I"/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-0.8.5/lib:lib""/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-0.8.5/bin/cucumber"--profiledefault(in/home//practice/rails/blog)Usingthedefaultprofile...UUUU1scen

ruby-on-rails - 如果没有可用标签,则运行标记规范或全部

我将guard与rspec和cucumber一起使用。要连续运行选定的规范,我只需使用focus标记来确定我要处理的内容。但问题是,如果没有带有该标签的规范,我想运行所有规范。我该怎么做?注意::我知道所有RSpec选项。因此,请仅在阅读问题后回复。 最佳答案 我通过以下配置实现了您描述的行为:#torunonlyspecificspecs,add:focustothespec#describe"foo",:focusdo#OR#it"shouldfoo",:focusdoconfig.treat_symbols_as_metada