specinfra 2.0.0.beta5 → 2.0.0.beta6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65e4d83475bbdd34b27754036496fc53ba0a2134
4
- data.tar.gz: 46cbd1679ece1082f94dea53e3cb9ed5e54974c8
3
+ metadata.gz: c59de503cd2a6e1e99e571d21abe145d4901c62e
4
+ data.tar.gz: 4c84a1001c9c5df401c3195fd9c957b33c43b8c0
5
5
  SHA512:
6
- metadata.gz: b2d221e45cb170df18ffa898388eb7018143e828e6045591bbd63e3f2f931283899192490bcb391d107a35421f0df967cbddfc1eb98dc28bc692339b41388a5f
7
- data.tar.gz: 713db6f57e9ff241a5aa23c531e3a51c2c0584114ebd9f0f1d8917b005a21ec0667032c07d7c9b6bbf8248b7568f066a0f35d52febbefbf525eab3bd963c3928
6
+ metadata.gz: 4367b260c7854879384d8f9292fdd9ae4eda45693445d951e675c91140e0c068ff76e52df1b8f7b878b77063410f84680f7b51713b499219e0c543536fe02c4b
7
+ data.tar.gz: c69205dad07e42abab0fab31fdfdd8873a3964cd50395ec4c9f9b2223154803d42da040407600b8d2511828b852575f9a25793ac6f9fdb6113893467641cf2d6
data/Rakefile CHANGED
@@ -31,5 +31,9 @@ if defined?(RSpec)
31
31
  RSpec::Core::RakeTask.new(:configuration) do |t|
32
32
  t.pattern = "spec/configuration_spec.rb"
33
33
  end
34
+
35
+ RSpec::Core::RakeTask.new(:command) do |t|
36
+ t.pattern = "spec/command/*.rb"
37
+ end
34
38
  end
35
39
  end
@@ -77,7 +77,7 @@ module Specinfra
77
77
 
78
78
  channel.on_extended_data do |ch, type, data|
79
79
  if data.match /you must have a tty to run sudo/
80
- abort 'Please set "Specinfra.configuration.request_pty = true" or "c.request_pty = true" in your spec_helper.rb or other appropreate file.'
80
+ abort 'Please set "SpecInfra.configuration.request_pty = true" or "c.request_pty = true" in your spec_helper.rb or other appropriate file.'
81
81
  end
82
82
 
83
83
  if data.match /^sudo: no tty present and no askpass program specified/
@@ -80,7 +80,7 @@ module Specinfra
80
80
  end
81
81
 
82
82
  def check_group(group)
83
- "getent group | grep -wq -- #{escape(group)}"
83
+ "getent group #{escape(group)}"
84
84
  end
85
85
 
86
86
  def check_installed(package, version=nil)
@@ -95,14 +95,15 @@ module Specinfra
95
95
  raise NotImplementedError.new
96
96
  end
97
97
 
98
- def check_listening(port)
99
- regexp = ":#{port} "
100
- "netstat -tunl | grep -- #{escape(regexp)}"
98
+ def check_listening(port, options = {})
99
+ pattern = ":#{port}"
100
+ pattern = " #{options[:local_address]}#{pattern}" if options[:local_address]
101
+ pattern = "^#{options[:protocol]} .*#{pattern}" if options[:protocol]
102
+ "netstat -tunl | grep -- #{escape(pattern)}"
101
103
  end
102
104
 
103
105
  def check_listening_with_protocol(port, protocol)
104
- regexp = "^#{protocol} .*:#{port} "
105
- "netstat -tunl | grep -- #{escape(regexp)}"
106
+ check_listening port, {:protocol => protocol}
106
107
  end
107
108
 
108
109
  def check_running(service)
@@ -200,7 +201,7 @@ module Specinfra
200
201
  end
201
202
 
202
203
  def check_cron_entry(user, entry)
203
- entry_escaped = entry.gsub(/\*/, '\\*')
204
+ entry_escaped = entry.gsub(/\*/, '\\*').gsub(/\[/, '\\[').gsub(/\]/, '\\]')
204
205
  if user.nil?
205
206
  "crontab -l | grep -v \"#\" -- | grep -- #{escape(entry_escaped)}"
206
207
  else
@@ -28,7 +28,7 @@ module Specinfra
28
28
  end
29
29
 
30
30
  def check_cron_entry(user, entry)
31
- entry_escaped = entry.gsub(/\*/, '\\*')
31
+ entry_escaped = entry.gsub(/\*/, '\\*').gsub(/\[/, '\\[').gsub(/\]/, '\\]')
32
32
  if user.nil?
33
33
  "crontab -l | grep -- #{escape(entry_escaped)}"
34
34
  else
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.0.0.beta5"
2
+ VERSION = "2.0.0.beta6"
3
3
  end
@@ -78,7 +78,7 @@ describe 'check_os' do
78
78
  context 'test ubuntu with lsb_release command' do
79
79
  subject { backend.check_os }
80
80
  it do
81
- backend.should_receive(:run_command).at_least(1).times do |args|
81
+ expect(backend).to receive(:run_command).at_least(1).times do |args|
82
82
  if ['ls /etc/debian_version', 'lsb_release -ir'].include? args
83
83
  double(
84
84
  :run_command_response,
@@ -98,7 +98,7 @@ describe 'check_os' do
98
98
  context 'test ubuntu with /etc/lsb-release' do
99
99
  subject { backend.check_os }
100
100
  it do
101
- backend.should_receive(:run_command).at_least(1).times do |args|
101
+ expect(backend).to receive(:run_command).at_least(1).times do |args|
102
102
  if ['ls /etc/debian_version', 'cat /etc/lsb-release'].include? args
103
103
  double(
104
104
  :run_command_response,
@@ -123,7 +123,7 @@ EOF
123
123
  context 'test debian (no lsb_release or lsb-release)' do
124
124
  subject { backend.check_os }
125
125
  it do
126
- backend.should_receive(:run_command).at_least(1).times do |args|
126
+ expect(backend).to receive(:run_command).at_least(1).times do |args|
127
127
  if args == 'ls /etc/debian_version'
128
128
  double :run_command_response, :success? => true
129
129
  elsif args == 'uname -m'
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Specinfra::Command::Base do
4
+ describe '#check_listening' do
5
+ let(:port) { 80 }
6
+ let(:options) { {} }
7
+ subject { described_class.new.check_listening(port, options) }
8
+
9
+ it { should_not be_empty }
10
+ it { should start_with('netstat') }
11
+ it { should include(':80') }
12
+ it { should be_a_kind_of(String) }
13
+
14
+ context 'with protocol' do
15
+ let(:protocol) { 'tcp' }
16
+ let(:options) { {:protocol => protocol} }
17
+
18
+ it { should include(protocol) }
19
+ end
20
+
21
+ context 'with local_address' do
22
+ let(:local_address) { '127.0.0.1' }
23
+ let(:options) { {:local_address => local_address} }
24
+
25
+ it { should include(local_address) }
26
+ end
27
+ end
28
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta5
4
+ version: 2.0.0.beta6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-15 00:00:00.000000000 Z
11
+ date: 2014-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -146,6 +146,7 @@ files:
146
146
  - lib/specinfra/version.rb
147
147
  - spec/backend/exec/build_command_spec.rb
148
148
  - spec/backend/ssh/build_command_spec.rb
149
+ - spec/command/base.rb
149
150
  - spec/configuration_spec.rb
150
151
  - spec/helper/backend_spec.rb
151
152
  - spec/helper/properties_spec.rb
@@ -180,6 +181,7 @@ summary: Common layer for serverspec and configspec
180
181
  test_files:
181
182
  - spec/backend/exec/build_command_spec.rb
182
183
  - spec/backend/ssh/build_command_spec.rb
184
+ - spec/command/base.rb
183
185
  - spec/configuration_spec.rb
184
186
  - spec/helper/backend_spec.rb
185
187
  - spec/helper/properties_spec.rb