Skip to content

Instantly share code, notes, and snippets.

@unakatsuo
Created August 21, 2014 19:10
Show Gist options
  • Save unakatsuo/fa676950ee9de2c8fd01 to your computer and use it in GitHub Desktop.
Save unakatsuo/fa676950ee9de2c8fd01 to your computer and use it in GitHub Desktop.
RSpec example which inlines Turnip's steps. Inspired by https://about.futurelearn.com/blog/how-we-write-readable-feature-tests-with-rspec/.
require 'spec_helper'
feature "Feature1" do
scenario "Scenario1" do
step "Do something 1"
step "Do something 2"
step "Do something 3"
step "Do something 4"
end
Step "Do something :number" do |number|
puts "hoge-: #{number}"
end
end
require 'rspec'
require 'turnip'
::RSpec::Core::ExampleGroup.define_example_group_method :feature
::RSpec::Core::ExampleGroup.define_example_method :scenario
module DSL
module ExampleGroupMethods
include Turnip::Define
alias_method :Step, :step
end
module ExampleMethods
include Turnip::Execute
end
end
::RSpec.configure do |config|
config.include Turnip::Steps, turnip: true
config.extend DSL::ExampleGroupMethods
config.include DSL::ExampleMethods
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment