Skip to content

Commit c8a4285

Browse files
committed
Small from_hash spec to showcase creating from multi key hash works
1 parent 9ed35de commit c8a4285

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

spec/result_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,36 @@
205205
end
206206
end
207207
end
208+
209+
describe ".from_hash" do
210+
let(:other_result) do
211+
{
212+
source_fixture("sample.rb") => {"lines" => [nil, 1, 1, 1, nil, nil, 0, 0, nil, nil]}
213+
}
214+
end
215+
let(:created_at) { Time.now.to_i }
216+
217+
it "can consume multiple commands" do
218+
input = {
219+
"rspec" => {
220+
"coverage" => original_result,
221+
"timestamp" => created_at
222+
},
223+
"cucumber" => {
224+
"coverage" => other_result,
225+
"timestamp" => created_at
226+
}
227+
}
228+
229+
result = described_class.from_hash(input)
230+
231+
expect(result.size).to eq 2
232+
sorted = result.sort_by(&:command_name)
233+
expect(sorted.map(&:command_name)).to eq %w[cucumber rspec]
234+
expect(sorted.map(&:created_at).map(&:to_i)).to eq [created_at, created_at]
235+
expect(sorted.map(&:original_result)).to eq [other_result, original_result]
236+
end
237+
end
208238
end
209239

210240
context "with outdated result format" do

0 commit comments

Comments
 (0)