Module: Cucumber
- Defined in:
- lib/cucumber/version.rb,
lib/cucumber.rb,
lib/cucumber/ast.rb,
lib/cucumber/parser.rb,
lib/cucumber/jbehave.rb,
lib/cucumber/ast/step.rb,
lib/cucumber/ast/tags.rb,
lib/cucumber/cli/main.rb,
lib/cucumber/platform.rb,
lib/cucumber/ast/steps.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/ast/background.rb,
lib/cucumber/formatter/html.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/cli/configuration.rb,
lib/cucumber/formatter/console.rb,
lib/cucumber/formatter/profile.rb,
lib/cucumber/formatter/color_io.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,
lib/cucumber/cli/language_help_formatter.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Ast, Cli, Formatter, JBehave, Parser, Rails, Rake, StepMother Classes: Ambiguous, ArityMismatchError, Broadcaster, Pending, Redundant, StepDefinition, Undefined, VERSION
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)
- CODEPAGE =
"cp#{codepage}"
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_incomplete?(lang = @lang) ⇒ Boolean
-
.load_language(lang) ⇒ Object
:nodoc:.
Class Attribute Details
.lang ⇒ Object (readonly)
Returns the value of attribute lang.
17 18 19 |
# File 'lib/cucumber.rb', line 17 def lang @lang end |
Class Method Details
.alias_step_definitions(lang) ⇒ Object
:nodoc:
42 43 44 45 |
# File 'lib/cucumber.rb', line 42 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
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/cucumber.rb', line 56 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
31 32 33 |
# File 'lib/cucumber.rb', line 31 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.
38 39 40 |
# File 'lib/cucumber.rb', line 38 def keyword_hash(lang=@lang) LANGUAGES[lang] end |
.language_incomplete?(lang = @lang) ⇒ Boolean
26 27 28 |
# File 'lib/cucumber.rb', line 26 def language_incomplete?(lang=@lang) KEYWORD_KEYS.detect{|key| keyword_hash(lang)[key].nil?} end |
.load_language(lang) ⇒ Object
:nodoc:
19 20 21 22 23 24 |
# File 'lib/cucumber.rb', line 19 def load_language(lang) #:nodoc: return if @lang @lang = lang alias_step_definitions(lang) Parser.load_parser(keyword_hash) end |