Sha256: adb85942eaf07740bfa3403a345f964571412206ae7f7178f402a99d07a1b239
Contents?: true
Size: 1.49 KB
Versions: 3
Compression:
Stored size: 1.49 KB
Contents
# rubocop:disable LineLength Then(/^the number of packets sent from "(.*?)" should be:$/) do |host_name, table| command = "trema show_stats #{host_name}" step "I successfully run `#{command}`" result = {} in_current_dir do output_from(command).split("\n").each do |each| case each when /Packets sent/ next when /Packets recevied/ break when /-> (\S+) = (\d+) packet/ result[Regexp.last_match(1)] = Regexp.last_match(2).to_i else fail "Failed to parse line '#{each}'" end end end table.hashes.each do |each| ip_address = each.fetch('destination') expect(result.fetch(ip_address)).to eq(each.fetch('#packets').to_i) end end Then(/^the number of packets received by "(.*?)" should be:$/) do |host_name, table| command = "trema show_stats #{host_name}" step "I successfully run `#{command}`" result = Hash.new(0) in_current_dir do received = false output_from(command).split("\n").each do |each| case each when /Packets sent/ next when /Packets received/ received = true next when /(\S+) -> (\S+) = (\d+) packet/ next unless received result[Regexp.last_match(1)] = Regexp.last_match(3).to_i else fail "Failed to parse line '#{each}'" end end end table.hashes.each do |each| ip_address = each.fetch('source') expect(result[ip_address]).to eq(each.fetch('#packets').to_i) end end # rubocop:enable LineLength
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
trema-0.5.1 | features/step_definitions/show_stats_steps.rb |
trema-0.5.0 | features/step_definitions/show_stats_steps.rb |
trema-0.4.8 | features/step_definitions/show_stats_steps.rb |