Add specs

This commit is contained in:
Tomasz Maczukin 2016-08-29 14:10:14 +02:00
parent 77295de407
commit e2e8ec6074
No known key found for this signature in database
GPG Key ID: 7E9EB2E4B0F625CD
1 changed files with 51 additions and 0 deletions

View File

@ -19,4 +19,55 @@ describe Ci::Build, models: true do
expect(build.trace).to eq(test_trace)
end
end
describe '#has_trace_file?' do
context 'when there is no trace' do
it { expect(build.has_trace_file?).to be_falsey }
it { expect(build.trace).to be_nil }
end
context 'when there is a trace' do
context 'when trace is stored in file' do
before do
build.trace = test_trace
build.save
end
it { expect(build.has_trace_file?).to be_truthy }
it { expect(build.trace).to eq(test_trace) }
end
context 'when trace is stored in old file' do
before do
build.trace = test_trace
build.save
build.project.ci_id = 999
build.project.save
FileUtils.mkdir_p(build.old_dir_to_trace)
FileUtils.mv(build.path_to_trace, build.old_path_to_trace)
end
it { expect(build.has_trace_file?).to be_truthy }
it { expect(build.trace).to eq(test_trace) }
end
context 'when there is stored in DB' do
class Ci::Build
def write_db_trace=(trace)
write_attribute :trace, trace
end
end
before do
build.write_db_trace = test_trace
build.save
end
it { expect(build.has_trace_file?).to be_falsey }
it { expect(build.trace).to eq(test_trace) }
end
end
end
end