Skip to content

Commit

Permalink
Add to_grid and sections specs
Browse files Browse the repository at this point in the history
  • Loading branch information
pacso committed Dec 5, 2024
1 parent 03b3f10 commit adb8770
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions spec/lib/aoc_rb_helpers/aoc_input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
345 678
EOF
end
let(:grid_input) do
<<~EOF
abcde
fghij
klmno
pqrst
uvwxy
EOF
end

describe '#multiple_lines' do
subject(:method_chain) { described_class.new(multiline_input).multiple_lines }
Expand Down Expand Up @@ -71,6 +80,33 @@
end
end

describe "#to_grid" do
it "returns an instance of Grid" do
expect(described_class.new(grid_input).to_grid).to be_a Grid
end
end

describe "sections" do
let(:input_with_2_sections) do
<<~EOF
23|45
34|38
83|21
4,3,1,8
EOF
end

it "returns two AocInput instances when provided an input with 2 sections" do
sections = described_class.new(input_with_2_sections).sections
expect(sections).to be_an Array
expect(sections.length).to eq 2
sections.each do |section|
expect(section).to be_an AocInput
end
end
end

it "is important which order you call the methods in" do
expect(described_class.new(multiline_numbers).multiple_lines.columns_of_numbers.transpose.sort_arrays.data).to eq [[123, 345, 789], [12, 456, 678]]
expect(described_class.new(multiline_numbers).multiple_lines.columns_of_numbers.sort_arrays.transpose.data).to eq [[123, 12, 345], [456, 789, 678]]
Expand Down

0 comments on commit adb8770

Please sign in to comment.