Skip to content

Commit 5ba13a2

Browse files
committed
Rationalize RSpec coverage
Trim duplicated comparison and serialization coverage from RSpec, keeping behavior checks focused and leaving API-level coverage to Test::Unit. Document the division in spec/README.md.
1 parent abf4236 commit 5ba13a2

2 files changed

Lines changed: 7 additions & 46 deletions

File tree

spec/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# RSpec Coverage Notes
2+
3+
RSpec examples in this repository focus on small, readable behavior checks
4+
such as initialization and cloning. API-level and regression coverage lives
5+
primarily in the Test::Unit suite under `test/`.

spec/tree_spec.rb

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
# tree_spec.rb
44
#
55
# Author: Anupam Sengupta
6-
# Time-stamp: <2022-06-22 13:52:50 anupam>
7-
# Copyright (C) 2015-2022 Anupam Sengupta <anupamsg@gmail.com>
6+
#
7+
# Copyright (C) 2015-2026 Anupam Sengupta <anupamsg@gmail.com>
88
#
99
# frozen_string_literal: true
1010

1111
require 'rspec'
1212
require 'spec_helper'
1313

14-
class SpecializedTreeNode < Tree::TreeNode; end
15-
1614
describe Tree do
1715

1816
describe '#initialize with empty name and nil content' do
@@ -58,48 +56,6 @@ class SpecializedTreeNode < Tree::TreeNode; end
5856
it_behaves_like 'detached node'
5957
end
6058

61-
describe 'comparison' do
62-
let(:node1) { Tree::TreeNode.new('a') }
63-
let(:node2) { SpecializedTreeNode.new('b') }
64-
65-
it 'allows comparison of specialized tree nodes' do
66-
expect(node1 <=> node2).to be_eql(-1)
67-
end
68-
69-
it 'does not allow comparison with nil' do
70-
expect(node1 <=> nil).to be_nil
71-
end
72-
73-
it 'does not allow comparison with other objects' do
74-
expect(node1 <=> 'c').to be_nil
75-
end
76-
end
77-
78-
describe 'serialization' do
79-
let(:serialized_node1) { Marshal.dump(SpecializedTreeNode.new('a')) }
80-
let(:serialized_node2) { Marshal.dump(Tree::TreeNode.new('b')) }
81-
let(:tree) do
82-
SpecializedTreeNode.new('root').tap do |root|
83-
root << SpecializedTreeNode.new('a')
84-
root << Tree::TreeNode.new('b')
85-
end
86-
end
87-
let(:serialized_tree) { Marshal.dump(tree) }
88-
89-
it 'parses the serialized specialized tree node correctly (root)' do
90-
expect(Marshal.load(serialized_tree)).to be_a(SpecializedTreeNode)
91-
end
92-
93-
it 'parses the serialized specialized tree node correctly (child)' do
94-
expect(Marshal.load(serialized_tree).children.first).to \
95-
be_a(SpecializedTreeNode)
96-
end
97-
98-
it 'parses the serialized tree node correctly' do
99-
expect(Marshal.load(serialized_node2)).to be_a(Tree::TreeNode)
100-
end
101-
end
102-
10359
describe '#detached_copy', 'Without content' do
10460
let(:tree) { Tree::TreeNode.new('A', nil) }
10561
let(:clone) { tree.detached_copy }

0 commit comments

Comments
 (0)