Skip to content

Commit

Permalink
Modify syntax of be_zfs
Browse files Browse the repository at this point in the history
be_zfs(value).property(property) is unnatural.

So I fixed it to

be_zfs.with({ property => value })
  • Loading branch information
mizzy committed Apr 8, 2013
1 parent 09e3227 commit 425349b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
9 changes: 5 additions & 4 deletions lib/serverspec/commands/solaris.rb
Expand Up @@ -22,11 +22,12 @@ def check_cron_entry user, entry
"crontab -l #{user} | grep '#{entry_escaped}'"
end

def check_zfs zfs, property=nil, value=nil
if (value || property).nil?
"/sbin/zfs list -H #{zfs} 2> /dev/null"
def check_zfs zfs, property=nil
if property.nil?
"/sbin/zfs list -H #{zfs}"
else
"/sbin/zfs get -H #{property} #{zfs} 2> /dev/null | grep #{value}"
key = property.keys[0]
"/sbin/zfs get -H #{key} #{zfs} | grep '#{property[key]}'"
end
end
end
Expand Down
7 changes: 3 additions & 4 deletions lib/serverspec/matchers/be_zfs.rb
@@ -1,10 +1,9 @@
RSpec::Matchers.define :be_zfs do |value|
RSpec::Matchers.define :be_zfs do
match do |zfs|
ret = do_check(commands.check_zfs(zfs, @property, value))
ret[:exit_code] == 0
backend.check_zfs(zfs, @property)
end

chain :property do |property|
chain :with do |property|
@property = property
end
end
2 changes: 1 addition & 1 deletion spec/solaris/commads_spec.rb
Expand Up @@ -90,6 +90,6 @@
it { should eq "/sbin/zfs list -H rpool" }
end

describe commands.check_zfs('rpool', 'mountpoint', '/rpool') do
describe commands.check_zfs('rpool', { 'mountpoint' => '/rpool' }) do
it { should eq "/sbin/zfs get -H mountpoint rpool | grep '/rpool'" }
end
3 changes: 1 addition & 2 deletions spec/solaris/matchers_spec.rb
Expand Up @@ -34,6 +34,5 @@

it_behaves_like 'support get_stdout matcher', 'whoami', 'root'
it_behaves_like 'support be_zfs matcher', 'rpool'
it_behaves_like 'support be_zfs.property matcher', 'rpool', 'mountpoint', '/rpool'

it_behaves_like 'support be_zfs.property matcher', 'rpool', { 'mountpoint' => '/rpool' }
end
6 changes: 3 additions & 3 deletions spec/support/shared_matcher_examples.rb
Expand Up @@ -318,14 +318,14 @@
end
end

shared_examples_for 'support be_zfs.property matcher' do |zfs, property, value|
shared_examples_for 'support be_zfs.property matcher' do |zfs, property|
describe 'be_zfs' do
describe zfs do
it { should be_zfs(value).property(property) }
it { should be_zfs.with(property) }
end

describe 'this-is-invalid-zfs' do
it { should_not be_zfs(value).property(property) }
it { should_not be_zfs.with(property) }
end
end
end

0 comments on commit 425349b

Please sign in to comment.