Parent

Files

Class/Module Index [+]

Quicksearch

Cucumber::RbSupport::RbLanguage

The Ruby implementation of the programming language API.

Constants

SNIPPET_TYPES

Attributes

current_world[R]
step_definitions[R]

Public Class Methods

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

Public Instance Methods

begin_rb_scenario(scenario) click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 92
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 112
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
find_best_assertions_module() click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 62
def find_best_assertions_module
  begin
    ::RSpec::Matchers
  rescue NameError
    # RSpec >=1.2.4
    begin
      options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
      Spec::Expectations.differ = Spec::Expectations::Differs::Default.new(options)
      ::Spec::Matchers
    rescue NameError
      ::Test::Unit::Assertions
    end
  end
end
load_code_file(code_file) click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 121
def load_code_file(code_file)
  load 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 98
def register_rb_hook(phase, tag_expressions, proc)
  add_hook(phase, RbHook.new(self, tag_expressions, proc))
end
register_rb_step_definition(regexp, proc_or_sym, options) click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 106
def register_rb_step_definition(regexp, proc_or_sym, options)
  step_definition = RbStepDefinition.new(self, regexp, proc_or_sym, options)
  @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 102
def register_rb_transform(regexp, proc)
  add_transform(RbTransform.new(self, regexp, proc))
end
snippet_text(code_keyword, step_name, multiline_arg_class, snippet_type = :regexp) click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 87
def snippet_text(code_keyword, step_name, multiline_arg_class, snippet_type = :regexp)
  snippet_class = typed_snippet_class(snippet_type)
  snippet_class.new(code_keyword, step_name, multiline_arg_class).to_s
end
step_matches(name_to_match, name_to_format) click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 77
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 127
def begin_scenario(scenario)
  begin_rb_scenario(scenario)
end
end_scenario() click to toggle source
# File lib/cucumber/rb_support/rb_language.rb, line 131
def end_scenario
  @current_world = nil
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.