ruby on rails - How can I add a variable to an "it" statement in an rspec? -
if have
let(:analysis_file_1) { "./spec/test_files/analysis1.json" } ... "should have message x"
i'd print out value of analysis_file_1 in "it" statement.
but doesn't work:
it "#{analysis_file_1} should have message x"
it errors out
in `block in <top (required)>': undefined local variable or method `analysis_file_1' #<class:0x007f865a219c00> (nameerror)
is there way use let defined variable in message?
you can define constant this:
analysis_file_1 = "./spec/test_files/analysis1.json" "#{analysis_file_1} should have message x"
or in case have multiple analysis files can put them in array:
["./spec/test_files/analysis1.json", "./spec/test_files/analysis2.json", "./spec/test_files/analysis3.json"].each |analysis_file| "#{analysis_file} should have message x" # spec here end end
Comments
Post a Comment