lib/cucumber/rb_support/rb_language.rb in cucumber-0.8.6 vs lib/cucumber/rb_support/rb_language.rb in cucumber-0.8.7
- old
+ new
@@ -1,6 +1,5 @@
-require 'cucumber/core_ext/instance_exec'
require 'cucumber/rb_support/rb_dsl'
require 'cucumber/rb_support/rb_world'
require 'cucumber/rb_support/rb_step_definition'
require 'cucumber/rb_support/rb_hook'
require 'cucumber/rb_support/rb_transform'
@@ -20,20 +19,19 @@
message = "You can only pass a proc to #World once, but it's happening\n"
message << "in 2 places:\n\n"
message << first_proc.backtrace_line('World') << "\n"
message << second_proc.backtrace_line('World') << "\n\n"
message << "Use Ruby modules instead to extend your worlds. See the Cucumber::RbSupport::RbDsl#World RDoc\n"
- message << "or http://wiki.github.com/cucumber/cucumber/a-whole-new-world.\n\n"
+ message << "or http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world.\n\n"
super(message)
end
end
# The Ruby implementation of the programming language API.
class RbLanguage
include LanguageSupport::LanguageMethods
- attr_reader :current_world,
- :step_definitions
+ attr_reader :current_world
Gherkin::I18n.code_keywords.each do |adverb|
RbDsl.alias_adverb(adverb)
RbWorld.alias_adverb(adverb)
end
@@ -65,22 +63,22 @@
end
end
# Gets called for each file under features (or whatever is overridden
# with --require).
- def step_definitions_for(rb_file) # Looks Unused - Delete?
+ def step_definitions_for(rb_file)
begin
require rb_file # This will cause self.add_step_definition and self.add_hook to be called from RbDsl
step_definitions
rescue LoadError => e
e.message << "\nFailed to load #{code_file}"
raise e
ensure
@step_definitions = nil
end
end
-
+
def step_matches(name_to_match, name_to_format)
@step_definitions.map do |step_definition|
if(arguments = step_definition.arguments_from(name_to_match))
StepMatch.new(step_definition, name_to_match, name_to_format, arguments)
else
@@ -89,11 +87,11 @@
end.compact
end
ARGUMENT_PATTERNS = ['"([^"]*)"', '(\d+)']
- def snippet_text(code_keyword, step_name, multiline_arg_class)
+ def snippet_text(step_keyword, step_name, multiline_arg_class)
snippet_pattern = Regexp.escape(step_name).gsub('\ ', ' ').gsub('/', '\/')
arg_count = 0
ARGUMENT_PATTERNS.each do |pattern|
snippet_pattern = snippet_pattern.gsub(Regexp.new(pattern), pattern)
arg_count += snippet_pattern.scan(pattern).length
@@ -105,11 +103,11 @@
multiline_class_comment = ""
if(multiline_arg_class == Ast::Table)
multiline_class_comment = "# #{multiline_arg_class.default_arg_name} is a #{multiline_arg_class.to_s}\n "
end
- "#{code_keyword} /^#{snippet_pattern}$/ do#{block_arg_string}\n #{multiline_class_comment}pending # express the regexp above with the code you wish you had\nend"
+ "#{Gherkin::I18n.code_keyword_for(step_keyword)} /^#{snippet_pattern}$/ do#{block_arg_string}\n #{multiline_class_comment}pending # express the regexp above with the code you wish you had\nend"
end
def begin_rb_scenario(scenario)
create_world
extend_world
@@ -138,12 +136,12 @@
@world_modules ||= []
@world_modules += world_modules
end
def load_code_file(code_file)
- load File.expand_path(code_file) # This will cause self.add_step_definition, self.add_hook, and self.add_transform to be called from RbDsl
+ require File.expand_path(code_file) # This will cause self.add_step_definition, self.add_hook, and self.add_transform to be called from RbDsl
end
-
+
protected
def begin_scenario(scenario)
begin_rb_scenario(scenario)
end