Sha256: 0861fb7b6e0e904afb739e719832c735873bd3f1f5c592c7dc64e8c5c90628ce

Contents?: true

Size: 623 Bytes

Versions: 9

Compression:

Stored size: 623 Bytes

Contents

RSpec::Matchers.define :contain do |expected_content|
  match do |file_path|
    @actual_contents = File.new(file_path).read
    case expected_content
      when String
        @actual_contents.include? expected_content
      when Regexp
        @actual_contents =~ expected_content
    end
  end
  
  failure_message_for_should do |file_path|
    "expected the file #{file_path} to contain #{expected_content.inspect} but it contained #{@actual_contents.inspect}"
  end
  
  failure_message_for_should_not do |file_path|
    "expected the file #{file_path} to not contain #{expected_content.inspect} but it did"
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ammeter-0.2.8 lib/ammeter/rspec/generator/matchers/contain.rb
ammeter-0.2.7 lib/ammeter/rspec/generator/matchers/contain.rb
ammeter-0.2.6 lib/ammeter/rspec/generator/matchers/contain.rb
ammeter-0.2.5 lib/ammeter/rspec/generator/matchers/contain.rb
ammeter-0.2.4 lib/ammeter/rspec/generator/matchers/contain.rb
ammeter-0.2.3 lib/ammeter/rspec/generator/matchers/contain.rb
ammeter-0.2.2 lib/ammeter/rspec/generator/matchers/contain.rb
ammeter-0.2.1 lib/ammeter/rspec/generator/matchers/contain.rb
ammeter-0.2.0 lib/ammeter/rspec/generator/matchers/contain.rb