好久没写 rspec,回头一看:
http://rspec.info/documentation/3.1/rspec-core/
# in spec/calculator_spec.rb
RSpec.describe Calculator do
describe '#add' do
it 'returns the sum of its arguments' do
expect(Calculator.new.add(1, 2)).to eq(3)
end
end
end
原先用Calculator.new.add(1, 2).should == 3
多简洁,为什么改成了这种写法?还不如 Test::Unit 的方法assert_equal
呢。