Class: CRB
- Inherits:
-
Cucumber::Cli::Main
- Object
- Cucumber::Cli::Main
- CRB
- Extended by:
- IRB
- Defined in:
- lib/crb.rb,
lib/crb.rb
Defined Under Namespace
Modules: ExecuteProc
Class Attribute Summary collapse
-
.irb ⇒ Object
Returns the value of attribute irb.
Class Method Summary collapse
- .alias_adverbs ⇒ Object
- .around_hooks(&block) ⇒ Object
- .enable_session(mode = nil) ⇒ Object
- .start(args) ⇒ Object
- .world ⇒ Object
Instance Method Summary collapse
Class Attribute Details
.irb ⇒ Object
Returns the value of attribute irb.
13 14 15 |
# File 'lib/crb.rb', line 13 def irb @irb end |
Class Method Details
.alias_adverbs ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/crb.rb', line 67 def alias_adverbs world.instance_eval do hash = Cucumber.keyword_hash keywords = %w{given when then and but}.map{|keyword| hash[keyword].split('|')}.flatten keywords.each do |name| instance_eval "alias :'#{name}' :__cucumber_invoke" end end end |
.around_hooks(&block) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/crb.rb', line 55 def around_hooks(&block) step_mother.hooks[:before].each do |hook| hook.execute(world) end block.call step_mother.hooks[:after].each do |hook| hook.execute(world) end end |
.enable_session(mode = nil) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/crb.rb', line 77 def enable_session(mode = nil) require 'webrat' require 'webrat/core/matchers' world.instance_eval do extend ::Webrat::Methods extend ::Webrat::Matchers if mode || !Webrat.configure.mode Webrat.configure.mode = (mode || :mechanize) if Webrat.configure.mode == :mechanize webrat_session.mechanize.user_agent_alias = 'Windows Mozilla' end end %w{response post}.each do |m| unless respond_to?(m, true) instance_eval <<-EOF def #{m}(*args, &blk) webrat.#{m}(*args, &blk) end EOF end end end end |
.start(args) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/crb.rb', line 25 def start(args) IRB.setup(__FILE__) IRB.conf[:CONTEXT_MODE] = 0 ws = WorkSpace.new(world) CRB.irb = Irb.new(ws) IRB.module_eval do @CONF[:MAIN_CONTEXT] = CRB.irb.context end step_mother.World do world end execute(args) step_mother.send(:new_world!) alias_adverbs enable_session trap("SIGINT") do irb.signal_handle end around_hooks do catch(:IRB_EXIT) do irb.eval_input end end end |
.world ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/crb.rb', line 15 def world unless @world @world = CRB.step_mother def @world.to_s "World" end end @world end |
Instance Method Details
#execute!(step_mother) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/crb.rb', line 106 def execute!(step_mother) configuration.load_language step_mother. = configuration. require_files enable_diffing features = load_plain_text_features visitor = configuration.build_formatter_broadcaster(step_mother) step_mother.visitor = visitor # Needed to support World#announce end |