Sha256: 5edc772b1cb01dbaf7340df27a4e94bca5b449b621ec4758a47c68cb8bbe91e6

Contents?: true

Size: 702 Bytes

Versions: 11

Compression:

Stored size: 702 Bytes

Contents

RSpec::Matchers.define :contain do |pattern|
  match do |file|
    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.do_check(cmd)
    ret[:exit_code] == 0
  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

11 entries across 11 versions & 1 rubygems

Version Path
serverspec-0.2.11 lib/serverspec/matchers/contain.rb
serverspec-0.2.10 lib/serverspec/matchers/contain.rb
serverspec-0.2.9 lib/serverspec/matchers/contain.rb
serverspec-0.2.8 lib/serverspec/matchers/contain.rb
serverspec-0.2.7 lib/serverspec/matchers/contain.rb
serverspec-0.2.6 lib/serverspec/matchers/contain.rb
serverspec-0.2.5 lib/serverspec/matchers/contain.rb
serverspec-0.2.4 lib/serverspec/matchers/contain.rb
serverspec-0.2.3 lib/serverspec/matchers/contain.rb
serverspec-0.2.2 lib/serverspec/matchers/contain.rb
serverspec-0.2.1 lib/serverspec/matchers/contain.rb