Class: CRB::Console

Inherits:
Cucumber::Cli::Main
  • Object
show all
Includes:
IRB
Defined in:
lib/crb.rb

Instance Method Summary collapse

Instance Method Details

#execute!Object



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/crb.rb', line 97

def execute!
  load_step_definitions
  IRB.setup(__FILE__)
  IRB.conf[:CONTEXT_MODE] = 0
  irb = Irb.new(WorkSpace.new(world))
  IRB.module_eval do
    @CONF[:MAIN_CONTEXT] = irb.context
  end

  trap("SIGINT") {
    world.before 
    irb.signal_handle
  }
  catch(:IRB_EXIT) do
    irb.eval_input
  end
end

#load_step_definitionsObject



92
93
94
95
# File 'lib/crb.rb', line 92

def load_step_definitions
  files = configuration.support_to_load + configuration.step_defs_to_load
  support.load_files!(files)
end

#rbObject



70
71
72
# File 'lib/crb.rb', line 70

def rb
  @rb ||= support.load_programming_language('rb')
end

#supportObject



66
67
68
# File 'lib/crb.rb', line 66

def support
  @support ||= Cucumber::Runtime::SupportCode.new(configuration)
end

#worldObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/crb.rb', line 74

def world
  @world ||= (
    stub = Struct.new(:language).new # stub scenario
    rb.begin_rb_scenario(stub)
    world = rb.current_world
    world.extend(CRB::World)
    world.support = support
    world.rb = rb
    world.instance_eval do
      Gherkin::I18n.code_keywords.each do |adverb|
        next if adverb.to_s == "Given"
        alias :"#{adverb}" :Given
      end
    end
    world
  )
end