0

if i have following lines in my spec

  include Rack::Test::Methods

  let(:competition_date) { Date.today+10.days }

How can i print the value of competition_date symbol in rspec?

4

1 回答 1

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
于 2013-09-16T18:28:51.957 回答