gocd 0.5 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +34 -1
- data/LICENSE.txt +201 -0
- data/README.md +71 -0
- data/Rakefile +7 -0
- data/gocd.gemspec +3 -0
- data/lib/gocd/agents/agent.rb +1 -1
- data/lib/gocd/agents/agents_repository.rb +1 -1
- data/lib/gocd/config/credentials.rb +2 -0
- data/lib/gocd/history/history_fetcher.rb +35 -0
- data/lib/gocd/pipeline_config/environment.rb +29 -0
- data/lib/gocd/pipeline_config/job.rb +21 -0
- data/lib/gocd/pipeline_config/pipeline.rb +30 -0
- data/lib/gocd/pipeline_config/pipeline_config.rb +72 -0
- data/lib/gocd/pipeline_config/pipeline_group.rb +20 -0
- data/lib/gocd/pipeline_config/repository/pipeline_config_repository.rb +11 -0
- data/lib/gocd/pipeline_config/stage.rb +26 -0
- data/lib/gocd/pipeline_config/template.rb +6 -0
- data/lib/gocd/{pipeline → pipeline_status}/pipeline.rb +0 -0
- data/lib/gocd/{pipeline → pipeline_status}/pipeline_repository.rb +0 -0
- data/lib/gocd/{pipeline → pipeline_status}/pipelines.rb +0 -0
- data/lib/gocd/version.rb +1 -1
- data/spec/gocd/agents/agent_spec.rb +98 -0
- data/spec/gocd/agents/agents_repository_spec.rb +79 -0
- data/spec/gocd/agents/agents_spec.rb +37 -0
- data/spec/gocd/config/credentials_spec.rb +9 -0
- data/spec/gocd/history/history_fetcher_spec.rb +54 -0
- data/spec/gocd/pipeline_config/environment_spec.rb +27 -0
- data/spec/gocd/pipeline_config/job_spec.rb +23 -0
- data/spec/gocd/pipeline_config/pipeline_group_spec.rb +50 -0
- data/spec/gocd/pipeline_config/pipeline_spec.rb +62 -0
- data/spec/gocd/pipeline_config/stage_spec.rb +32 -0
- data/spec/gocd/pipeline_config/template_spec.rb +32 -0
- data/spec/gocd/pipeline_status/pipeline_spec.rb +47 -0
- data/spec/gocd/pipeline_status/pipelines_repository_spec.rb +43 -0
- data/spec/gocd/pipeline_status/pipelines_spec.rb +80 -0
- data/spec/spec_helper.rb +103 -0
- metadata +91 -5
@@ -0,0 +1,27 @@
|
|
1
|
+
require './lib/gocd/pipeline_config/pipeline_group'
|
2
|
+
require 'active_support/core_ext/hash/conversions'
|
3
|
+
|
4
|
+
RSpec.describe GOCD::PIPELINE_CONFIG::Environment, 'Environment' do
|
5
|
+
xml_response = <<-PipelineGroup
|
6
|
+
<environment name="Env">
|
7
|
+
<agents>
|
8
|
+
<physical uuid="276cc6fa-e97f-914f9a1acaa4-45f6-b78d" />
|
9
|
+
<physical uuid="2828cc5c-7bad-2c99c81638b3-49b8-a83b" />
|
10
|
+
</agents>
|
11
|
+
<pipelines>
|
12
|
+
<pipeline name="Pipeline1" />
|
13
|
+
<pipeline name="Pipeline2" />
|
14
|
+
</pipelines>
|
15
|
+
</environment>
|
16
|
+
PipelineGroup
|
17
|
+
|
18
|
+
it 'should parse environment' do
|
19
|
+
response = Hash.from_xml(xml_response)
|
20
|
+
environment = GOCD::PIPELINE_CONFIG::Environment.new response['environment']
|
21
|
+
|
22
|
+
expect(environment.name).to eq 'Env'
|
23
|
+
expect(environment.pipeline_names.size).to eq 2
|
24
|
+
expect(environment.pipeline_names.first).to eq 'Pipeline1'
|
25
|
+
expect(environment.pipeline_names.last).to eq 'Pipeline2'
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require './lib/gocd/pipeline_config/pipeline_group'
|
2
|
+
require 'active_support/core_ext/hash/conversions'
|
3
|
+
|
4
|
+
RSpec.describe GOCD::PIPELINE_CONFIG::Job, 'Job' do
|
5
|
+
xml_response = <<-PipelineGroup
|
6
|
+
<job name="flavor1_spec" timeout="60">
|
7
|
+
<resources>
|
8
|
+
<resource>mac</resource>
|
9
|
+
<resource>spec</resource>
|
10
|
+
</resources>
|
11
|
+
</job>
|
12
|
+
PipelineGroup
|
13
|
+
|
14
|
+
it 'should parse job' do
|
15
|
+
response = Hash.from_xml(xml_response)
|
16
|
+
job = GOCD::PIPELINE_CONFIG::Job.new 'MyAwesomePipeline', 'spec', response['job']
|
17
|
+
|
18
|
+
expect(job.resources.size).to eq 2
|
19
|
+
expect(job.resources.first).to eq 'mac'
|
20
|
+
expect(job.pipeline).to eq 'MyAwesomePipeline'
|
21
|
+
expect(job.stage).to eq 'spec'
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require './lib/gocd/pipeline_config/pipeline_group'
|
2
|
+
require 'active_support/core_ext/hash/conversions'
|
3
|
+
|
4
|
+
RSpec.describe GOCD::PIPELINE_CONFIG::PipelineGroup, 'PipelineGroup' do
|
5
|
+
pipeline_group_xml = <<-PipelineGroup
|
6
|
+
<pipelines group="MyPipelineGroup">
|
7
|
+
<pipeline name="MyAwesomePipeline" isLocked="false">
|
8
|
+
<stage name="build">
|
9
|
+
<jobs>
|
10
|
+
<job name="flavor1_build">
|
11
|
+
<resources>
|
12
|
+
<resource>mac</resource>
|
13
|
+
<resource>build</resource>
|
14
|
+
</resources>
|
15
|
+
</job>
|
16
|
+
<job name="flavor2_build">
|
17
|
+
<resources>
|
18
|
+
<resource>mac</resource>
|
19
|
+
<resource>build</resource>
|
20
|
+
</resources>
|
21
|
+
</job>
|
22
|
+
</jobs>
|
23
|
+
</stage>
|
24
|
+
<stage name="spec">
|
25
|
+
<jobs>
|
26
|
+
<job name="flavor1_spec" timeout="60">
|
27
|
+
<resources>
|
28
|
+
<resource>mac</resource>
|
29
|
+
<resource>spec</resource>
|
30
|
+
</resources>
|
31
|
+
</job>
|
32
|
+
<job name="flavor2_spec" timeout="60">
|
33
|
+
<resources>
|
34
|
+
<resource>mac</resource>
|
35
|
+
<resource>spec</resource>
|
36
|
+
</resources>
|
37
|
+
</job>
|
38
|
+
</jobs>
|
39
|
+
</stage>
|
40
|
+
</pipeline>
|
41
|
+
</pipelines>
|
42
|
+
PipelineGroup
|
43
|
+
|
44
|
+
it 'should parse pipeline group' do
|
45
|
+
response = Hash.from_xml(pipeline_group_xml)
|
46
|
+
pipeline_group = GOCD::PIPELINE_CONFIG::PipelineGroup.new response['pipelines']
|
47
|
+
|
48
|
+
expect(pipeline_group.name).to eq 'MyPipelineGroup'
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require './lib/gocd/pipeline_config/pipeline_group'
|
2
|
+
require 'active_support/core_ext/hash/conversions'
|
3
|
+
|
4
|
+
RSpec.describe GOCD::PIPELINE_CONFIG::Pipeline, 'Pipeline' do
|
5
|
+
xml_response = <<-PipelineGroup
|
6
|
+
<pipeline name="MyAwesomePipeline" isLocked="false">
|
7
|
+
<stage name="build">
|
8
|
+
<jobs>
|
9
|
+
<job name="flavor1_build">
|
10
|
+
<resources>
|
11
|
+
<resource>mac</resource>
|
12
|
+
<resource>build</resource>
|
13
|
+
</resources>
|
14
|
+
</job>
|
15
|
+
<job name="flavor2_build">
|
16
|
+
<resources>
|
17
|
+
<resource>mac</resource>
|
18
|
+
<resource>build</resource>
|
19
|
+
</resources>
|
20
|
+
</job>
|
21
|
+
</jobs>
|
22
|
+
</stage>
|
23
|
+
<stage name="spec">
|
24
|
+
<jobs>
|
25
|
+
<job name="flavor1_spec" timeout="60">
|
26
|
+
<resources>
|
27
|
+
<resource>mac</resource>
|
28
|
+
<resource>spec</resource>
|
29
|
+
</resources>
|
30
|
+
</job>
|
31
|
+
<job name="flavor2_spec" timeout="60">
|
32
|
+
<resources>
|
33
|
+
<resource>mac</resource>
|
34
|
+
<resource>spec</resource>
|
35
|
+
</resources>
|
36
|
+
</job>
|
37
|
+
</jobs>
|
38
|
+
</stage>
|
39
|
+
</pipeline>
|
40
|
+
PipelineGroup
|
41
|
+
|
42
|
+
template_pipline = <<-PipelineGroup
|
43
|
+
<pipeline name="MyAwesomePipeline" isLocked="false" template="MyAwesomeTemplate">
|
44
|
+
</pipeline>
|
45
|
+
PipelineGroup
|
46
|
+
|
47
|
+
it 'should parse pipeline' do
|
48
|
+
response = Hash.from_xml(xml_response)
|
49
|
+
pipeline = GOCD::PIPELINE_CONFIG::Pipeline.new response['pipeline']
|
50
|
+
|
51
|
+
expect(pipeline.name).to eq 'MyAwesomePipeline'
|
52
|
+
expect(pipeline.stages.size).to eq 2
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should parse pipeline created from template' do
|
56
|
+
response = Hash.from_xml(template_pipline)
|
57
|
+
pipeline = GOCD::PIPELINE_CONFIG::Pipeline.new response['pipeline']
|
58
|
+
|
59
|
+
expect(pipeline.name).to eq 'MyAwesomePipeline'
|
60
|
+
expect(pipeline.template).to eq 'MyAwesomeTemplate'
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require './lib/gocd/pipeline_config/pipeline_group'
|
2
|
+
require 'active_support/core_ext/hash/conversions'
|
3
|
+
|
4
|
+
RSpec.describe GOCD::PIPELINE_CONFIG::Stage, 'Stage' do
|
5
|
+
xml_response = <<-PipelineGroup
|
6
|
+
<stage name="build">
|
7
|
+
<jobs>
|
8
|
+
<job name="flavor1_build">
|
9
|
+
<resources>
|
10
|
+
<resource>mac</resource>
|
11
|
+
<resource>build</resource>
|
12
|
+
</resources>
|
13
|
+
</job>
|
14
|
+
<job name="flavor2_build">
|
15
|
+
<resources>
|
16
|
+
<resource>mac</resource>
|
17
|
+
<resource>build</resource>
|
18
|
+
</resources>
|
19
|
+
</job>
|
20
|
+
</jobs>
|
21
|
+
</stage>
|
22
|
+
PipelineGroup
|
23
|
+
|
24
|
+
it 'should parse stage' do
|
25
|
+
response = Hash.from_xml(xml_response)
|
26
|
+
stage = GOCD::PIPELINE_CONFIG::Stage.new 'MyAwesomePipeline', response['stage']
|
27
|
+
|
28
|
+
expect(stage.name).to eq 'build'
|
29
|
+
expect(stage.pipeline).to eq 'MyAwesomePipeline'
|
30
|
+
expect(stage.jobs.size).to eq 2
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require './lib/gocd/pipeline_config/template'
|
2
|
+
require 'active_support/core_ext/hash/conversions'
|
3
|
+
|
4
|
+
RSpec.describe GOCD::PIPELINE_CONFIG::Template, 'Template' do
|
5
|
+
xml_response = <<-Template
|
6
|
+
<templates>
|
7
|
+
<pipeline name="MyPipeline">
|
8
|
+
<stage name="prepare">
|
9
|
+
<jobs>
|
10
|
+
<job name="job1">
|
11
|
+
<resources>
|
12
|
+
<resource>promotion</resource>
|
13
|
+
<resource>mac</resource>
|
14
|
+
</resources>
|
15
|
+
</job>
|
16
|
+
</jobs>
|
17
|
+
</stage>
|
18
|
+
</pipeline>
|
19
|
+
</templates>
|
20
|
+
Template
|
21
|
+
|
22
|
+
it 'should parse template' do
|
23
|
+
response = Hash.from_xml(xml_response)
|
24
|
+
pipeline = GOCD::PIPELINE_CONFIG::Template.new response['templates']['pipeline']
|
25
|
+
|
26
|
+
expect(pipeline.name).to eq 'MyPipeline'
|
27
|
+
expect(pipeline.template.nil?).to be_truthy
|
28
|
+
expect(pipeline.stages.size).to eq 1
|
29
|
+
expect(pipeline.stages.first.jobs.size).to eq 1
|
30
|
+
expect(pipeline.stages.first.jobs.first.resources.size).to eq 2
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require './lib/gocd/pipeline_status/pipeline'
|
2
|
+
|
3
|
+
RSpec.describe GOCD::Pipeline, 'pipeline' do
|
4
|
+
|
5
|
+
context 'when last build status is success' do
|
6
|
+
before(:each) do
|
7
|
+
@raw_pipeline = { 'name' => 'pipeline 1', 'activity' => 'sleeping', 'lastBuildStatus' => 'Success' }
|
8
|
+
end
|
9
|
+
|
10
|
+
it '#name should return name' do
|
11
|
+
@pipeline = GOCD::Pipeline.new @raw_pipeline
|
12
|
+
expect(@pipeline.name).to eq 'pipeline 1'
|
13
|
+
end
|
14
|
+
|
15
|
+
it '#last_build_status should return last build status' do
|
16
|
+
@pipeline = GOCD::Pipeline.new @raw_pipeline
|
17
|
+
expect(@pipeline.last_build_status).to eq 'Success'
|
18
|
+
end
|
19
|
+
|
20
|
+
it '#green? should return true' do
|
21
|
+
@pipeline = GOCD::Pipeline.new @raw_pipeline
|
22
|
+
expect(@pipeline.green?).to be_truthy
|
23
|
+
end
|
24
|
+
|
25
|
+
it '#red? should return false' do
|
26
|
+
@pipeline = GOCD::Pipeline.new @raw_pipeline
|
27
|
+
expect(@pipeline.red?).to be_falsey
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when last build status is failure' do
|
32
|
+
before(:each) do
|
33
|
+
@raw_pipeline = { 'name' => 'pipeline 1', 'activity' => 'sleeping', 'lastBuildStatus' => 'Failure' }
|
34
|
+
end
|
35
|
+
|
36
|
+
it '#green? should return false' do
|
37
|
+
@pipeline = GOCD::Pipeline.new @raw_pipeline
|
38
|
+
expect(@pipeline.green?).to be_falsey
|
39
|
+
end
|
40
|
+
|
41
|
+
it '#red? should return true' do
|
42
|
+
@pipeline = GOCD::Pipeline.new @raw_pipeline
|
43
|
+
expect(@pipeline.red?).to be_truthy
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative '../../../lib/gocd/pipeline_status/pipeline_repository'
|
2
|
+
require_relative '../../../lib/gocd/config/credentials'
|
3
|
+
require_relative '../../../lib/gocd/config/server'
|
4
|
+
require_relative '../../../lib/gocd/exception/data_fetch_exception'
|
5
|
+
|
6
|
+
|
7
|
+
def setup_credential_and_server
|
8
|
+
GOCD.credentials = GOCD::Credentials.new 'admin', 'password'
|
9
|
+
GOCD.server = GOCD::Server.new 'http://gocd.com'
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec.describe GOCD::PipelineRepository, 'pipelines' do
|
13
|
+
|
14
|
+
response_xml = '<?xml version="1.0" encoding="utf-8"?>
|
15
|
+
<Projects>
|
16
|
+
<Project name="pipeline1" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="kernel-5044" lastBuildTime="2016-10-28T04:31:37" webUrl="http://go.lgnbrry.com/go/pipelines/Mobile_Web/5044/kernel/1" />
|
17
|
+
<Project name="pipeline2" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="kernel-5044" lastBuildTime="2016-10-28T04:31:37" webUrl="http://go.lgnbrry.com/go/tab/build/detail/Mobile_Web/5044/kernel/1/spec" />
|
18
|
+
</Projects>'
|
19
|
+
|
20
|
+
it '#pipelines should return all pipelines' do
|
21
|
+
setup_credential_and_server
|
22
|
+
curl_command = 'curl -s -k -u admin:password http://gocd.com/go/cctray.xml'
|
23
|
+
expect(GOCD::PipelineRepository).to receive(:`).with(curl_command).and_return(response_xml)
|
24
|
+
|
25
|
+
pipelines = GOCD::PipelineRepository.pipelines
|
26
|
+
expect(pipelines.size).to eq 2
|
27
|
+
expect(pipelines[0].name).to eq 'pipeline1'
|
28
|
+
expect(pipelines[0].last_build_status).to eq 'Success'
|
29
|
+
expect(pipelines[1].name).to eq 'pipeline2'
|
30
|
+
expect(pipelines[1].last_build_status).to eq 'Success'
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
it '#pipelines should raise GOCDDataFetchException exception' do
|
35
|
+
GOCD::PipelineRepository.instance_variable_set(:@pipelines, nil)
|
36
|
+
setup_credential_and_server
|
37
|
+
curl_command = 'curl -s -k -u admin:password http://gocd.com/go/cctray.xml'
|
38
|
+
empty_response = ''
|
39
|
+
expect(GOCD::PipelineRepository).to receive(:`).with(curl_command).and_return(empty_response)
|
40
|
+
|
41
|
+
expect{GOCD::PipelineRepository.pipelines}.to raise_error(GOCDDataFetchException).with_message('Could not fetch data from server!!')
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require './lib/gocd/pipeline_status/pipelines'
|
2
|
+
require_relative '../../../lib/gocd/pipeline_status/pipeline_repository'
|
3
|
+
|
4
|
+
def mock_pipeline_repository
|
5
|
+
pipeline1 = instance_double("Pipeline", :red? => true, :green? => false, :status => 'failing', :name => 'pipeline1')
|
6
|
+
pipeline2 = instance_double("Pipeline", :red? => true, :green? => false, :status => 'failing', :name => 'pipeline2')
|
7
|
+
pipeline3 = instance_double("Pipeline", :red? => false, :green? => true, :status => 'passing', :name => 'pipeline3')
|
8
|
+
expect(GOCD::PipelineRepository).to receive(:pipelines).and_return([pipeline1, pipeline2, pipeline3])
|
9
|
+
end
|
10
|
+
|
11
|
+
def mock_pipeline_repository_with_green_pipelines
|
12
|
+
pipeline1 = instance_double("Pipeline", :red? => false, :green? => true, :status => 'passing', :name => 'pipeline1')
|
13
|
+
pipeline2 = instance_double("Pipeline", :red? => false, :green? => true, :status => 'passing', :name => 'pipeline2')
|
14
|
+
expect(GOCD::PipelineRepository).to receive(:pipelines).and_return([pipeline1, pipeline2])
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec.describe GOCD::AllPipelines, 'pipelines' do
|
18
|
+
|
19
|
+
context 'All Pipelines' do
|
20
|
+
|
21
|
+
it '#red_pipelines should return red pipelines' do
|
22
|
+
mock_pipeline_repository
|
23
|
+
expect(GOCD::AllPipelines.red_pipelines.size).to eq 2
|
24
|
+
end
|
25
|
+
|
26
|
+
it '#green_pipelines should return green pipelines' do
|
27
|
+
mock_pipeline_repository
|
28
|
+
expect(GOCD::AllPipelines.green_pipelines.size).to eq 1
|
29
|
+
end
|
30
|
+
|
31
|
+
it '#status should return pipelines status' do
|
32
|
+
mock_pipeline_repository
|
33
|
+
expect(GOCD::AllPipelines.status).to eq %w(failing failing passing)
|
34
|
+
end
|
35
|
+
|
36
|
+
it '#any_red? should return true when red pipeline found' do
|
37
|
+
mock_pipeline_repository
|
38
|
+
expect(GOCD::AllPipelines.any_red?).to be_truthy
|
39
|
+
end
|
40
|
+
|
41
|
+
it '#any_red? should return false when no red pipeline found' do
|
42
|
+
mock_pipeline_repository_with_green_pipelines
|
43
|
+
expect(GOCD::AllPipelines.any_red?).to be_falsy
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
context 'Group Pipelines' do
|
49
|
+
|
50
|
+
it '#red_pipelines should return red pipelines' do
|
51
|
+
mock_pipeline_repository
|
52
|
+
pipeline_group = GOCD::PipelineGroup.new %w(pipeline1 pipeline3)
|
53
|
+
expect(pipeline_group.red_pipelines.size).to eq 1
|
54
|
+
end
|
55
|
+
|
56
|
+
it '#green_pipelines should return green pipelines' do
|
57
|
+
mock_pipeline_repository
|
58
|
+
pipeline_group = GOCD::PipelineGroup.new %w(pipeline1 pipeline3)
|
59
|
+
expect(pipeline_group.green_pipelines.size).to eq 1
|
60
|
+
end
|
61
|
+
|
62
|
+
it '#status should return pipelines status' do
|
63
|
+
mock_pipeline_repository
|
64
|
+
pipeline_group = GOCD::PipelineGroup.new %w(pipeline1 pipeline3)
|
65
|
+
expect(pipeline_group.status).to eq %w(failing passing)
|
66
|
+
end
|
67
|
+
|
68
|
+
it '#any_red? should return true when red pipeline found' do
|
69
|
+
mock_pipeline_repository
|
70
|
+
pipeline_group = GOCD::PipelineGroup.new %w(pipeline1 pipeline3)
|
71
|
+
expect(pipeline_group.any_red?).to be_truthy
|
72
|
+
end
|
73
|
+
|
74
|
+
it '#any_red? should return false when no red pipeline found' do
|
75
|
+
mock_pipeline_repository_with_green_pipelines
|
76
|
+
pipeline_group = GOCD::PipelineGroup.new %w(pipeline1 pipeline2)
|
77
|
+
expect(pipeline_group.any_red?).to be_falsy
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
44
|
+
# have no way to turn it off -- the option exists only for backwards
|
45
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
46
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
47
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
48
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
49
|
+
|
50
|
+
# The settings below are suggested to provide a good initial experience
|
51
|
+
# with RSpec, but feel free to customize to your heart's content.
|
52
|
+
=begin
|
53
|
+
# This allows you to limit a spec run to individual examples or groups
|
54
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
55
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
56
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
57
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
58
|
+
config.filter_run_when_matching :focus
|
59
|
+
|
60
|
+
# Allows RSpec to persist some state between runs in order to support
|
61
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
62
|
+
# you configure your source control system to ignore this file.
|
63
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
64
|
+
|
65
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
66
|
+
# recommended. For more details, see:
|
67
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
68
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
69
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
70
|
+
config.disable_monkey_patching!
|
71
|
+
|
72
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
73
|
+
# be too noisy due to issues in dependencies.
|
74
|
+
config.warnings = true
|
75
|
+
|
76
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
77
|
+
# file, and it's useful to allow more verbose output when running an
|
78
|
+
# individual spec file.
|
79
|
+
if config.files_to_run.one?
|
80
|
+
# Use the documentation formatter for detailed output,
|
81
|
+
# unless a formatter has already been configured
|
82
|
+
# (e.g. via a command-line flag).
|
83
|
+
config.default_formatter = 'doc'
|
84
|
+
end
|
85
|
+
|
86
|
+
# Print the 10 slowest examples and example groups at the
|
87
|
+
# end of the spec run, to help surface which specs are running
|
88
|
+
# particularly slow.
|
89
|
+
config.profile_examples = 10
|
90
|
+
|
91
|
+
# Run specs in random order to surface order dependencies. If you find an
|
92
|
+
# order dependency and want to debug it, you can fix the order by providing
|
93
|
+
# the seed, which is printed after each run.
|
94
|
+
# --seed 1234
|
95
|
+
config.order = :random
|
96
|
+
|
97
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
98
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
99
|
+
# test failures related to randomization by passing the same `--seed` value
|
100
|
+
# as the one that triggered the failure.
|
101
|
+
Kernel.srand config.seed
|
102
|
+
=end
|
103
|
+
end
|