dimanche 29 novembre 2015

How to test variable assignment in RSpec

def hide_gridlines(sheet, hide_gridlines)
  sheet.sheet_view.show_grid_lines = false if hide_gridlines
 end

I need to test this method in RSpec / Ruby, and I want to write two tests, one to see if this code sheet.sheet_view.show_grid_lines = false executes if hide_gridlines is true.

The other is to ensure that code sheet.sheet_view.show_grid_lines = false does not run if hide_gridlines is false.

sheet is a worksheet that comes from the Axlsx Gem, and I created a double, but I'm not sure how to setup the double to have a sheet_view, and then test the variable declaration.

Any pointers on how to test this in RSpec, your help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire