spec/lib/build_spec.rb in evrone-ci-router-0.2.0.pre1 vs spec/lib/build_spec.rb in evrone-ci-router-0.2.0.pre3
- old
+ new
@@ -5,43 +5,43 @@
let(:build) { described_class.new msg }
subject { build }
context "just created" do
- its(:message) { should eq msg }
- its(:output) { should eq '' }
+ its(:message) { should eq msg }
+ its(:output) { should eq '' }
+ its(:output_counter) { should eq 0 }
end
context "create_build_log_message" do
- let(:tm) { Time.new(2012, 12, 10, 15, 45) }
let(:data) { 'log' }
subject { build.create_build_log_message data }
- before do
- mock(Time).now { tm }
- end
-
it { should be_an_instance_of(Evrone::CI::Message::BuildLog) }
its(:build_id) { should eq build.message.id }
- its(:tm) { should eq tm.to_i }
+ its(:tm) { should eq 1 }
its(:log) { should eq data }
+
+ it "should increment counter" do
+ expect {
+ subject
+ }.to change(build, :output_counter).by(1)
+ end
end
context "to_build_status_message" do
subject { build.to_build_status_message Evrone::CI::Router::Build::STARTED }
before do
- build.matrix = ["rvm"]
build.jobs_count = 1
end
it { should be_an_instance_of(Evrone::CI::Message::BuildStatus) }
its(:build_id) { should eq build.message.id }
its(:status) { should eq 2 }
its(:tm) { should be }
its(:tm_usec) { should be }
- its(:matrix) { should eq %w{ rvm } }
its(:jobs_count) { should eq 1 }
context "when commit_info exists" do
before do
build.commit_info = OpenStruct.new(
@@ -63,28 +63,44 @@
let(:data) { 'data' }
let(:messages) { Evrone::CI::Router::BuildLogsConsumer.messages }
subject { build.add_to_output(data) ; build }
its(:output) { should eq data }
+
it "should delivery message" do
expect {
subject
}.to change(messages, :size).by(1)
end
+
+ it "should increment output_counter" do
+ expect {
+ subject
+ }.to change(build, :output_counter).by(1)
+ expect(messages.first.tm).to eq 1
+ end
end
context "add_command_to_output" do
let(:data) { 'data' }
let(:messages) { Evrone::CI::Router::BuildLogsConsumer.messages }
subject { build.add_command_to_output(data) ; build }
its(:output) { should eq "$ #{data}\n" }
+
it "should delivery message" do
expect {
subject
}.to change(messages, :size).by(1)
end
+
+ it "should increment output_counter" do
+ expect {
+ subject
+ }.to change(build, :output_counter).by(1)
+ expect(messages.first.tm).to eq 1
+ end
end
context ".to_perform_job_message" do
let(:travis) { create :travis }
let(:job_id) { 2 }
@@ -101,8 +117,17 @@
its(:job_id) { should eq job_id }
its(:before_script) { should be }
its(:script) { should be }
its(:matrix_keys) { should eq ['rvm:2.0.0'] }
+ end
+
+ context "when commit_info.sha exists" do
+ before do
+ build.commit_info = OpenStruct.new sha: "commit info sha"
+ end
+
+ its(:sha) { should eq 'commit info sha' }
+
end
end
end