Module: Cucumber
- Defined in:
- lib/cucumber/version.rb,
lib/cucumber.rb,
lib/cucumber/ast.rb,
lib/cucumber/cli.rb,
lib/cucumber/parser.rb,
lib/cucumber/jbehave.rb,
lib/cucumber/ast/step.rb,
lib/cucumber/ast/tags.rb,
lib/cucumber/platform.rb,
lib/cucumber/ast/table.rb,
lib/cucumber/rake/task.rb,
lib/cucumber/ast/filter.rb,
lib/cucumber/ast/comment.rb,
lib/cucumber/ast/feature.rb,
lib/cucumber/ast/visitor.rb,
lib/cucumber/broadcaster.rb,
lib/cucumber/rails/world.rb,
lib/cucumber/step_mother.rb,
lib/cucumber/ast/examples.rb,
lib/cucumber/ast/features.rb,
lib/cucumber/ast/scenario.rb,
lib/cucumber/parser/table.rb,
lib/cucumber/ast/py_string.rb,
lib/cucumber/parser/feature.rb,
lib/cucumber/formatter/rerun.rb,
lib/cucumber/step_definition.rb,
lib/cucumber/formatter/pretty.rb,
lib/cucumber/ast/outline_table.rb,
lib/cucumber/formatter/console.rb,
lib/cucumber/formatter/profile.rb,
lib/cucumber/formatter/progress.rb,
lib/cucumber/parser/treetop_ext.rb,
lib/cucumber/formatter/ansicolor.rb,
lib/cucumber/ast/scenario_outline.rb,
lib/cucumber/core_ext/instance_exec.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Ast, Formatter, JBehave, Parser, Rails, Rake, StepMother Classes: ArityMismatchError, Broadcaster, CLI, StepDefinition, VERSION, YmlLoadError
Constant Summary collapse
- KEYWORD_KEYS =
%w{name native encoding feature background scenario scenario_outline examples given when then but}
- LANGUAGE_FILE =
File.(File.dirname(__FILE__) + '/languages.yml')
- LANGUAGES =
YAML.load_file(LANGUAGE_FILE)
- BINARY =
File.(File.dirname(__FILE__) + '/../../bin/cucumber')
- JRUBY =
defined?(JRUBY_VERSION)
- IRONRUBY =
Config::CONFIG['sitedir'] =~ /IronRuby/
- WINDOWS =
Config::CONFIG['host_os'] =~ /mswin|mingw/
- WINDOWS_MRI =
WINDOWS && !JRUBY && !IRONRUBY
- RAILS =
defined?(Rails)
- RUBY_BINARY =
File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
- RUBY_1_9 =
RUBY_VERSION =~ /^1\.9/
- EXCEPTION_STATUS =
Hash.new(:failed)
Class Attribute Summary collapse
-
.lang ⇒ Object
readonly
Returns the value of attribute lang.
Class Method Summary collapse
-
.alias_step_definitions(lang) ⇒ Object
:nodoc:.
-
.alias_steps(keywords) ⇒ Object
Sets up additional aliases for Given, When and Then.
-
.file_mode(m) ⇒ Object
File mode that accounts for Ruby platform and current language.
-
.keyword_hash(lang = @lang) ⇒ Object
Returns a Hash of the currently active language, or for a specific language if
lang
is specified. - .language_complete?(lang) ⇒ Boolean
-
.load_language(lang) ⇒ Object
:nodoc:.
Class Attribute Details
.lang ⇒ Object (readonly)
Returns the value of attribute lang.
18 19 20 |
# File 'lib/cucumber.rb', line 18 def lang @lang end |
Class Method Details
.alias_step_definitions(lang) ⇒ Object
:nodoc:
43 44 45 46 |
# File 'lib/cucumber.rb', line 43 def alias_step_definitions(lang) #:nodoc: keywords = %w{given when then and but}.map{|keyword| keyword_hash(lang)[keyword]} alias_steps(keywords) end |
.alias_steps(keywords) ⇒ Object
Sets up additional aliases for Given, When and Then. Try adding the following to your support/env.rb
:
# Given When Then in Norwegian
Cucumber.alias_steps %w{Gitt Naar Saa}
You cannot use special characters here, because methods with special characters is not valid Ruby code
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/cucumber.rb', line 57 def alias_steps(keywords) keywords.each do |adverb| StepMother.class_eval do alias_method adverb, :register_step_definition end StepMother::WorldMethods.class_eval do alias_method adverb, :__cucumber_invoke end end end |
.file_mode(m) ⇒ Object
File mode that accounts for Ruby platform and current language
32 33 34 |
# File 'lib/cucumber.rb', line 32 def file_mode(m) Cucumber::RUBY_1_9 ? "#{m}:#{keyword_hash['encoding']}" : m end |
.keyword_hash(lang = @lang) ⇒ Object
Returns a Hash of the currently active language, or for a specific language if lang
is specified.
39 40 41 |
# File 'lib/cucumber.rb', line 39 def keyword_hash(lang=@lang) LANGUAGES[lang] end |
.language_complete?(lang) ⇒ Boolean
27 28 29 |
# File 'lib/cucumber.rb', line 27 def language_complete?(lang) KEYWORD_KEYS.detect{|key| keyword_hash(lang)[key].nil?} end |
.load_language(lang) ⇒ Object
:nodoc:
20 21 22 23 24 25 |
# File 'lib/cucumber.rb', line 20 def load_language(lang) #:nodoc: return if @lang @lang = lang alias_step_definitions(lang) Parser.load_parser(keyword_hash) end |