I am trying to verify if a text have been written to file (build.log) after executing a rake task which will throw an exception. Checkout both the code snippets below, the one with begin works whereas lambda throws a message saying it couldn't find the build.log file.
Using begin to test.(works)
begin
Rake::Task['git:checkout'].invoke //writes "destination already exists" to build.log
rescue
end
IO.read(@project_folder+@build_id+"/build.log").should match(/.*destination.*already.*exists.* /)
Trying to test the same using lambda. (Not works)
lambda {
Rake::Task['git:checkout'].invoke //writes "destination already exists" to build.log
}
IO.read(@project_folder+@build_id+"/build.log").should match(/.*destination.*already.*exists.* /)
What is the difference between these two?