Parent

Class/Module Index [+]

Quicksearch

Cucumber::RbSupport::RbLanguage

The Ruby implementation of the programming language API.

Attributes

current_world[R]

Public Class Methods

new(step_mother) click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 39
def initialize(step_mother)
  @step_mother = step_mother
  @step_definitions = []
  RbDsl.rb_language = self
  @world_proc = @world_modules = nil
end

Public Instance Methods

begin_rb_scenario(scenario) click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 89
def begin_rb_scenario(scenario)
  create_world
  extend_world
  connect_world(scenario)
end
build_rb_world_factory(world_modules, proc) click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 109
def build_rb_world_factory(world_modules, proc)
  if(proc)
    raise MultipleWorld.new(@world_proc, proc) if @world_proc
    @world_proc = proc
  end
  @world_modules ||= []
  @world_modules += world_modules
end
load_code_file(code_file) click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 118
def load_code_file(code_file)
  require File.expand_path(code_file) # This will cause self.add_step_definition, self.add_hook, and self.add_transform to be called from RbDsl
end
register_rb_hook(phase, tag_expressions, proc) click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 95
def register_rb_hook(phase, tag_expressions, proc)
  add_hook(phase, RbHook.new(self, tag_expressions, proc))
end
register_rb_step_definition(regexp, proc) click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 103
def register_rb_step_definition(regexp, proc)
  step_definition = RbStepDefinition.new(self, regexp, proc)
  @step_definitions << step_definition
  step_definition
end
register_rb_transform(regexp, proc) click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 99
def register_rb_transform(regexp, proc)
  add_transform(RbTransform.new(self, regexp, proc))
end
snippet_text(step_keyword, step_name, multiline_arg_class) click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 70
def snippet_text(step_keyword, step_name, multiline_arg_class)
  escaped = Regexp.escape(step_name).gsub('\ ', ' ').gsub('/', '\/')
  escaped = escaped.gsub(PARAM_PATTERN, ESCAPED_PARAM_PATTERN)

  n = 0
  block_args = escaped.scan(ESCAPED_PARAM_PATTERN).map do |a|
    n += 1
    "arg#{n}"
  end
  block_args << multiline_arg_class.default_arg_name unless multiline_arg_class.nil?
  block_arg_string = block_args.empty? ? "" : " |#{block_args.join(", ")}|"
  multiline_class_comment = ""
  if(multiline_arg_class == Ast::Table)
    multiline_class_comment = "# #{multiline_arg_class.default_arg_name} is a #{multiline_arg_class.to_s}\n  "
  end

  "#{Gherkin::I18n.code_keyword_for(step_keyword)} /^#{escaped}$/ do#{block_arg_string}\n  #{multiline_class_comment}pending # express the regexp above with the code you wish you had\nend"
end
step_definitions_for(rb_file) click to toggle source

Gets called for each file under features (or whatever is overridden with –require).

# File lib/cucumber/rb_support/rb_language.rb, line 48
def step_definitions_for(rb_file)
  begin
    require rb_file # This will cause self.add_step_definition and self.add_hook to be called from RbDsl
    step_definitions
  rescue LoadError => e
    e.message << "\nFailed to load #{code_file}"
    raise e
  ensure
    @step_definitions = nil
  end
end
step_matches(name_to_match, name_to_format) click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 60
def step_matches(name_to_match, name_to_format)
  @step_definitions.map do |step_definition|
    if(arguments = step_definition.arguments_from(name_to_match))
      StepMatch.new(step_definition, name_to_match, name_to_format, arguments)
    else
      nil
    end
  end.compact
end

Protected Instance Methods

begin_scenario(scenario) click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 124
def begin_scenario(scenario)
  begin_rb_scenario(scenario)
end
end_scenario() click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 128
def end_scenario
  @current_world = nil
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.