poise-service-spechelper 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +42 -0
- data/Rakefile +17 -0
- data/lib/poise_service/spec_helper.rb +18 -0
- data/lib/poise_service/spec_helper/helper.rb +123 -0
- data/lib/poise_service/spec_helper/version.rb +22 -0
- data/poise-service-spechelper.gemspec +35 -0
- metadata +51 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 764ce9f39fcf0940821597952e332d3f7f21ddfb
|
4
|
+
data.tar.gz: 04659b9f1ea40d128ec1cb8f91cc470337d62767
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 935b9b7923baec7fc5de6835e49056cd6ed8dcdb054d17c443fbe28346d0c9dd55b8f133407d5b0e063d1b3b26ff306b87d54e4c45077243345958f67da19baf
|
7
|
+
data.tar.gz: f40025ddc312d994d2d69e4b2e865fa0e3831ac6edfaee923aa16e6594657c59567234096abe549d03e7d3999d68b44aa0bd5ed4d6a2cfc6e23a5740c70767fc
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# PoiseService::SpecHelper
|
2
|
+
|
3
|
+
[![Build Status](https://img.shields.io/travis/poise/poise-service-spechelper.svg)](https://travis-ci.org/poise/poise-service-spechelper)
|
4
|
+
[![Gem Version](https://img.shields.io/gem/v/poise-service-spechelper.svg)](https://rubygems.org/gems/poise-service-spechelper)
|
5
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/poise/poise-service-spechelper.svg)](https://codeclimate.com/github/poise/poise-service-spechelper)
|
6
|
+
[![Gemnasium](https://img.shields.io/gemnasium/poise/poise-service-spechelper.svg)](https://gemnasium.com/poise/poise-service-spechelper)
|
7
|
+
[![License](https://img.shields.io/badge/license-Apache_2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
|
8
|
+
|
9
|
+
This gem exists only to help with integration tests of [poise-service](https://github.com/poise/poise-service)
|
10
|
+
providers. It provides an RSpec shared example called `'a poise_service_test'`
|
11
|
+
which verifies the correctness of `poise_service_test` resource.
|
12
|
+
|
13
|
+
You can use this shared example by adding `gem 'poise-service-spechelper'` to
|
14
|
+
the Gemfile in your `serverspec/` folder. Then call it in your RSpec like:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
describe 'dummy provider' do
|
18
|
+
it_should_behave_like 'a poise_service_test', 'dummy', 9000, false
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
## Sponsors
|
23
|
+
|
24
|
+
Development sponsored by [Bloomberg](http://www.bloomberg.com/company/technology/).
|
25
|
+
|
26
|
+
The Poise test server infrastructure is sponsored by [Rackspace](https://rackspace.com/).
|
27
|
+
|
28
|
+
## License
|
29
|
+
|
30
|
+
Copyright 2015, Noah Kantrowitz
|
31
|
+
|
32
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
33
|
+
you may not use this file except in compliance with the License.
|
34
|
+
You may obtain a copy of the License at
|
35
|
+
|
36
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
37
|
+
|
38
|
+
Unless required by applicable law or agreed to in writing, software
|
39
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
40
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
41
|
+
See the License for the specific language governing permissions and
|
42
|
+
limitations under the License.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2015, Noah Kantrowitz
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2015, Noah Kantrowitz
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'poise_service/spec_helper/helper'
|
18
|
+
PoiseService::SpecHelper::Helper.install
|
@@ -0,0 +1,123 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2015, Noah Kantrowitz
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
# For the json_http helper below.
|
18
|
+
require 'json'
|
19
|
+
require 'net/http'
|
20
|
+
require 'uri'
|
21
|
+
|
22
|
+
|
23
|
+
module PoiseService
|
24
|
+
module SpecHelper
|
25
|
+
# Not using Halite::HelperBase to avoid the dependency.
|
26
|
+
class Helper
|
27
|
+
def self.install
|
28
|
+
# Load and configure Serverspec.
|
29
|
+
require 'serverspec'
|
30
|
+
set :backend, :exec
|
31
|
+
|
32
|
+
# Set up the shared example for poise_service_test.
|
33
|
+
RSpec.shared_examples 'a poise_service_test' do |name, base_port, check_service=true|
|
34
|
+
def json_http(uri)
|
35
|
+
JSON.parse(Net::HTTP.get(URI(uri)))
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'default service' do
|
39
|
+
describe service("poise_test_#{name}") do
|
40
|
+
it { is_expected.to be_enabled }
|
41
|
+
it { is_expected.to be_running }
|
42
|
+
end if check_service
|
43
|
+
|
44
|
+
describe 'process environment' do
|
45
|
+
subject { json_http("http://localhost:#{base_port}/") }
|
46
|
+
it { is_expected.to include({
|
47
|
+
'user' => 'root',
|
48
|
+
'directory' => '/',
|
49
|
+
}) }
|
50
|
+
end
|
51
|
+
end # /describe default service
|
52
|
+
|
53
|
+
describe 'service with parameters' do
|
54
|
+
describe service("poise_test_#{name}_params") do
|
55
|
+
it { is_expected.to be_enabled }
|
56
|
+
it { is_expected.to be_running }
|
57
|
+
end if check_service
|
58
|
+
|
59
|
+
describe 'process environment' do
|
60
|
+
subject { json_http("http://localhost:#{base_port+1}/") }
|
61
|
+
it { is_expected.to include({
|
62
|
+
'user' => 'poise',
|
63
|
+
'directory' => '/tmp',
|
64
|
+
'environment' => include({'POISE_ENV' => name}),
|
65
|
+
}) }
|
66
|
+
end
|
67
|
+
end # /describe service with parameters
|
68
|
+
|
69
|
+
describe 'noterm service' do
|
70
|
+
describe service("poise_test_#{name}_noterm") do
|
71
|
+
it { is_expected.to_not be_enabled }
|
72
|
+
it { is_expected.to_not be_running }
|
73
|
+
end if check_service
|
74
|
+
|
75
|
+
describe 'process environment' do
|
76
|
+
subject { json_http("http://localhost:#{base_port+2}/") }
|
77
|
+
it { expect { subject }.to raise_error }
|
78
|
+
end
|
79
|
+
end # /describe noterm service
|
80
|
+
|
81
|
+
describe 'restart service' do
|
82
|
+
describe service("poise_test_#{name}_restart") do
|
83
|
+
it { is_expected.to be_enabled }
|
84
|
+
it { is_expected.to be_running }
|
85
|
+
end if check_service
|
86
|
+
|
87
|
+
describe 'process environment' do
|
88
|
+
subject { json_http("http://localhost:#{base_port+3}/") }
|
89
|
+
it do
|
90
|
+
is_expected.to include({
|
91
|
+
'file_data' => 'second',
|
92
|
+
})
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end # /describe restart service
|
96
|
+
|
97
|
+
describe 'reload service' do
|
98
|
+
describe service("poise_test_#{name}_reload") do
|
99
|
+
it { is_expected.to be_enabled }
|
100
|
+
it { is_expected.to be_running }
|
101
|
+
end if check_service
|
102
|
+
|
103
|
+
describe 'process environment' do
|
104
|
+
subject { json_http("http://localhost:#{base_port+4}/") }
|
105
|
+
it do
|
106
|
+
is_expected.to include({
|
107
|
+
'file_data' => 'second',
|
108
|
+
})
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end # /describe reload service
|
112
|
+
|
113
|
+
describe 'pid file' do
|
114
|
+
subject { IO.read("/tmp/poise_test_#{name}_pid") }
|
115
|
+
it { is_expected.to match /\d+/ }
|
116
|
+
its(:to_i) { is_expected.to eq json_http("http://localhost:#{base_port}/")['pid'] }
|
117
|
+
it { Process.kill(0, subject.to_i) }
|
118
|
+
end # /describe pid file
|
119
|
+
end # /shared_examples a poise_service_test
|
120
|
+
end # /def install
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2015, Noah Kantrowitz
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
|
18
|
+
module PoiseService
|
19
|
+
module SpecHelper
|
20
|
+
VERSION = '1.0.0'
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2015, Noah Kantrowitz
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
lib = File.expand_path('../lib', __FILE__)
|
18
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
19
|
+
require 'poise_service/spec_helper/version'
|
20
|
+
|
21
|
+
Gem::Specification.new do |spec|
|
22
|
+
spec.name = 'poise-service-spechelper'
|
23
|
+
spec.version = PoiseService::SpecHelper::VERSION
|
24
|
+
spec.authors = ['Noah Kantrowitz']
|
25
|
+
spec.email = %w{noah@coderanger.net}
|
26
|
+
spec.description = 'A helper for testing poise-service providers.'
|
27
|
+
spec.summary = spec.description
|
28
|
+
spec.homepage = 'https://github.com/poise/poise-service-spechelper'
|
29
|
+
spec.license = 'Apache 2.0'
|
30
|
+
|
31
|
+
spec.files = `git ls-files`.split($/)
|
32
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
33
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
34
|
+
spec.require_paths = %w{lib}
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: poise-service-spechelper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Noah Kantrowitz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A helper for testing poise-service providers.
|
14
|
+
email:
|
15
|
+
- noah@coderanger.net
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- README.md
|
21
|
+
- Rakefile
|
22
|
+
- lib/poise_service/spec_helper.rb
|
23
|
+
- lib/poise_service/spec_helper/helper.rb
|
24
|
+
- lib/poise_service/spec_helper/version.rb
|
25
|
+
- poise-service-spechelper.gemspec
|
26
|
+
homepage: https://github.com/poise/poise-service-spechelper
|
27
|
+
licenses:
|
28
|
+
- Apache 2.0
|
29
|
+
metadata: {}
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements: []
|
45
|
+
rubyforge_project:
|
46
|
+
rubygems_version: 2.2.2
|
47
|
+
signing_key:
|
48
|
+
specification_version: 4
|
49
|
+
summary: A helper for testing poise-service providers.
|
50
|
+
test_files: []
|
51
|
+
has_rdoc:
|