Sha256: 737583623e7c6b36223d40839273cefda6288e39ed718d9185f8e336f53d5524
Contents?: true
Size: 1.73 KB
Versions: 2
Compression:
Stored size: 1.73 KB
Contents
require 'spec_helper' RSpec.describe SGF::Collection do let(:collection) { get_collection_from 'spec/data/ff4_ex.sgf' } subject { collection } it "has two games" do expect(subject.gametrees.size).to eq 2 end context 'on the gametree level' do subject { collection.root } it "should have two children" do expect(subject.children.size).to eq 2 end context 'in the first gametree' do subject { collection.root.children[0] } it "should have five children" do expect(subject.children.size).to eq 5 end end end context "inspect" do subject { collection.inspect } it { is_expected.to match(/SGF::Collection/) } it { is_expected.to match(/#{collection.object_id}/) } it { is_expected.to match(/2 Games/) } it { is_expected.to match(/62 Nodes/) } end it "should use preorder traversal for each" do collection = get_collection_from 'spec/data/example1.sgf' array = [] collection.each { |node| array << node } expect(array[0].c).to eq "root" expect(array[1].c).to eq "a" expect(array[2].c).to eq "b" end it "should properly compare two collections" do new_collection = get_collection_from 'spec/data/ff4_ex.sgf' expect(collection).to eq new_collection end context "gametrees" do it "always returns the same objects for the same gametrees" do expect(subject.gametrees).to eq subject.gametrees end it "knows if you've added a new gametree" do expect do subject << SGF::Gametree.new(SGF::Node.new) end.to change { subject.gametrees.count }.by(1) end end it "barfs if you try to add a non-gametree object" do expect do subject << Object.new end.to raise_error(ArgumentError) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
SgfParser-3.0.1 | spec/collection_spec.rb |
SgfParser-3.0.0 | spec/collection_spec.rb |