diff options
| author | a14m <[email protected]> | 2020-12-02 14:33:50 +0100 |
|---|---|---|
| committer | a14m <[email protected]> | 2020-12-02 14:36:20 +0100 |
| commit | beef1220ecae3d4b3faec49059b131488bc8d016 (patch) | |
| tree | ad323efd0a4020a21df10a442865a3042f247c98 /CLI/ruby/spec/game_of_life | |
| parent | c3bb6ec97716f2084958bafdc9a3a1aa67c438d4 (diff) | |
Move the plane into the lexically correct spec folder
Diffstat (limited to 'CLI/ruby/spec/game_of_life')
| -rw-r--r-- | CLI/ruby/spec/game_of_life/plane_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/CLI/ruby/spec/game_of_life/plane_spec.rb b/CLI/ruby/spec/game_of_life/plane_spec.rb new file mode 100644 index 0000000..c4efbb4 --- /dev/null +++ b/CLI/ruby/spec/game_of_life/plane_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +RSpec.describe GameOfLife::Plane do + describe "#[]" do + context "when empty" do + subject { described_class.new } + + it "returns nil with [-1]" do + expect(subject[-1]).to be_nil + end + + it "returns nil with [0]" do + expect(subject[0]).to be_nil + end + + it "returns nil with [1]" do + expect(subject[1]).to be_nil + end + end + + context "when not empty" do + subject { described_class.new([0, 1, 2, 3]) } + + it "returns value at index" do + expect(subject[0]).to eq 0 + end + + it "returns value at -index (negative indices count backward from the end of the array)" do + expect(subject[-5]).to eq 3 + expect(subject[-1]).to eq 3 + end + + it "returns value at any index (indices bigger than size cycle again from the beginning)" do + expect(subject[5]).to eq 1 + expect(subject[9]).to eq 1 + end + end + end +end |
