Sha256: 41f4acf1faac47543205a07c880686327ad4ea6ab072fed953e7f4ff40e42a92

Contents?: true

Size: 812 Bytes

Versions: 23

Compression:

Stored size: 812 Bytes

Contents

RSpec::Matchers.define :contain do |pattern|
  match do |file|
    if file.respond_to?(:contain)
      file.contain(pattern, @from, @to)
    else
      if (@from || @to).nil?
        cmd = backend.commands.check_file_contain(file, pattern)
      else
        cmd = backend.commands.check_file_contain_within(file, pattern, @from, @to)
      end
      ret = backend.run_command(cmd)
      ret[:exit_status] == 0
    end
  end
  # for contain(pattern).from(/A/).to(/B/)
  chain :from do |from|
    @from = Regexp.new(from).inspect
  end
  chain :to do |to|
    @to = Regexp.new(to).inspect
  end
  # for contain(pattern).after(/A/)
  chain :after do |after|
    @from = Regexp.new(after).inspect
  end
  # for contain(pattern).before(/B/)
  chain :before do |before|
    @to = Regexp.new(before).inspect
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
serverspec-0.5.8 lib/serverspec/matchers/contain.rb
serverspec-0.5.7 lib/serverspec/matchers/contain.rb
serverspec-0.5.6 lib/serverspec/matchers/contain.rb
serverspec-0.5.5 lib/serverspec/matchers/contain.rb
serverspec-0.5.4 lib/serverspec/matchers/contain.rb
serverspec-0.5.3 lib/serverspec/matchers/contain.rb
serverspec-0.5.2 lib/serverspec/matchers/contain.rb
serverspec-0.5.1 lib/serverspec/matchers/contain.rb
serverspec-0.5.0 lib/serverspec/matchers/contain.rb
serverspec-0.4.14 lib/serverspec/matchers/contain.rb
serverspec-0.4.13 lib/serverspec/matchers/contain.rb
serverspec-0.4.12 lib/serverspec/matchers/contain.rb
serverspec-0.4.11 lib/serverspec/matchers/contain.rb
serverspec-0.4.10 lib/serverspec/matchers/contain.rb
serverspec-0.4.9 lib/serverspec/matchers/contain.rb
serverspec-0.4.8 lib/serverspec/matchers/contain.rb
serverspec-0.4.7 lib/serverspec/matchers/contain.rb
serverspec-0.4.6 lib/serverspec/matchers/contain.rb
serverspec-0.4.5 lib/serverspec/matchers/contain.rb
serverspec-0.4.4 lib/serverspec/matchers/contain.rb