Skip to content

Commit

Permalink
Merge pull request #449 from serverspec/move-commands-global-to-insid…
Browse files Browse the repository at this point in the history
…e-specinfra

Move commands method from global to inside Specinfra
  • Loading branch information
mizzy committed Jul 30, 2014
2 parents e1a59d3 + 9b27f2a commit 4b44b57
Show file tree
Hide file tree
Showing 103 changed files with 9 additions and 394 deletions.
2 changes: 1 addition & 1 deletion lib/serverspec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rubygems'
require 'specinfra'
require 'rspec'
require 'rspec/its'
require 'specinfra'
require 'serverspec/version'
require 'serverspec/matchers'
require 'serverspec/helper'
Expand Down
4 changes: 2 additions & 2 deletions lib/serverspec/type/default_gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ module Serverspec
module Type
class DefaultGateway < Base
def ipaddress
ret = @runner.run_command(commands.check_routing_table_has_entry('default'))
ret = @runner.get_routing_table_entry(:destination => 'default')
ret.stdout =~ /^(\S+)(?: via (\S+))? dev (\S+).+(?:\r)?\n(?:default via (\S+))?/
$2 ? $2 : $4
end

def interface
ret = @runner.run_command(commands.check_routing_table_has_entry('default'))
ret = @runner.get_routing_table_entry(:destination => 'default')
ret.stdout =~ /^(\S+)(?: via (\S+))? dev (\S+).+(?:\r)?\n(?:default via (\S+))?/
$3
end
Expand Down
2 changes: 1 addition & 1 deletion lib/serverspec/type/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def match_sha256checksum(sha256sum)

def content
if @content.nil?
@content = @runner.run_command(commands.get_file_content(@name)).stdout
@content = @runner.get_file_content(@name).stdout
end
@content
end
Expand Down
2 changes: 1 addition & 1 deletion lib/serverspec/type/interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Serverspec
module Type
class Interface < Base
def speed
ret = @runner.run_command(commands.get_interface_speed_of(@name))
ret = @runner.get_interface_speed_of(@name)
val = ret.stdout.strip
val = val.to_i if val.match(/^\d+$/)
val
Expand Down
2 changes: 1 addition & 1 deletion lib/serverspec/type/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def installed?(provider, version)
end

def version
ret = @runner.run_command(commands.get_package_version(@name)).stdout.strip
ret = @runner.get_package_version(@name).stdout.strip
if ret.empty?
nil
else
Expand Down
2 changes: 1 addition & 1 deletion lib/serverspec/type/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Serverspec
module Type
class Process < Base
def running?
pid = @runner.run_command(commands.get_process(@name, :format => "pid=")).stdout
pid = @runner.get_process(@name, :format => "pid=").stdout
not pid.empty?
end

Expand Down
4 changes: 0 additions & 4 deletions spec/type/aix/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, {:family => 'aix'}

describe commands.command_class('file').create do
it { should be_an_instance_of(Specinfra::Command::Aix::Base::File) }
end

describe file('/tmp') do
it { should be_readable.by_user('mail') }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/aix/group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'aix'

describe commands.command_class('group').create do
it { should be_an_instance_of(Specinfra::Command::Aix::Base::Group) }
end

describe group('root') do
it { should have_gid 0 }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/aix/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'aix'

describe commands.command_class('package').create do
it { should be_an_instance_of(Specinfra::Command::Aix::Base::Package) }
end

describe package('httpd') do
it { should be_installed }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/aix/port_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'aix'

describe commands.command_class('port').create do
it { should be_an_instance_of(Specinfra::Command::Aix::Base::Port) }
end

describe Serverspec::Type::Port do
describe port(80) do
it { should be_listening }
Expand Down
4 changes: 0 additions & 4 deletions spec/type/aix/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'aix'

describe commands.command_class('service').create do
it { should be_an_instance_of(Specinfra::Command::Aix::Base::Service) }
end

describe service('sshd') do
it { should be_enabled }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/aix/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'aix'

describe commands.command_class('user').create do
it { should be_an_instance_of(Specinfra::Command::Aix::Base::User) }
end

describe user('root') do
it { should belong_to_group 'root' }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/arch/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'arch'

describe commands.command_class('file').create do
it { should be_an_instance_of(Specinfra::Command::Arch::Base::File) }
end

describe file('/tmp') do
it { should be_readable.by_user('mail') }
end
Expand Down
6 changes: 2 additions & 4 deletions spec/type/arch/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

set :os, :family => 'arch'

describe commands.command_class('package').create do
it { should be_an_instance_of(Specinfra::Command::Arch::Base::Package) }
end

=begin
describe package('httpd') do
it { should be_installed }
end
Expand All @@ -21,6 +18,7 @@
describe package('httpd') do
it { should_not be_installed.with_version('invalid-version') }
end
=end

describe package('httpd') do
let(:stdout) { "2.2.15\n" }
Expand Down
4 changes: 0 additions & 4 deletions spec/type/arch/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'arch'

describe commands.command_class('service').create do
it { should be_an_instance_of(Specinfra::Command::Arch::Base::Service) }
end

describe service('sshd') do
it { should be_enabled }
it { should be_running }
Expand Down
4 changes: 0 additions & 4 deletions spec/type/base/cron_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'base'

describe commands.command_class('cron').create do
it { should be_an_instance_of(Specinfra::Command::Base::Cron) }
end

describe cron do
it { should have_entry '* * * * * /usr/local/bin/batch.sh' }
end
Expand Down
3 changes: 0 additions & 3 deletions spec/type/base/default_gateway_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

describe default_gateway do
let(:stdout) { "default via 192.168.1.1 dev eth1 \r\n" }

its(:ipaddress) { should eq '192.168.1.1' }

its(:interface) { should eq 'eth1' }

its(:ipaddress) { should_not eq '192.168.1.2' }
its(:interface) { should_not eq 'eth0' }
end
4 changes: 0 additions & 4 deletions spec/type/base/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, {:family => 'base'}

describe commands.command_class('file').create do
it { should be_an_instance_of(Specinfra::Command::Base::File) }
end

describe file('/etc/ssh/sshd_config') do
it { should be_file }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/base/group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'base'

describe commands.command_class('group').create do
it { should be_an_instance_of(Specinfra::Command::Base::Group) }
end

describe group('root') do
it { should exist }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/base/host_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'base'

describe commands.command_class('host').create do
it { should be_an_instance_of(Specinfra::Command::Base::Host) }
end

describe host('127.0.0.1') do
it { should be_resolvable }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/base/mail_alias_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'base'

describe commands.command_class('mail_alias').create do
it { should be_an_instance_of(Specinfra::Command::Base::MailAlias) }
end

describe mail_alias('daemon') do
it { should be_aliased_to "root" }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/base/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'base'

describe commands.command_class('package').create do
it { should be_an_instance_of(Specinfra::Command::Base::Package) }
end

describe package('jekyll') do
it { should be_installed.by('gem') }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/base/port_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'base'

describe commands.command_class('port').create do
it { should be_an_instance_of(Specinfra::Command::Base::Port) }
end

describe Serverspec::Type::Port do
describe port(80) do
it { should be_listening }
Expand Down
4 changes: 0 additions & 4 deletions spec/type/base/process_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'base'

describe commands.command_class('process').create do
it { should be_an_instance_of(Specinfra::Command::Base::Process) }
end

describe process("memcached") do
let(:stdout) { " 1407\n" }
its(:pid) { should eq 1407 }
Expand Down
4 changes: 0 additions & 4 deletions spec/type/base/routing_table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'base'

describe commands.command_class('routing_table').create do
it { should be_an_instance_of(Specinfra::Command::Base::RoutingTable) }
end

describe routing_table do
let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" }
it { should have_entry( :destination => '192.168.100.0/24' ) }
Expand Down
4 changes: 0 additions & 4 deletions spec/type/base/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'base'

describe commands.command_class('service').create do
it { should be_an_instance_of(Specinfra::Command::Base::Service) }
end

describe service('sshd') do
it { should be_running }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/base/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'base'

describe commands.command_class('user').create do
it { should be_an_instance_of(Specinfra::Command::Base::User) }
end

describe user('root') do
it { should exist }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/darwin/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'darwin'

describe commands.command_class('file').create do
it { should be_an_instance_of(Specinfra::Command::Darwin::Base::File) }
end

describe file('/tmp') do
it { should be_readable.by_user('mail') }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/darwin/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'darwin'

describe commands.command_class('package').create do
it { should be_an_instance_of(Specinfra::Command::Darwin::Base::Package) }
end

describe package('httpd') do
it { should be_installed }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/darwin/port_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'darwin'

describe commands.command_class('port').create do
it { should be_an_instance_of(Specinfra::Command::Darwin::Base::Port) }
end

describe Serverspec::Type::Port do
describe port(80) do
it { should be_listening }
Expand Down
4 changes: 0 additions & 4 deletions spec/type/darwin/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'darwin'

describe commands.command_class('service').create do
it { should be_an_instance_of(Specinfra::Command::Darwin::Base::Service) }
end

describe service('sshd') do
it { should be_enabled }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/debian/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'debian'

describe commands.command_class('package').create do
it { should be_an_instance_of(Specinfra::Command::Debian::Base::Package) }
end

describe package('httpd') do
it { should be_installed }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/debian/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'debian'

describe commands.command_class('service').create do
it { should be_an_instance_of(Specinfra::Command::Debian::Base::Service) }
end

describe service('sshd') do
it { should be_enabled }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/fedora/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'fedora'

describe commands.command_class('service').create do
it { should be_an_instance_of(Specinfra::Command::Fedora::Base::Service) }
end

describe service('sshd') do
it { should be_enabled }
end
Expand Down
4 changes: 0 additions & 4 deletions spec/type/fedora15/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set :os, :family => 'fedora', :release => 15

describe commands.command_class('service').create do
it { should be_an_instance_of(Specinfra::Command::Fedora::V15::Service) }
end

describe service('sshd') do
it { should be_enabled }
end
Expand Down
Loading

0 comments on commit 4b44b57

Please sign in to comment.