Skip to content

Commit

Permalink
Merge pull request #8 from ec-europa/full-table-assert
Browse files Browse the repository at this point in the history
Add a step to match a full table structure.
  • Loading branch information
idimopoulos authored Oct 8, 2018
2 parents 89b48b3 + c484a09 commit c178ebf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions features/tables.feature
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,12 @@ Feature: Inspecting HTML tables
| Engineering | Panteleimon Kita | moderator |
| Support | Victor Otto | moderator |
| Support | Melissa Kevorkian | moderator |
# Check that the full structure of the table on the page.
And the "User roles" table should be:
| Group | Username | Role |
| Engineering | Najib Randall | administrator |
| Support | Victor Otto | administrator |
| Engineering | Melor Vescovi | moderator |
| Support | Victor Otto | moderator |
| Engineering | Panteleimon Kita | moderator |
| Support | Melissa Kevorkian | moderator |
18 changes: 18 additions & 0 deletions src/Context/TableContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,24 @@ public function assertNoTableData(string $name, TableNode $data): void
}
}

/**
* Checks that the given table matches the given structure and data.
*
* @param string $name
* The human readable name for the table.
* @param \Behat\Gherkin\Node\TableNode $data
* The expected structure and data of the table.
*
* @Then the :name table should be:
*/
public function assertExactTableData(string $name, TableNode $data): void
{
$table = $this->getTable($name);
if ($table->getData() !== $data->getRows()) {
throw new \RuntimeException("The table $name doesn't match the expected data.");
}
}

/**
* Checks that the given table contains the given non-consecutive columns, identified by headers.
*
Expand Down

0 comments on commit c178ebf

Please sign in to comment.