Module: StonesSpec::WithGbbHtmlRendering

Included in:
Postcondition::ExpectedBoom, Postcondition::ExpectedResult
Defined in:
lib/renderers/with_gbb_html_rendering.rb

Instance Method Summary collapse

Instance Method Details

#get_html_board(caption, gbb_representation) ⇒ Object



3
4
5
# File 'lib/renderers/with_gbb_html_rendering.rb', line 3

def get_html_board(caption, gbb_representation)
  HtmlBoardRenderer.new(caption: caption).render(Stones::GbbReader.new.from_string gbb_representation)
end

#make_boards_output(title, gbb_boards, status, extra = nil) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/renderers/with_gbb_html_rendering.rb', line 11

def make_boards_output(title, gbb_boards, status, extra = nil)
  boards = gbb_boards.map { |gbb_with_caption| get_html_board *gbb_with_caption }.join("\n")
  output = "<div>#{boards}</div>"

  output = "<p>#{extra}</p>\n#{output}" if extra

  [title, status, output]
end

#make_error_output(result, initial_board_gbb) ⇒ Object



7
8
9
# File 'lib/renderers/with_gbb_html_rendering.rb', line 7

def make_error_output(result, initial_board_gbb)
  "#{get_html_board 'Tablero inicial', initial_board_gbb}\n#{get_boom_board initial_board_gbb}\n#{result}"
end