Class: Spec::Story::Step

Inherits:
Object show all
Defined in:
lib/gems/rspec-1.1.12/lib/spec/story/step.rb

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Step

Returns a new instance of Step.



9
10
11
12
13
# File 'lib/gems/rspec-1.1.12/lib/spec/story/step.rb', line 9

def initialize(name, &block)
  init_name(name)
  init_expression(name)
  block_given? ? init_module(name, &block) : set_pending
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/gems/rspec-1.1.12/lib/spec/story/step.rb', line 7

def name
  @name
end

Instance Method Details

#matches?(name) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/gems/rspec-1.1.12/lib/spec/story/step.rb', line 21

def matches?(name)
  !(name.strip =~ @expression).nil?
end

#parse_args(name) ⇒ Object



25
26
27
# File 'lib/gems/rspec-1.1.12/lib/spec/story/step.rb', line 25

def parse_args(name)
  name.strip.match(@expression)[1..-1]
end

#perform(instance, *args) ⇒ Object



15
16
17
18
19
# File 'lib/gems/rspec-1.1.12/lib/spec/story/step.rb', line 15

def perform(instance, *args)
  raise Spec::Example::ExamplePendingError.new("Not Yet Implemented") if pending?
  instance.extend(@mod)
  instance.__send__(sanitize(@name), *args)
end