Skip to content

Instantly share code, notes, and snippets.

@andrewhavens
Last active December 22, 2015 00:58
Show Gist options
  • Save andrewhavens/6393018 to your computer and use it in GitHub Desktop.
Save andrewhavens/6393018 to your computer and use it in GitHub Desktop.
Example of Capybara feature file, declarative style
feature "widget management" do
include AuthenticationSteps
include WidgetSteps
background do
i_log_in_as_a_user
end
scenario "creating a new widget" do
i_create_a_widget
expect(page).to have_text("Widget was successfully created.")
end
end
module AuthenticationSteps
def i_log_in_as_a_user
@user = Fabricate(:user)
visit auth_login_path
fill_in "Username", with: @user.username
fill_in "Password", with: "password"
click_button "Log In"
end
end
module WidgetSteps
def i_create_a_widget
visit root_url
click_link "New Widget"
fill_in "Name", with: "Awesome Widget"
click_button "Create Widget"
end
end
@andrewhavens
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment