Itâ€™s perfectly possible to write automated acceptance tests without using Cucumber. You can just write them in pure Ruby. Take this test for withdrawing cash from an ATM:
Scenario: Attempt withdrawal using stolen card
Given I have $100 in my account
But my card is invalid
When I request $50
Then my card should not be returned
And I should be told to contact the bank
We could automate that test using good old Test::Unit, perhaps something like this:
class WithdrawlTests < Test::Unit::TestCase
bank = Bank.new
account = Account.new(bank)
card = DebitCard.new(account)
atm = Atm.new(bank)
assert atm.card_withheld?, "Expected the card to be withheld by the ATM"
assert_equal "Please contact the bank.", atm.message_on_screen
The big disadvantage of writing acceptance tests in pure Ruby like this is that itâ€™s unlikely youâ€™ll be able to show this test to your team’s analyst without their eyes glazing over.
Unless your analyst is, or has recently been, a programmer themselves, they wonâ€™t be able to see past the noise of Rubyâ€™s syntax, clean as it may be, to understand the actual behaviour thatâ€™s being specified. The specification of behaviour and the implementation of the test are all mixed up together, and thatâ€™s a problem if we want to get feedback from our stakeholders about whether weâ€™ve specified the right thing before we go ahead and build it.
If we want the benefits of using plain language to write our behaviour specification, then we need a way to translate that into automation code that actually pulls and pokes at our application. Step definitions give you a translation layer between the plain-language specification of behviour and the test automation code, mapping the Gherkin steps of each scenario to Ruby code that Cucumber can execute.
The cost of this extra layer is complexity: Yes, you have more test code to maintain than you would if you stuck to writing your tests in pure Ruby. The benefit is clarity: by separating the what (the features) from the how (the ruby automation code), you keep each part simpler and easier for its target audience to understand.