File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
lib/puppet/functions/apache Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 1717 # apache::bool2httpd(undef) # returns 'Off'
1818 #
1919 def bool2httpd ( arg )
20- return 'Off' if arg . nil? || arg == false || arg =~ %r{false}i || arg == :undef
21- return 'On' if arg == true || arg =~ %r{true}i
20+ return 'Off' if arg . nil? || arg == false || matches_string? ( arg , %r{false}i ) || arg == :undef
21+ return 'On' if arg == true || matches_string? ( arg , %r{true}i )
2222 arg . to_s
2323 end
24+
25+ private
26+
27+ def matches_string? ( value , matcher )
28+ value . is_a? ( String ) && value . match? ( matcher )
29+ end
2430end
Original file line number Diff line number Diff line change 55 it { is_expected . to run . with_params . and_raise_error ( ArgumentError ) }
66 it { is_expected . to run . with_params ( '1' , '2' ) . and_raise_error ( ArgumentError ) }
77 it { is_expected . to run . with_params ( true ) . and_return ( 'On' ) }
8+ it { is_expected . to run . with_params ( 'true' ) . and_return ( 'On' ) }
89 it 'expected to return a string "On"' do
910 expect ( subject . execute ( true ) ) . to be_an_instance_of ( String )
1011 end
1112 it { is_expected . to run . with_params ( false ) . and_return ( 'Off' ) }
13+ it { is_expected . to run . with_params ( 'false' ) . and_return ( 'Off' ) }
1214 it 'expected to return a string "Off"' do
1315 expect ( subject . execute ( false ) ) . to be_an_instance_of ( String )
1416 end
You can’t perform that action at this time.
0 commit comments