require 'json' require 'korinthenkacker/test_case' module Korinthenkacker describe TestCase do let(:test_case_a) { TestCase.new(json_a, 1) } let(:test_case_b) { TestCase.new(json_b, 2) } describe '#==' do context 'with same name and same class name' do let(:json_a) { {'name' => 'name', 'className' => 'class_name'} } let(:json_b) { {'name' => 'name', 'className' => 'class_name'} } it 'is considered equal' do expect(test_case_a).to eql(test_case_b) end end context 'with same name but different class name' do let(:json_a) { {'name' => 'name', 'className' => 'class_name_a'} } let(:json_b) { {'name' => 'name', 'className' => 'class_name_b'} } it 'is NOT considered equal' do expect(test_case_a).to_not eql(test_case_b) end end context 'with different name but same class name' do let(:json_a) { {'name' => 'name_a', 'className' => 'class_name'} } let(:json_b) { {'name' => 'name_b', 'className' => 'class_name'} } it 'is NOT considered equal' do expect(test_case_a).to_not eql(test_case_b) end end context 'with different name and different class name' do let(:json_a) { {'name' => 'name_a', 'className' => 'class_name_a'} } let(:json_b) { {'name' => 'name_b', 'className' => 'class_name_b'} } it 'is NOT considered equal' do expect(test_case_a).to_not eql(test_case_b) end end end describe '#sibling?' do context 'when equal and same failed_since' do let(:json_a) { {'name' => 'name', 'className' => 'class_name', 'failedSince' => 42} } let(:json_b) { {'name' => 'name', 'className' => 'class_name', 'failedSince' => 42} } it 'returns false' do expect(test_case_a.sibling?(test_case_b)).to be_falsy end end context 'when equal but different failed_since' do let(:json_a) { {'name' => 'name', 'className' => 'class_name', 'failedSince' => 1} } let(:json_b) { {'name' => 'name', 'className' => 'class_name', 'failedSince' => 42} } it 'returns false' do expect(test_case_a.sibling?(test_case_b)).to be_truthy end end context 'when not equal and same failed_since' do let(:json_a) { {'name' => 'nameA', 'className' => 'class_nameA', 'failedSince' => 42} } let(:json_b) { {'name' => 'nameB', 'className' => 'class_nameB', 'failedSince' => 42} } it 'returns false' do expect(test_case_a.sibling?(test_case_b)).to be_falsy end end context 'when not equal and different failed_since' do let(:json_a) { {'name' => 'nameA', 'className' => 'class_nameA', 'failedSince' => 1} } let(:json_b) { {'name' => 'nameB', 'className' => 'class_nameB', 'failedSince' => 42} } it 'returns false' do expect(test_case_a.sibling?(test_case_b)).to be_falsy end end end end end