Class | Spec::Story::Step
In: | lib/spec/story/step.rb
Parent: | Object

### Methods

init_module matches? new parse_args perform sanitize

### Constants

PARAM_PATTERN | = | /([^\\]|^)(\$(?!\$)\w*)/
PARAM_OR_GROUP_PATTERN | = | /(\$(?!\$)\w*)|\(.*?\)/

### Attributes

name | [R] |

### Public Class methods

new(name, &block)

[Source]

        # File lib/spec/story/step.rb, line 8
     8:       def initialize(name, &block)
     9:         @name = name
    10:         assign_expression(name)
    11:         init_module(name, &block)
    12:       end

### Public Instance methods

init_module(name, &block)

[Source]

        # File lib/spec/story/step.rb, line 19
    19:       def init_module(name, &block)
    20:         sanitized_name = sanitize(name)
    21:         @mod = Module.new do
    22:           define_method(sanitized_name, &block)
    23:         end
    24:       end

matches?(name)

[Source]

        # File lib/spec/story/step.rb, line 32
    32:       def matches?(name)
    33:         !(matches = name.match(@expression)).nil?
    34:       end

parse_args(name)

[Source]

        # File lib/spec/story/step.rb, line 36
    36:       def parse_args(name)
    37:         name.match(@expression)[1..-1]
    38:       end

perform(instance, *args)

[Source]

        # File lib/spec/story/step.rb, line 14
    14:       def perform(instance, *args)
    15:         instance.extend(@mod)
    16:         instance.__send__(sanitize(@name), *args)
    17:       end

sanitize(a_string_or_regexp)

[Source]

        # File lib/spec/story/step.rb, line 26
    26:       def sanitize(a_string_or_regexp)
    27:         return a_string_or_regexp.source if Regexp == a_string_or_regexp
    28:         a_string_or_regexp.to_s
    29:       end

[Validate]