Skip to content

First Story (Ruby)

Create a test file such as test/login_test.rb:

require "minitest/autorun"
require "executable_stories/minitest"
class LoginTest < Minitest::Test
def test_user_logs_in_successfully
story = ExecutableStories.init("user logs in successfully")
story.given("the user is on the login page")
password = "secret"
story.when("the user submits valid credentials")
result = email == "[email protected]" && password == "secret"
story.then("the user should see the dashboard")
assert_equal true, result
end
end

Create a spec file such as spec/login_spec.rb:

require "executable_stories/rspec"
ExecutableStories::RSpecPlugin.install!
RSpec.describe "Login" do
story "user logs in successfully" do |s|
s.given("the user is on the login page")
password = "secret"
s.when("the user submits valid credentials")
result = email == "[email protected]" && password == "secret"
s.expect("the user should see the dashboard") do
expect(result).to be(true)
end
end
end
Terminal window
bundle exec ruby -Ilib -Itest test/login_test.rb

Or run your specs:

Terminal window
bundle exec rspec

The raw run JSON can be rendered by executable-stories-formatters. A Markdown report for the examples above will include the scenario title and the Given/When/Then steps.

Ruby story & doc API — steps, docs, and options.

Other adapters — the rest of the repo’s non-JS adapters.