Created
August 21, 2014 19:10
-
-
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/.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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