-1
如何在Rspec中使用vanilla assert
?在Rspec中使用「vanilla」斷言?
require 'rspec'
describe MyTest do
it 'tests that number 1 equals 1' do
assert 1 == 1
end
end
的錯誤,我得到:
undefined method `assert' for
#<RSpec::ExampleGroups::Metadata::LoadFile:0x00000002b232a0>
請注意,我不想用assert_equal
,eq
,should
或其他魔神。
爲什麼你需要這個?另外,我認爲'assert'來自['Unit tests'](http://ruby-doc.org/stdlib-2.0.0/libdoc/test/unit/rdoc/Test/Unit/Assertions.html),而不是'RSpec'。 – Wikiti
@Wikiti因爲'assert'感覺比其他東西更優雅IMO – Pithikos
爲什麼你不使用minitest呢,如果你不想要Rspec的功能? https://github.com/seattlerb/minitest#specs – sevenseacat