Module: Gurke::DSL
- Defined in:
- lib/gurke/dsl.rb
Instance Method Summary collapse
- #_define_step(pattern, method_name, opts, &block) ⇒ Object
-
#Given(pattern, method_name = nil, opts = {}, &block) ⇒ Object
rubocop:disable MethodName.
- #step(pattern, method_name = nil, opts = {}, &block) ⇒ Object
- #Then(pattern, method_name = nil, opts = {}, &block) ⇒ Object
- #When(pattern, method_name = nil, opts = {}, &block) ⇒ Object
Instance Method Details
#_define_step(pattern, method_name, opts, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gurke/dsl.rb', line 17 def _define_step(pattern, method_name, opts, &block) step = StepDefinition.new(pattern, opts) define_method("match: #{step.method_name}") do |name, s = nil| step.match(name, s) end if block_given? define_method("#{step.method_name}", &block) elsif method_name alias_method "#{step.method_name}", method_name end end |
#Given(pattern, method_name = nil, opts = {}, &block) ⇒ Object
rubocop:disable MethodName
32 33 34 |
# File 'lib/gurke/dsl.rb', line 32 def Given(pattern, method_name = nil, opts = {}, &block) step pattern, method_name, opts.merge(type: :given), &block end |
#step(pattern, method_name = nil, opts = {}, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/gurke/dsl.rb', line 3 def step(pattern, method_name = nil, opts = {}, &block) if method_name.is_a?(Hash) && opts.empty? method_name, opts = nil, method_name end if method_name && block_given? raise ArgumentError.new <<-EOF.strip You can either specify a method name or given a block, not both. EOF end _define_step(pattern, method_name, opts, &block) end |
#Then(pattern, method_name = nil, opts = {}, &block) ⇒ Object
40 41 42 |
# File 'lib/gurke/dsl.rb', line 40 def Then(pattern, method_name = nil, opts = {}, &block) step pattern, method_name, opts.merge(type: :then), &block end |
#When(pattern, method_name = nil, opts = {}, &block) ⇒ Object
36 37 38 |
# File 'lib/gurke/dsl.rb', line 36 def When(pattern, method_name = nil, opts = {}, &block) step pattern, method_name, opts.merge(type: :when), &block end |