Skip to content

Commit

Permalink
0.0.2 - minor bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Mar 14, 2015
1 parent 2c26fbe commit a392975
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
## 0.0.1 2015-03-14 Jason Antman <jason@jasonantman.com>

* Initial release with bitlbee, http_get and virtualenv types

## 0.0.2 2015-03-14 Jason Antman <jason@jasonantman.com>

* Minor bugfix in Serverspec::Types::Virtualenv#virtualenv?
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ Test whether this appears to be a working venv

Tests performed:

* venv_path/bin/pip executable by root?
* venv_path/bin/python executable by root?
* venv_path/bin/activate executable by root?
* venv_path/bin/pip executable by owner?
* venv_path/bin/python executable by owner?
* venv_path/bin/activate readable by owner?
* 'export VIRTUAL_ENV' in venv_path/bin/activate?

## Contributing
Expand Down
2 changes: 1 addition & 1 deletion lib/serverspec_extended_types/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ServerspecExtendedTypes
VERSION = "0.0.1"
VERSION = "0.0.2"
end
12 changes: 6 additions & 6 deletions lib/serverspec_extended_types/virtualenv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class Virtualenv < Base
# Test whether this appears to be a working venv
#
# Tests performed:
# - venv_path/bin/pip executable by root?
# - venv_path/bin/python executable by root?
# - venv_path/bin/activate executable by root?
# - venv_path/bin/pip executable by owner?
# - venv_path/bin/python executable by owner?
# - venv_path/bin/activate readable by owner?
# - 'export VIRTUAL_ENV' in venv_path/bin/activate?
#
# @example
Expand All @@ -32,9 +32,9 @@ def virtualenv?
python_path = ::File.join(@name, 'bin', 'python')
act_path = ::File.join(@name, 'bin', 'activate')
cmd = "grep -q 'export VIRTUAL_ENV' #{act_path}"
@runner.check_file_is_executable(pip_path, 'root') and
@runner.check_file_is_executable(python_path, 'root') and
@runner.check_file_is_executable(act_path, 'root') and
@runner.check_file_is_executable(pip_path, 'owner') and
@runner.check_file_is_executable(python_path, 'owner') and
@runner.check_file_is_readable(act_path, 'owner') and
@runner.run_command(cmd).exit_status.to_i == 0
end

Expand Down
2 changes: 1 addition & 1 deletion spec/types/http_get_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
stub_const('ENV', ENV.to_hash.merge('TARGET_HOST' => 'myhost'))
conn = double
headers = double
expect(headers).to receive(:[]=).with(:user_agent, 'Serverspec::Type::Http_Get/0.0.1 (https://github.com/jantman/serverspec-extended-types)')
expect(headers).to receive(:[]=).with(:user_agent, %r"Serverspec::Type::Http_Get/\d+\.\d+\.\d+ \(https://github.com/jantman/serverspec-extended-types\)")
expect(conn).to receive(:headers).and_return(headers)
expect(headers).to receive(:[]=).with(:Host, 'hostheader')
expect(conn).to receive(:headers).and_return(headers)
Expand Down
24 changes: 12 additions & 12 deletions spec/types/virtualenv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,36 @@
context '#virtualenv?' do
it 'checks all files' do
v = virtualenv('/foo/bar')
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/pip', 'root').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/python', 'root').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/activate', 'root').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/pip', 'owner').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/python', 'owner').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_readable).once.ordered.with('/foo/bar/bin/activate', 'owner').and_return(true)
res = Specinfra::CommandResult.new({:stdout => '', :stderr => '', :exit_signal => nil, :exit_status => 0 })
expect(v.instance_variable_get(:@runner)).to receive(:run_command).once.ordered.with("grep -q 'export VIRTUAL_ENV' /foo/bar/bin/activate").and_return(res)
expect(v.virtualenv?).to eq true
end
it 'returns false with missing pip' do
v = virtualenv('/foo/bar')
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/pip', 'root').and_return(false)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/pip', 'owner').and_return(false)
expect(v.virtualenv?).to eq false
end
it 'returns false with missing python' do
v = virtualenv('/foo/bar')
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/pip', 'root').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/python', 'root').and_return(false)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/pip', 'owner').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/python', 'owner').and_return(false)
expect(v.virtualenv?).to eq false
end
it 'returns false with missing activate' do
v = virtualenv('/foo/bar')
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/pip', 'root').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/python', 'root').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/activate', 'root').and_return(false)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/pip', 'owner').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/python', 'owner').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_readable).once.ordered.with('/foo/bar/bin/activate', 'owner').and_return(false)
expect(v.virtualenv?).to eq false
end
it 'returns false with invalid activate' do
v = virtualenv('/foo/bar')
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/pip', 'root').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/python', 'root').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/activate', 'root').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/pip', 'owner').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_executable).once.ordered.with('/foo/bar/bin/python', 'owner').and_return(true)
expect(v.instance_variable_get(:@runner)).to receive(:check_file_is_readable).once.ordered.with('/foo/bar/bin/activate', 'owner').and_return(true)
res = Specinfra::CommandResult.new({:stdout => '', :stderr => '', :exit_signal => nil, :exit_status => 254 })
expect(v.instance_variable_get(:@runner)).to receive(:run_command).once.ordered.with("grep -q 'export VIRTUAL_ENV' /foo/bar/bin/activate").and_return(res)
expect(v.virtualenv?).to eq false
Expand Down

0 comments on commit a392975

Please sign in to comment.