引用
runs each scenario in an isolated DB transaction.
Cucumber::Rails::World
Cucumber::Rails::World is the bridge between Cucumber and
Rails. It provides the Rails integration testing methods within
each scenario.
When Cucumber’s Rails support is loaded by requiring cucum-
ber/rails/world in features/support/env.rb, instances of Cucum-
ber::Rails::World are configured to be the World for each sce-
nario:
World do
Cucumber::Rails::World.new
end
inherits Rails’
Cucumber::Rails::World ActionCon-
troller::IntegrationTest, and makes surprisingly few modifications to
the superclass behaviour. Each scenario is run in a newly instan-
tiated Cucumber::Rails::World. This gives us access to all of the
functionality of Rails’ Integration tests and RSpec’s Rails-specific
matchers, including simulating requests to the application and
specifying behaviour with RSpec expectations.
In the default configuration, it runs each scenario in an isolated
DB transaction. You can disable this by removing the following
line from the features/support/env.rb generated by Cucumber:
Cucumber::Rails.use_transactional_fixtures
If you disable per-scenario transactions, you’ll have to worry
about records left over from one scenario affecting the results
of the next. This often leads to inadvertent and subtle order-
ing dependencies in your scenario build. For these reasons, we
strongly recommend using the transactional fixtures setting.∗
分享到:
相关推荐
在`support`目录下,开发者可以放置一些辅助文件,例如World类(用于扩展Cucumber的上下文)、Hooks(用于在测试前后的自定义操作)和环境配置。这些支持文件增强了Cucumber-Rails的灵活性和可定制性。 结合Rails ...
2. **Rails环境搭建**:学习如何安装Ruby、Rails以及相关的开发工具,如Git、SQLite、TextMate或Sublime Text等,创建第一个“Hello, World!”应用。 3. **Rails生成器**:Rails提供了许多命令行工具,如`rails ...
Once you’ve integrated those features into your coding practice, work with popular third-party testing tools such as RSpec, Jasmine, Cucumber, and factory_bot. Test the component parts of a Rails ...
电子邮件规格 RSpec , MiniTest和Cucumber步骤的匹配器集合... # Make sure this require is after you require cucumber/rails/world. require 'email_spec' # add this line if you use spork require 'email_spec/c
- **示例**: `puts "Hello, World!"` 是一个典型的Ruby示例,无需额外的结束符号。 - **优点**: 这样的语法设计使得代码更易于阅读和编写,有助于提高开发效率。 **2. 动态类型系统** - **特点**: Ruby是一种...