Sha256: b015b7c34f726e03ef57e43c722804eebabcef70fc5b0d7738caa844c2952ca8

Contents?: true

Size: 1.07 KB

Versions: 7

Compression:

Stored size: 1.07 KB

Contents

describe Vnstat::Result::Hour do
  it 'includes Comparable' do
    expect(described_class).to include Comparable
  end

  describe '.extract_from_xml_element' do
    let :element do
      data = <<-XML
        <hour id="19">
          <date><year>2015</year><month>10</month><day>21</day></date>
          <rx>1000</rx><tx>2000</tx>
        </hour>
      XML
      Nokogiri::XML.parse(data).xpath('hour')
    end

    subject do
      described_class.extract_from_xml_element(element)
    end

    it { is_expected.to be_a described_class }

    it 'initializes with the correct #date' do
      expect(subject.date).to eq Date.new(2015, 10, 21)
    end

    it 'initializes with the correct #hour' do
      expect(subject.hour).to eq 19
    end

    it 'initializes with the correct #bytes_received' do
      expect(subject.bytes_received).to eq 1000 * 1024
    end

    it 'initializes with the correct #bytes_sent' do
      expect(subject.bytes_sent).to eq 2000 * 1024
    end
  end

  include_examples 'date delegation' do
    subject { described_class.new(Date.today, 12, 0, 0) }
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vnstat-ruby-1.1.0 spec/lib/vnstat/result/hour_spec.rb
vnstat-ruby-1.0.5 spec/lib/vnstat/result/hour_spec.rb
vnstat-ruby-1.0.4 spec/lib/vnstat/result/hour_spec.rb
vnstat-ruby-1.0.3 spec/lib/vnstat/result/hour_spec.rb
vnstat-ruby-1.0.2 spec/lib/vnstat/result/hour_spec.rb
vnstat-ruby-1.0.1 spec/lib/vnstat/result/hour_spec.rb
vnstat-ruby-1.0.0 spec/lib/vnstat/result/hour_spec.rb