Tag: 黄瓜

使用Cucumber测试在rails3上进行uploadify

我想在rails 3上的ruby上进行黄瓜测试。我试图点击capybara的上传按钮,但因为它既不是按钮也不是链接。 此外,它隐藏了text_field,所以我不能写“当我填写”上传“with”text.txt“”。 如果有人解决了这个问题,请在此处提供帮助。

导轨:黄瓜不清洁DB

我在黄瓜和数据库事务方面遇到了一些问题 – 具体来说,当我运行测试套件时,之后不会清理数据库事务。 我正在使用spork,postgres运行rails 3.1。 最初feature / support / env.rb设置为使用database_cleaner,但在每次调用db时始终出现以下错误: 没有指定数据库。 缺少参数:数据库。 (ArgumentError)/Users/john/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/postgresql_adapter.rb:22:in postgresql_connection’ /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in new_connection’/Users/ postgresql_connection’ /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in .rvm/gems /ruby-1.9.2-p290/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_pool.rb:302:in checkout_new_connection’ /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_pool.rb:254:in在checkout checkout_new_connection’ /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_pool.rb:254:in块(2个级别)’ checkout_new_connection’ /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_pool.rb:254:in 1.9 .2-p290 / gems / activerecord-3.1.0.rc4 / lib / active_record / connection_adapters / abstract / connection_pool.rb:250:in loop’ /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_pool.rb:250:in /Users/john/.rvm/gems/ruby-1.9.2-p290/ loop’ /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_pool.rb:250:in in checkout’ loop’ /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_pool.rb:250:in p29 0 / lib […]

用设计和黄瓜测试登录

我正在尝试使用Cucumber测试登录function。 我的文件users_steps.rb包含 Given /^I am a user named “([^”]*)” with an email “([^”]*)” and password “([^”]*)”$/ do |name, email, password| u = User.new(:name => name, :email => email, :password => password, :password_confirmation => password) u.skip_confirmation! u.save! end When /^I sign in as “(.*)\/(.*)”$/ do |email, password| #Given %{I am not logged in} When %{I go […]

为什么我的黄瓜场景在步骤一起运行时失败,但在单独运行时通过?

当我整个运行我的黄瓜场景,或者使用命令:黄瓜时,我得到7个失败的步骤。 当我使用正在进行的工作标签单独运行它们时,它们会很好地通过。 我不认为这是一个数据库状态问题..我正在运行事务,我也尝试运行没有和清理数据库清理数据库….仍然没有帮助。 我试图运行调试器,但是当我运行命令黄瓜时它似乎不起作用。 它只适用于我使用正在进行的工作标记: cucumber -p wip 我认为可能是事情运行得太快而且水豚没有正确检查事情? 有任何想法吗?

如何找到Dragonfly with Cucumber / Capybara生成的图像?

在如何使用Cucumber / Capybara在页面上找到图像的解决方案的评论中,有人问: 我似乎无法想象如何使用Dragonfly生成的URL。 它们看起来像这样:/media/BAh_some_long_string_AwIw/12_11_52_810_5x5.jpg?s=7e360000,其中5×5.jpg是我的文件名。 我尝试过类似:// img [@src =“/ media / / #{image}?s = *”]但它不起作用。 有什么提示吗? – Ramon Tayag 2月25日凌晨 4点18分 我有一个类似的问题,只是更糟糕 – 在我的情况下,生成的图像路径甚至不包含(jpg | png | gif)文件名,它们只有这些非常长的ID: (使用蜻蜓和mongo / gridfs) 这些路径渲染得很好,但我无法弄清楚如何在Cucumber / Capybara步骤中找到它们:P 有任何想法吗? 我查看了Dragonfly的function ,但是他们只测试了图像本身的渲染,而没有检测到它在html页面中的存在。

保留黄瓜中的变量?

我想访问差异Given / Then / When子句中的变量。 如何保存变量以便它们可以在任何地方访问? Given(#something) do foo = 123 # I want to preserve foo end Then(#something) do # how to access foo at this point??? end

Rails 3.1.1和Cucumber – 错误

我有一个运行Cucumber的小问题。 使用黄瓜时,我得到以下结果: Yanniss-MacBook:rechnungen yannis$ cucumber Using the default profile… /Users/yannis/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_ MiniTest v1.6.0 is out of date. `gem install minitest` and add `gem ‘minitest’ to you test helper. (RuntimeError) /Users/yannis/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/turn-0.8.3/lib/turn/autorun/minitest.rb:14:in `’ /Users/yannis/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require’ /Users/yannis/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require’ /Users/yannis/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:225:in `load_dependency’ /Users/yannis/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require’ /Users/yannis/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/turn-0.8.3/lib/turn.rb:13:in `’ /Users/yannis/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require’ /Users/yannis/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require’ /Users/yannis/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:225:in `load_dependency’ […]

黄瓜和Rspec

任何人都可以建议我黄瓜和rspec教程(轨道3)的良好来源(简单的例子)??? 编辑: 其实我正在寻找免费的在线资源和良好的例子..

黄瓜:找到带有标签文字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选择器语法建议解决方案吗?

用于在子目录中运行单个黄瓜function的Guardfile?

我将我的function组织在子文件夹中,如下所示: app/ features/ users/ feature1.feature feature2.feature 但每次我保存一个function时,Guard都会运行我的所有function(不仅仅是编辑过的function)。 如何将其更改为仅运行已保存的? 这是我的Cucumber Guardfile: guard ‘cucumber’, :cli => “–drb –require features/support –require features/step_definitions” do watch(%r{features/.+\.feature}) watch(%r{features/support/.+}) { ‘features’ } watch(%r{features/step_definitions/(.+)_steps\.rb}) { |m| Dir[File.join(“**/#{m[1]}.feature”)][0] || ‘features’ } end