相关疑难解决方法(0)

在`expect`测试中,Rspec`eq`对`eql`

使用eqeql在rspec测试中有什么区别?是否有区别:

it "adds the correct information to entries" do
  # book = AddressBook.new # => Replaced by line 4
  book.add_entry('Ada Lovelace', '010.012.1815', 'augusta.king@lovelace.com')
  new_entry = book.entries[0]

  expect(new_entry.name).to eq('Ada Lovelace')
  expect(new_entry.phone_number).to eq('010.012.1815')
  expect(new_entry.email).to eq('augusta.king@lovelace.com')
end
Run Code Online (Sandbox Code Playgroud)

和:

it "adds the correct information to entries" do
  # book = AddressBook.new # => Replaced by line 4
  book.add_entry('Ada Lovelace', '010.012.1815', 'augusta.king@lovelace.com')
  new_entry = book.entries[0]

  expect(new_entry.name).to eql('Ada Lovelace')
  expect(new_entry.phone_number).to eql('010.012.1815')
  expect(new_entry.email).to eql('augusta.king@lovelace.com')
end
Run Code Online (Sandbox Code Playgroud)

ruby rspec

29
推荐指数
2
解决办法
1万
查看次数

标签 统计

rspec ×1

ruby ×1