Module: Cucumber
- Defined in:
- lib/cucumber/version.rb,
lib/cucumber.rb,
lib/cucumber/ast.rb,
lib/cucumber/world.rb,
lib/cucumber/parser.rb,
lib/cucumber/ast/step.rb,
lib/cucumber/ast/tags.rb,
lib/cucumber/cli/main.rb,
lib/cucumber/platform.rb,
lib/cucumber/ast/table.rb,
lib/cucumber/rake/task.rb,
lib/cucumber/step_match.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/formatter/usage.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/ast/feature_element.rb,
lib/cucumber/ast/step_collection.rb,
lib/cucumber/ast/step_invocation.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, FeatureElement, Formatter, Parser, Rails, Rake, StepDefinitionMethods, StepMother, World Classes: Ambiguous, ArityMismatchError, Broadcaster, MultipleWorld, NilWorld, NoStepMatch, Pending, Redundant, StepDefinition, StepMatch, 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/
- 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 method 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 method aliases for Given, When and Then. This does not affect how feature files are parsed. If you want to create aliases in the parser, you have to do this in languages.yml. For example:
and: And|With
53 54 55 56 57 58 |
# File 'lib/cucumber.rb', line 53 def alias_steps(keywords) keywords.each do |adverb| StepMother.alias_adverb(adverb) World.alias_adverb(adverb) 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 |