如果我的规格中有以下行
include Rack::Test::Methods
let(:competition_date) { Date.today+10.days }
如何在rspec中打印competition_date符号的值?
答案 0 :(得分:2)
在RSpec中,let
中定义的变量可在before
和it
块中访问。所有内容都必须包含在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