Skip to main content

Posts

Featured

Rspec: let vs let!

Sự khác nhau giữa let vs let!  Let:  Let chỉ có giá trị trong từng block it Nếu trong 1 block mà gọi nhiều biến let thì nó sẽ khai báo 1 lần biến let ở lần gọi đầu tiên. Có thể xem nó là: lazy evaluation   Example : $count = 0 RSpec .describe "let" do let( :count ) { $count += 1 } it "memoizes the value" do expect(count).to eq( 1 ) expect(count).to eq( 1 ) end it "is not cached across examples" do expect(count).to eq( 2 ) end end   Note :                 Note that  let  is lazy-evaluated: it is not evaluated until the first time           the method it defines is invoked.    Let!: You can use  let!  to force the method's   invocation before each example.       Có thể được hiểu là let! khi được gọi thì nó sẽ gọi trong block before...

Latest Posts

Migration in rails

How to install and uninstall ActiveAdmin in rails

Learn Rails

Config database my sql

Gem neccessary the first in rails