Sha256: d39d04758c3636d9c52c444c3f48186f76ca19613bc62bc8e664642aee422021
Contents?: true
Size: 1.75 KB
Versions: 4
Compression:
Stored size: 1.75 KB
Contents
require 'helper' require 'json' require 'pilfer/profile' describe Pilfer::Profile do let(:spec_root) { File.expand_path('..', File.dirname(__FILE__)) } let(:data) { profile_file = File.join(spec_root, 'files', 'profile.json') profile_content = File.read(profile_file).gsub('SPEC_ROOT', spec_root) JSON.parse(profile_content) } let(:start) { Time.at(42) } subject { Pilfer::Profile.new(data, start) } it 'should be an Enumerable' do subject.should be_kind_of(Enumerable) end describe '#start' do it 'returns the given start time' do subject.start.should eq(start) end end describe '#each' do it 'yields each file and data' do actual = {} subject.each do |file, data| actual[file] = data end expected = { "#{spec_root}/files/hello.rb" => { "wall_time" => 31, "cpu_time" => 18, "lines" => { 0 => { "wall_time" => 31, "cpu_time" => 18, "calls" => 2} } }, "#{spec_root}/files/test.rb" => { "wall_time" => 113692, "cpu_time" => 5313, "lines" => { 11 => { "wall_time" => 5062, "cpu_time" => 4890, "calls" => 3 }, 12 => { "wall_time" => 23, "cpu_time" => 14, "calls" => 4 }, 13 => { "wall_time" => 108607, "cpu_time" => 409, "calls" => 1 }, 14 => { "wall_time" => 108404, "cpu_time" => 310, "calls" => 10 } } } } actual.should eq(expected) end it 'yields each file alphabetically' do actual = [] subject.each do |file, data| actual << file end expected = %W(#{spec_root}/files/hello.rb #{spec_root}/files/test.rb) actual.should eq(expected) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
pilfer-1.0.2 | spec/pilfer/profile_spec.rb |
pilfer-1.0.1 | spec/pilfer/profile_spec.rb |
pilfer-1.0.0 | spec/pilfer/profile_spec.rb |
pilfer-0.0.1.pre4 | spec/pilfer/profile_spec.rb |