diff options
author | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-08-29 16:07:19 +0300 |
---|---|---|
committer | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-09-07 13:10:49 +0300 |
commit | 2c8b830fdbf749e8bb7461d5c3ce4699b77ce3ca (patch) | |
tree | 10e0c44ca36349acf1378d3191267c9d1493b321 /spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | |
parent | bbba62fa51419b14be4f39873afdd45b5b248764 (diff) |
Code refactoring
Diffstat (limited to 'spec/lib/ci/gitlab_ci_yaml_processor_spec.rb')
-rw-r--r-- | spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index d3a37ba6eb5..21aca9ee39f 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -1252,20 +1252,33 @@ EOT end describe "#errors" do - describe "Error handling" do - it "returns an error if the YAML could not be parsed" do + context "when the YAML could not be parsed" do + it "returns an error about invalid configutaion" do content = YAML.dump("invalid: yaml: test") - expect(GitlabCiYamlProcessor.errors(content)).to eq "Invalid configuration format" + + expect(GitlabCiYamlProcessor.validation_message(content)).to eq "Invalid configuration format" end + end - it "returns an error if the tags parameter is invalid" do + context "when the tags parameter is invalid" do + it "returns an error about invalid tags" do content = YAML.dump({ rspec: { script: "test", tags: "mysql" } }) - expect(GitlabCiYamlProcessor.errors(content)).to eq "jobs:rspec tags should be an array of strings" + + expect(GitlabCiYamlProcessor.validation_message(content)).to eq "jobs:rspec tags should be an array of strings" + end + end + + context "when YMAL content is empty" do + it "returns an error about missing content" do + expect(GitlabCiYamlProcessor.validation_message('')).to eq "Please provide content of .gitlab-ci.yml" end + end - it "does not return any errors when the YAML is valid" do + context "when the YAML is valid" do + it "does not return any errors" do content = File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) - expect(GitlabCiYamlProcessor.errors(content)).to eq nil + + expect(GitlabCiYamlProcessor.validation_message(content)).to be_nil end end end |