Created
October 23, 2015 02:31
-
-
Save framallo/64589a56ffbd6c22d02e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Image | |
def initialize(array) | |
@array = array | |
end | |
def output_image | |
@array.each { |a| puts a.join } | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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