spec/lib/build_spec.rb in evrone-ci-router-0.2.0.pre4 vs spec/lib/build_spec.rb in evrone-ci-router-0.2.0.pre5
- old
+ new
@@ -6,17 +6,17 @@
subject { build }
context "just created" do
its(:message) { should eq msg }
- its(:output) { should eq '' }
+ its(:output) { should be_an_instance_of(Evrone::CI::Common::OutputBuffer)}
its(:output_counter) { should eq 0 }
end
- context "create_build_log_message" do
+ context "publish_build_log_message" do
let(:data) { 'log' }
- subject { build.create_build_log_message data }
+ subject { build.publish_build_log_message data }
it { should be_an_instance_of(Evrone::CI::Message::BuildLog) }
its(:build_id) { should eq build.message.id }
its(:tm) { should eq 1 }
its(:log) { should eq data }
@@ -24,10 +24,17 @@
it "should increment counter" do
expect {
subject
}.to change(build, :output_counter).by(1)
end
+
+ it "should delivery message" do
+ expect {
+ subject
+ }.to change(Evrone::CI::Router::BuildLogsConsumer.messages, :count).by(1)
+ expect(last_build_log_message.log).to eq data
+ end
end
context "to_build_status_message" do
subject { build.to_build_status_message Evrone::CI::Router::Build::STARTED }
@@ -38,67 +45,57 @@
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(:jobs_count) { should eq 1 }
-
- context "when commit_info exists" do
- before do
- build.commit_info = OpenStruct.new(
- author: "author",
- email: "email",
- sha: 'sha',
- message: "message"
- )
- end
-
- its(:commit_author) { should eq 'author' }
- its(:commit_author_email) { should eq 'email' }
- its(:commit_sha) { should eq 'sha' }
- its(:commit_message) { should eq 'message' }
- end
end
context "add_to_output" do
let(:data) { 'data' }
let(:messages) { Evrone::CI::Router::BuildLogsConsumer.messages }
- subject { build.add_to_output(data) ; build }
+ subject do
+ build.add_to_output(data)
+ build.output.flush
+ build
+ end
- its(:output) { should eq data }
-
it "should delivery message" do
expect {
subject
}.to change(messages, :size).by(1)
+ expect(last_build_log_message.log).to eq data
end
it "should increment output_counter" do
expect {
subject
}.to change(build, :output_counter).by(1)
- expect(messages.first.tm).to eq 1
+ expect(last_build_log_message.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 }
+ subject do
+ build.add_command_to_output(data)
+ build.output.flush
+ build
+ end
- its(:output) { should eq "$ #{data}\n" }
-
it "should delivery message" do
expect {
subject
}.to change(messages, :size).by(1)
+ expect(last_build_log_message.log).to eq "$ #{data}\n"
end
it "should increment output_counter" do
expect {
subject
}.to change(build, :output_counter).by(1)
- expect(messages.first.tm).to eq 1
+ expect(last_build_log_message.tm).to eq 1
end
end
context ".to_perform_job_message" do
let(:travis) { create :travis }
@@ -106,27 +103,20 @@
subject { build.to_perform_job_message travis, job_id }
it { should be_an_instance_of Evrone::CI::Message::PerformJob }
context "created message" do
- its(:id) { should eq build.message.id }
- its(:name) { should eq build.message.name }
- its(:src) { should eq build.message.src }
- its(:sha) { should eq build.message.sha }
- its(:deploy_key) { should eq build.message.deploy_key }
-
- 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'] }
+ its(:id) { should eq build.message.id }
+ its(:name) { should eq build.message.name }
+ its(:job_id) { should eq job_id }
+ its(:before_script) { should be }
+ its(:script) { should be }
+ its(:after_script) { should be }
+ its(:matrix_keys) { should eq ['rvm:2.0.0'] }
end
+ 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
+ context "scm_class" do
+ subject { build.scm_class }
+ it { should eq ::Evrone::CI::SCM::Git }
end
end