- 浏览: 111736 次
- 性别:
- 来自: 南京
文章分类
- 全部博客 (117)
- ForTran读书笔记 (2)
- C++读书笔记 (5)
- 生活 ~=电影 (12)
- English Polish (3)
- Design Pattern (1)
- Ruby Hacking Guide (9)
- BDD (7)
- Algorithm (0)
- ruby in rails (9)
- jQuery (4)
- 工具 (6)
- 汇编笔记 (1)
- python (1)
- ubunbu (6)
- git (2)
- db (4)
- cache (1)
- scala (1)
- vim (3)
- linux (3)
- sinatra (7)
- couch db (2)
- error (1)
- rack (1)
- gems (4)
- ruby (3)
最新评论
require 'minitest/spec'
MiniTest::Unit.autorun
describe MiniTest::Spec do
before do
@assertion_count = 4
end
after do
self._assertions.must_equal @assertion_count
end
it "needs to have all methods named well" do
@assertion_count = 2
methods = Object.public_instance_methods.find_all { |n| n =~ /^must|^wont/ }
methods.map! { |m| m.to_s } if Symbol === methods.first
musts, wonts = methods.sort.partition { |m| m =~ /^must/ }
expected_musts = %w(must_be
must_be_close_to
must_be_empty
must_be_instance_of
must_be_kind_of
must_be_nil
must_be_same_as
must_be_within_delta
must_be_within_epsilon
must_equal
must_include
must_match
must_raise
must_respond_to
must_send
must_throw)
expected_wonts = expected_musts.map { |m| m.sub(/^must/, 'wont') }
expected_wonts.reject! { |m| m =~ /wont_(not|raise|throw|send)/ }
musts.must_equal expected_musts
wonts.must_equal expected_wonts
end
it "needs to verify equality" do
(6 * 7).must_equal(42).must_equal true
proc { (6 * 9).must_equal(42) }.must_raise MiniTest::Assertion
end
it "needs to verify floats within a delta" do
(6.0 * 7).must_be_close_to(42.0).must_equal true
proc { 42.002.must_be_close_to 42.0 }.must_raise MiniTest::Assertion
end
it "needs to verify types of objects" do
(6 * 7).must_be_instance_of(Fixnum).must_equal true
proc { (6 * 7).must_be_instance_of String }.must_raise MiniTest::Assertion
end
it "needs to verify kinds of objects" do
@assertion_count = 6
(6 * 7).must_be_kind_of(Fixnum).must_equal true
(6 * 7).must_be_kind_of(Numeric).must_equal true
proc { (6 * 7).must_be_kind_of String }.must_raise MiniTest::Assertion
end
it "needs to verify regexp matches" do
@assertion_count = 6
"blah".must_match(/\w+/).must_equal true
proc { "blah".must_match(/\d+/) }.must_raise MiniTest::Assertion
end
it "needs to verify nil" do
nil.must_be_nil.must_equal true
proc { 42.must_be_nil }.must_raise MiniTest::Assertion
end
it "needs to verify using any operator" do
41.must_be(:<, 42).must_equal true
proc { 42.must_be(:<, 41) }.must_raise MiniTest::Assertion
end
it "needs to catch an expected exception" do
@assertion_count = 2
proc { raise "blah" }.must_raise RuntimeError
proc { raise MiniTest::Assertion }.must_raise MiniTest::Assertion
end
it "needs to catch an unexpected exception" do
@assertion_count = 2
proc {
proc { raise MiniTest::Assertion }.must_raise(RuntimeError)
}.must_raise MiniTest::Assertion
end
it "needs raise if an expected exception is not raised" do
@assertion_count = 2
proc { proc { 42 }.must_raise(RuntimeError) }.must_raise MiniTest::Assertion
end
it "needs to be able to catch a MiniTest::Assertion exception" do
@assertion_count = 2
proc { 1.wont_equal 1 }.must_raise MiniTest::Assertion
end
it "needs to verify using respond_to" do
42.must_respond_to(:+).must_equal true
proc { 42.must_respond_to(:clear) }.must_raise MiniTest::Assertion
end
it "needs to verify identity" do
1.must_be_same_as(1).must_equal true
proc { 1.must_be_same_as 2 }.must_raise MiniTest::Assertion
end
it "needs to verify throw" do
@assertion_count = 6
proc { throw :blah }.must_throw(:blah).must_equal true
proc { proc { }.must_throw(:blah) }.must_raise MiniTest::Assertion
proc { proc { throwxx }.must_throw(:blah) }.must_raise MiniTest::Assertion
end
it "needs to verify inequality" do
42.wont_equal(6 * 9).must_equal false
proc { 1.wont_equal 1 }.must_raise MiniTest::Assertion
end
it "needs to verify mismatch" do
@assertion_count = 6
"blah".wont_match(/\d+/).must_equal false
proc { "blah".wont_match(/\w+/) }.must_raise MiniTest::Assertion
end
it "needs to verify non-nil" do
42.wont_be_nil.must_equal false
proc { nil.wont_be_nil }.must_raise MiniTest::Assertion
end
it "needs to verify non-identity" do
1.wont_be_same_as(2).must_equal false
proc { 1.wont_be_same_as 1 }.must_raise MiniTest::Assertion
end
it "needs to be sensible about must_include order" do
@assertion_count = 6
[1, 2, 3].must_include(2).must_equal true
proc { [1, 2, 3].must_include 5 }.must_raise MiniTest::Assertion
end
it "needs to be sensible about wont_include order" do
@assertion_count = 6
[1, 2, 3].wont_include(5).must_equal false
proc { [1, 2, 3].wont_include 2 }.must_raise MiniTest::Assertion
end
end
MiniTest::Unit.autorun
describe MiniTest::Spec do
before do
@assertion_count = 4
end
after do
self._assertions.must_equal @assertion_count
end
it "needs to have all methods named well" do
@assertion_count = 2
methods = Object.public_instance_methods.find_all { |n| n =~ /^must|^wont/ }
methods.map! { |m| m.to_s } if Symbol === methods.first
musts, wonts = methods.sort.partition { |m| m =~ /^must/ }
expected_musts = %w(must_be
must_be_close_to
must_be_empty
must_be_instance_of
must_be_kind_of
must_be_nil
must_be_same_as
must_be_within_delta
must_be_within_epsilon
must_equal
must_include
must_match
must_raise
must_respond_to
must_send
must_throw)
expected_wonts = expected_musts.map { |m| m.sub(/^must/, 'wont') }
expected_wonts.reject! { |m| m =~ /wont_(not|raise|throw|send)/ }
musts.must_equal expected_musts
wonts.must_equal expected_wonts
end
it "needs to verify equality" do
(6 * 7).must_equal(42).must_equal true
proc { (6 * 9).must_equal(42) }.must_raise MiniTest::Assertion
end
it "needs to verify floats within a delta" do
(6.0 * 7).must_be_close_to(42.0).must_equal true
proc { 42.002.must_be_close_to 42.0 }.must_raise MiniTest::Assertion
end
it "needs to verify types of objects" do
(6 * 7).must_be_instance_of(Fixnum).must_equal true
proc { (6 * 7).must_be_instance_of String }.must_raise MiniTest::Assertion
end
it "needs to verify kinds of objects" do
@assertion_count = 6
(6 * 7).must_be_kind_of(Fixnum).must_equal true
(6 * 7).must_be_kind_of(Numeric).must_equal true
proc { (6 * 7).must_be_kind_of String }.must_raise MiniTest::Assertion
end
it "needs to verify regexp matches" do
@assertion_count = 6
"blah".must_match(/\w+/).must_equal true
proc { "blah".must_match(/\d+/) }.must_raise MiniTest::Assertion
end
it "needs to verify nil" do
nil.must_be_nil.must_equal true
proc { 42.must_be_nil }.must_raise MiniTest::Assertion
end
it "needs to verify using any operator" do
41.must_be(:<, 42).must_equal true
proc { 42.must_be(:<, 41) }.must_raise MiniTest::Assertion
end
it "needs to catch an expected exception" do
@assertion_count = 2
proc { raise "blah" }.must_raise RuntimeError
proc { raise MiniTest::Assertion }.must_raise MiniTest::Assertion
end
it "needs to catch an unexpected exception" do
@assertion_count = 2
proc {
proc { raise MiniTest::Assertion }.must_raise(RuntimeError)
}.must_raise MiniTest::Assertion
end
it "needs raise if an expected exception is not raised" do
@assertion_count = 2
proc { proc { 42 }.must_raise(RuntimeError) }.must_raise MiniTest::Assertion
end
it "needs to be able to catch a MiniTest::Assertion exception" do
@assertion_count = 2
proc { 1.wont_equal 1 }.must_raise MiniTest::Assertion
end
it "needs to verify using respond_to" do
42.must_respond_to(:+).must_equal true
proc { 42.must_respond_to(:clear) }.must_raise MiniTest::Assertion
end
it "needs to verify identity" do
1.must_be_same_as(1).must_equal true
proc { 1.must_be_same_as 2 }.must_raise MiniTest::Assertion
end
it "needs to verify throw" do
@assertion_count = 6
proc { throw :blah }.must_throw(:blah).must_equal true
proc { proc { }.must_throw(:blah) }.must_raise MiniTest::Assertion
proc { proc { throwxx }.must_throw(:blah) }.must_raise MiniTest::Assertion
end
it "needs to verify inequality" do
42.wont_equal(6 * 9).must_equal false
proc { 1.wont_equal 1 }.must_raise MiniTest::Assertion
end
it "needs to verify mismatch" do
@assertion_count = 6
"blah".wont_match(/\d+/).must_equal false
proc { "blah".wont_match(/\w+/) }.must_raise MiniTest::Assertion
end
it "needs to verify non-nil" do
42.wont_be_nil.must_equal false
proc { nil.wont_be_nil }.must_raise MiniTest::Assertion
end
it "needs to verify non-identity" do
1.wont_be_same_as(2).must_equal false
proc { 1.wont_be_same_as 1 }.must_raise MiniTest::Assertion
end
it "needs to be sensible about must_include order" do
@assertion_count = 6
[1, 2, 3].must_include(2).must_equal true
proc { [1, 2, 3].must_include 5 }.must_raise MiniTest::Assertion
end
it "needs to be sensible about wont_include order" do
@assertion_count = 6
[1, 2, 3].wont_include(5).must_equal false
proc { [1, 2, 3].wont_include 2 }.must_raise MiniTest::Assertion
end
end
发表评论
-
nokogiri
2011-08-29 13:57 615227 class Builder 228 ... -
ostruct.rb caller
2011-01-04 15:57 745# # = ostruct.rb: OpenStruct im ... -
Log
2010-11-26 16:55 726class BasicLog # log-level ... -
Uploading multiple images with Rails and Paperclip
2010-04-23 17:03 1017http://infrastacks.com/?p=57 &l ... -
#error_messages_for(*params)
2010-04-07 11:54 1365# Returns a string with a < ... -
Rails url_for and params missery
2010-04-02 12:59 1152Assume you have a params array ... -
Base# filter_parameter_logging
2010-03-26 20:41 999# Replace sensitive parameter d ... -
HTML::Selector #select #match
2010-03-25 11:37 918match(element, first?) => ar ...
相关推荐
具体型号包括:MiniTest 600BF3、MiniTest 600BN2、MiniTest 600BFN2、MiniTest 600F3、MiniTest 600N2和MiniTest 600FN3。 **应用领域**: MiniTest 600系列广泛应用于防腐、电镀、化工、汽车、造船、航空和轻工等...
Python库minitest-0.2.2是一个针对Python编程语言的测试框架,它提供了一套简单易用的接口,帮助开发者编写和运行测试用例,确保代码的质量和稳定性。minitest的设计灵感来源于Ruby的minitest库,但在Python环境中...
minitest-reporters, 创建可以自定义的MiniTest输出格式 Minitest记者- 创建可以自定义的Minitest输出格式 随意的猴子修补通过简单的钩子扩展 Minitest 。安装gem install minitest-reporters用法在 tes
minitest-rails, Rails的Minitest集成 minitestRails 5的Minitest集成 安装gem install minitest-rails这将安装以下宝石:minitest配置创建一个新的Rail
Ruby提供了两种强大的测试工具,RSpec和Minitest,它们通过匹配器功能可以帮助我们预防这种问题的发生。 RSpec是Ruby中广泛使用的BDD(行为驱动开发)框架,它允许开发者以自然语言的方式编写测试。匹配器是RSpec的...
email-spec, 在使用ActionMailer或者Pony的ruby 应用中,收集 testing/minitest匹配器的集合和用于测试电子邮件的Cucumber 步骤 电子邮件规范用于 RSpec 。MiniTest 和 Cucumber 步骤的匹配器集合,使测试邮件顺利...
《MiniTest2 - 副本.rar》是一个包含小程序基础程序和数据绑定示例的压缩文件,这为我们提供了一个深入理解小程序开发和数据管理的窗口。在这个压缩包中,我们主要探讨以下几个关键知识点: 1. **小程序基础**:小...
**minitest:全面理解这个强大的Ruby测试框架** minitest是Ruby社区中广泛使用的测试框架,它为开发人员提供了丰富的测试工具,支持Test Driven Development (TDD)、Behavior Driven Development (BDD)、模拟...
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
迷你轨道与Rails 6.1的Minitest集成安装gem install minitest-rails 这将安装以下gem: minitest配置创建一个新的Rails应用程序: rails new MyApp 选择一个版本如果您正在运行Rails 6.x,请在Gemfile中指定相应的6....
MiniTest TextMate 包 这是一组片段。 MiniTest 包目前专注于规范片段,因为断言片段已经包含在默认的 Ruby 包中。 安装 您可以通过将其克隆到Application Support/Avian目录来在本地安装此包: mkdir -p ~/...
minitest-reporters-创建可定制的Minitest输出格式 死于乱七八糟的猴子! 通过简单的钩子扩展Minitest。 安装 gem install minitest-reporters 用法 在您的test_helper.rb文件中,添加以下行: require "minitest/...
Test::Unit 的 minitest 包装器 在 Ruby 1.9 和 2.1 之间,Ruby 为 minitest 提供了一个包装器,以提供与 Ruby 1.8 相同的 Test::Unit 接口。 Ruby 2.2 附带了 Test::Unit 的捆绑 gem,但这不是包装器。 对包装好的 ...
[root@Lrw888 local]# tree -L 2 minitest/ minitest/ ├── build.sh ├── include │ ├── hwclientcomm.h │ ├── hwclientplat.h │ └── pbasetype.h ├── lib │ ├── libclientcomm.a │ ...
rack-minitest = rack-test + Minitest 。 看看我在那里做了什么? 这个 gem 为rack-test和Minitest添加了一些方便的方法,我发现自己为我编写的每个应用程序一遍又一遍地重复。 它添加了一些处理 JSON 的方法到...
**minitest:Scala和Scala.js的轻量级测试框架** `minitest` 是一个针对Scala编程语言及其JavaScript后端Scala.js设计的轻量级测试库。这个库的主要目标是提供简洁、快速且易于理解的测试工具,使得开发者在编写...
N + 1控制RSpec和Minitest匹配器以防止N + 1查询问题。 为什么还有另一个断言来声明数据库查询呢? 与其他库(例如db-query-matchers,rspec-sqlimit等)不同,使用n_plus_one_cont N +1 Control RSpec和Minitest...
MiniTest 是新一代的 Ruby 测试框架,它已经成为 Ruby 1.9 的内置测试框架,据说它也将成为Rails 4的默认测试框架,可谓前途一片光明。 MiniTest 为什么成为最新 Ruby 和 Rails 的首选,它有哪些吸引人的东西呢? ...
minitest-rerun-options 输出命令行选项以重新运行失败的测试描述这个插件添加了一个报告器,为失败的测试输出命令行选项。 举个例子: $ ruby test/test_examples/test_with_failures.rbRun options: --seed 39171#...