spec/spec_helper.rb
# the mash variable may be an array listing multiple levels of Mash hierarchy
the mash variable may be an array listing multiple levels of Mash hierarchy
the mash variable may be an array listing multiple levels of Mash hierarchy
def it_should_check_from_deep_mash(plugin, mash, attribute, from, value)
  it "should get the #{mash.inspect}[:#{attribute}] value from '#{from}'" do
    expect(@plugin).to receive(:shell_out).with(from).and_return(mock_shell_out(value[0], value[1], value[2]))
    @plugin.run
  end
  it "should set the #{mash.inspect}[:#{attribute}] to the value from '#{from}'" do
    @plugin.run
    value = value[1].split($/)[0]
    if mash.is_a?(String)
      expect(@plugin[mash][attribute]).to eq(value)
    elsif mash.is_a?(Array)
      if mash.length == 2
        expect(@plugin[mash[0]][mash[1]][attribute]).to eq value
      elsif mash.length == 3
        expect(@plugin[mash[0]][mash[1]][mash[2]][attribute]).to eq value
      else
        return nil
      end
    else
      return nil
    end
  end
end
def it_should_check_from_deep_mash ( plugin , mash , attribute , from , value ) it "should get the #{mash.inspect}[:#{attribute}] value from '#{from}'" do expect ( @plugin ) . to receive ( :shell_out ) . with ( from ) . and_return ( mock_shell_out ( value [ 0 ] , value [ 1 ] , value [ 2 ] ) ) @plugin . run end it "should set the #{mash.inspect}[:#{attribute}] to the value from '#{from}'" do @plugin . run value = value [ 1 ] . split ( $/ ) [ 0 ] if mash . is_a? ( String ) expect ( @plugin [ mash ] [ attribute ] ) . to eq ( value ) elsif mash . is_a? ( Array ) if mash . length == 2 expect ( @plugin [ mash [ 0 ] ] [ mash [ 1 ] ] [ attribute ] ) . to eq value elsif mash . length == 3 expect ( @plugin [ mash [ 0 ] ] [ mash [ 1 ] ] [ mash [ 2 ] ] [ attribute ] ) . to eq value else return nil end else return nil end end end
the mash variable may be an array listing multiple levels of Mash hierarchy
the mash variable may be an array listing multiple levels of Mash hierarchy
plugin
<not_specific>
mash
<not_specific>
attribute
<not_specific>
from
<not_specific>
value
<not_specific>