Skip to content

Instantly share code, notes, and snippets.

@optix2000
Last active July 18, 2017 02:54
Show Gist options
  • Save optix2000/4328ea9b4eb5b3b1e827a086a207b7e7 to your computer and use it in GitHub Desktop.
Save optix2000/4328ea9b4eb5b3b1e827a086a207b7e7 to your computer and use it in GitHub Desktop.
Hacky rspec-steps for smoke tests
require 'capybara'
require 'capybara/rspec'
require 'capybara/poltergeist'
require 'capybara-screenshot/rspec'
Capybara.configure do |c|
c.javascript_driver = :poltergeist
c.run_server = false
c.app_host = 'http://app.lvh.me:3000'
end
context 'Smoke Tests', type: :feature, js: true, order: :defined do
before :example do |current_example|
# Approximates rspec-steps by failing on previous failures
# NB!: Failures will not propogate across contexts.
# This funcationality can be added by checking current_example.example_group.children, and current_example.example_group.parent_groups
example_group = RSpec.world.filtered_examples[current_example.example_group]
bad_ex = example_group.find { |ex| !ex.exception.nil? }
if bad_ex
skip "Failure in #{bad_ex.to_s}: #{bad_ex.exception.to_s}: #{bad_ex.exception.message}"
end
end
it 'Can visit page' do
visit '/'
end
it 'Can do stuff' do
click_on 'Break test with nonexistant button'
expect(page).to have_current_path('done')
end
it 'Can do more stuff' do
visit '/'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment