Sha256: 1eea8ca335380456eb1deef51dddcb470e35ab1a08a3b09101ae78a34944c046

Contents?: true

Size: 707 Bytes

Versions: 13

Compression:

Stored size: 707 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.run_command(cmd)
    ret[:exit_status] == 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

13 entries across 13 versions & 1 rubygems

Version Path
serverspec-0.4.0 lib/serverspec/matchers/contain.rb
serverspec-0.3.2 lib/serverspec/matchers/contain.rb
serverspec-0.3.1 lib/serverspec/matchers/contain.rb
serverspec-0.3.0 lib/serverspec/matchers/contain.rb
serverspec-0.2.28 lib/serverspec/matchers/contain.rb
serverspec-0.2.27 lib/serverspec/matchers/contain.rb
serverspec-0.2.26 lib/serverspec/matchers/contain.rb
serverspec-0.2.25 lib/serverspec/matchers/contain.rb
serverspec-0.2.24 lib/serverspec/matchers/contain.rb
serverspec-0.2.23 lib/serverspec/matchers/contain.rb
serverspec-0.2.22 lib/serverspec/matchers/contain.rb
serverspec-0.2.21 lib/serverspec/matchers/contain.rb
serverspec-0.2.20 lib/serverspec/matchers/contain.rb