Sha256: 5cc65b22ca6ccaaa41bbaf18dfb5606a27f2d7ff57954f9d87e8f6e010e5ad7d

Contents?: true

Size: 772 Bytes

Versions: 3

Compression:

Stored size: 772 Bytes

Contents

# encoding: utf-8

Given(/^a packet data file "(.*?)"$/) do |name|
  path = File.expand_path(File.join(File.dirname(__FILE__),
                                    '..', 'packet_data', name))
  case File.extname(name)
  when '.raw'
    @raw = path
  when '.pcap'
    @pcap = path
  else
    fail "Unsupported file extension: #{name}"
  end
end

When(/^I try to parse the file with "(.*?)" class$/) do |parser|
  parser_klass = Pio.const_get(parser)
  if @raw
    parser_klass.read IO.read(@raw)
  elsif @pcap
    File.open(@pcap) do |file|
      pcap = Pio::Pcap::Frame.read(file)
      pcap.records.each { |each| parser_klass.read each.data }
    end
  else
    fail 'Packet data file is not specified.'
  end
end

Then(/^it should finish successfully$/) do
  # Noop.
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pio-0.8.1 features/step_definitions/packet_data_steps.rb
pio-0.8.0 features/step_definitions/packet_data_steps.rb
pio-0.7.0 features/step_definitions/packet_data_steps.rb