Tag: 黄瓜

Capybara,在css元素中找到

我正在使用Ruby on Rails 3,Cucumber和Capybara 我已经搜索了相当长的一段时间,我无法弄清楚如何在css标签中找到特定的页面元素。 在我的例子中,我需要确保在表格中找到名称,而不是在“欢迎[名称]”中。 我试过类似的东西: within(‘table’) do page.body.index(“[Name]”) end 我有一个id=’table’ 。 但我想知道如何为任何css元素执行此操作,例如: within(‘h2’) do page.body.should have_content (‘stuff’) end 我认为我的问题与page.body有关,但我不确定如何将其包含在特定的css标签中。 提前致谢!

Rspec,Cucumber:最佳速度数据库清洁策略

我想提高测试的速度。 我应该使用use_transactional_fixtures还是使用database_cleaner gem? 哪种database_cleaner策略最好? 我注意到从迁移后:truncation到:transaction我的800多个例子运行速度快了4倍! 当我使用database_cleaner :transaction时,我应该关闭use_transactional_fixtures吗? Rack_test的最佳策略是:transaction吗? 在使用selenium或akephalos时,从:transaction到:truncation的最佳实践是什么? PS Mysql,Rails 3,Rspec2,Cucumber PPS我知道spork和parallel_test并使用它们。 但他们是偏离主义的。 例如,Spork在整个套件运行中节省大约15-20秒,但从:transaction更改为:truncation显着地将运行时间从3.5增加到13.5分钟(差异10分钟)。

Capybara webkit的数据库清理问题

我正在使用Cucumber编写我的集成测试和数据库清理程序以保持我的数据库清理。 一切都很完美,因为我的测试不需要Javascript。 我可以使用Capybara webkit让这些最后的测试通过,但是我的数据库根本没有被清除。 这是我的function/ support / env.rb文件: require ‘simplecov’ SimpleCov.start ‘rails’ require ‘cucumber/rails’ Capybara.default_selector = :css Capybara.javascript_driver = :webkit begin require ‘database_cleaner’ require ‘database_cleaner/cucumber’ DatabaseCleaner[:active_record].strategy = :transaction rescue NameError raise “You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it.” end Before do DatabaseCleaner.start end After […]

黄瓜+测试JS警报

我正在尝试使用Cucumber on Rails测试JS确认对话框。 我有一个window.onbeforeunload事件处理程序,如果你试图离开页面但我不知道如何测试它会提示你一个确认对话框,任何人都知道如何做到这一点?

黄瓜与RSpec

我想开始潜入BDD。 我之前从未使用过TDD,也不确定我是否应该从学习RSpec开始,然后跳到Cucumber或者直接使用Cucumber。 我一直在互联网上阅读这两本书,在我看来,黄瓜可能是RSpec的“替代品”。 我是对的还是应该用于某些事情而另一个用于其他事物?

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

黄瓜,rspec和rails 3引发错误选项: – profile

我第一次使用带有导轨3的黄瓜。 的Gemfile group :test do gem “rspec” gem “rspec-rails” gem “database_cleaner” gem “spork” gem “cucumber”, :git => “git://github.com/aslakhellesoy/cucumber.git” gem “cucumber-rails”, :git => “git://github.com/aslakhellesoy/cucumber-rails.git” gem “capybara” gem “capybara-envjs” gem “launchy” gem “ruby-debug” end 并用发电机安装黄瓜骨架 rails generate cucumber:install –rspec –capybara 这会生成一个cucumber.yml default: features wip: –tags @wip:3 –wip features rerun: –format rerun –out rerun.txt –strict –tags ~@wip 如果我运行它运行的最简单的function,但在测试后它会引发exception […]

无法批量分配受保护的属性

我的features文件看到了这个: Given there are the following users: | email | password | admin | | admin@ticketee.com | password | true | 并且我的user模型没有将admin属性声明为attr_accessible以防止批量分配。 因此,我已经对user_steps.rb文件进行了更改以解决此问题。 Given /^there are the following users:$/ do |table| table.hashes.each do |attributes| unconfirmed = attributes.delete(“unconfirmed”) == “true” @user = User.create!(attributes) @user.update_attribute(“admin”, attributes[“admin”] == “true”) @user.confirm! unless unconfirmed end end 现在这应该按照这本书 – Rails3的实际工作。 我也检查了他们在线仓库的代码。 […]

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

我在使用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 […]

黄瓜:未定义的步骤,尽管应该定义步骤

我创建了这个步骤: Given /^the feed “([^”]*)” has an item “([^”]*)” published at “([^”]*)”$/ do |feed_name, feed_item_title, published_at| feed = Feed.find_by_name(feed_name) FeedItem.make(:feed => feed, :title => feed_item_title, :published_at => published_at) end 我用以下方法进行黄瓜测试: Scenario: feed items should be sorted by date Given I am signed into an account called “GT” as a customer And there is a social […]