Skip to content

Instantly share code, notes, and snippets.

@framallo
Created October 23, 2015 02:31
Show Gist options
  • Save framallo/64589a56ffbd6c22d02e to your computer and use it in GitHub Desktop.
Save framallo/64589a56ffbd6c22d02e to your computer and use it in GitHub Desktop.
class Image
def initialize(array)
@array = array
end
def output_image
@array.each { |a| puts a.join }
end
end
require 'rspec'
require 'pry'
require_relative 'image'
RSpec.describe Image do
it 'returns an image instance' do
expect(Image.new([])).to be_kind_of Image
end
let(:expected_output) { "0000\n0100\n0001\n0000\n" }
it 'outputs the image in console' do
array = [
[0, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 0, 1],
[0, 0, 0, 0]]
image = Image.new(array)
expect { image.output_image }.to output(expected_output).to_stdout
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment