2013-09-16 25 views

回答

2

在RSpec中,在let中定義的變量可在beforeit塊中訪問。全部必須包含在describe區塊內,但是,如:

describe "let variables" do 
    let(:competition_date) { Date.today+10.days } 
    it "should be accessible within it blocks" do 
    expect(competition_date).to be == Date.today+10.days 
    puts competition_date 
    end 
end