草庐IT

describing

全部标签

ruby-on-rails - 在规范中使用 describe/it 优于 feature/scenario 的优势? (除了语法糖)

Ruby1.9.3、Rails3.1.10、RSpec2.13.0、Capybara2.2.1我正在为Rails3应用程序编写测试——一个供客户(和管理员)配置各种电话设置的GUI。我已经编写了6个左右的规范文件,之前还编写了很多其他文件(我将其用作模板)。以下是规范文件的快照。#spec/features/admin/administrators_spec.rbrequire'spec_helper'includeAdministratorHelperincludeHelpersfeature"ExerciseAdministratorspage"include_context"sh

ruby - 在包含被测模块时使用 described_class

我正在编写一些rspec来测试一些模块是否正确实现了它们的行为。模块看起来像这样:moduleUnder::Testdefsome_behaviourendend我不能在RSpec中这样做:describeUnder::Testdosubject{Class.new{includedescribed_class}.new}在调用#described_class时,它无法再解析,因为self是Class的实例,它没有#describe_class方法。所以我不得不重复一遍:subject{Class.new{includeUnder::Test}.new}或者在规范中以与我的客户使用它的