Skip to content

Commit

Permalink
Merge pull request #548 from RageZBla/feature/php_ini
Browse files Browse the repository at this point in the history
Add php_ini type and have_config matcher.
  • Loading branch information
mizzy committed Dec 24, 2015
2 parents 4372fc8 + 53f7e00 commit 3c22bc9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/serverspec/type/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ class Base

attr_reader :name

def initialize(name=nil)
@name = name
@runner = Specinfra::Runner
def initialize(name=nil, options = {})
@name = name
@options = options
@runner = Specinfra::Runner
end

def to_s
Expand Down
4 changes: 3 additions & 1 deletion lib/serverspec/type/php_config.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module Serverspec::Type
class PhpConfig < Base
def value
ret = @runner.run_command("php -r 'echo get_cfg_var( \"#{@name}\" );'")
extra = '';
extra = extra + "-c #{@options[:ini]}" if @options.has_key?(:ini)
ret = @runner.run_command("php #{extra} -r 'echo get_cfg_var( \"#{@name}\" );'")
val = ret.stdout
val = val.to_i if val.match(/^\d+$/)
val
Expand Down
4 changes: 4 additions & 0 deletions spec/type/base/php_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@
let(:stdout) { 'application' }
its(:value) { should_not match /html/ }
end
describe php_config('default_mimetype', :ini => '/etc/php5/php.ini') do
let(:stdout) { 'text/html' }
its(:value) { should eq 'text/html' }
end

0 comments on commit 3c22bc9

Please sign in to comment.