Skip to content

Commit

Permalink
Remove as many warnings as we can by initialising @Ivars to nil [cucu…
Browse files Browse the repository at this point in the history
…mber#507 state:resolved]
  • Loading branch information
aslakhellesoy committed Oct 29, 2009
1 parent ca5d20e commit 5e88a77
Show file tree
Hide file tree
Showing 22 changed files with 47 additions and 22 deletions.
1 change: 1 addition & 0 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Avoid duplicate cucumber entries in database.yml (Daniel Hofstetter)

=== Changed Features
* $cucumber_interrupted is now Cucumber.wants_to_quit - avoid global variable, which gives warnings. (Aslak Hellesøy)
* Examples keyword without a colon is deprecated loudly. Gherkin will not recognize it at all. (Gherkin #30 Mike Sassak)

== 0.4.3 2009-10-28
Expand Down
6 changes: 6 additions & 0 deletions lib/cucumber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@
require 'cucumber/step_mother'
require 'cucumber/cli/main'
require 'cucumber/broadcaster'

module Cucumber
class << self
attr_accessor :wants_to_quit
end
end
2 changes: 1 addition & 1 deletion lib/cucumber/ast/background.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def step_collection(step_invocations)
end

def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
visitor.visit_comment(@comment) unless @comment.empty?
visitor.visit_background_name(@keyword, @name, file_colon_line(@line), source_indent(first_line_length))
with_visitor(hook_context, visitor) do
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/ast/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def empty?
end

def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
@value.strip.split("\n").each do |line|
visitor.visit_comment_line(line.strip)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/ast/examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def initialize(comment, line, keyword, name, outline_table)
end

def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
visitor.visit_comment(@comment) unless @comment.empty?
visitor.visit_examples_name(@keyword, @name)
visitor.visit_outline_table(@outline_table)
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/ast/feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def initialize(background, comment, tags, name, feature_elements)
end

def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
visitor.visit_comment(@comment) unless @comment.empty?
visitor.visit_tags(@tags)
visitor.visit_feature_name(@name)
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/ast/features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def add_feature(feature)
end

def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
start = Time.now
self.each do |feature|
visitor.visit_feature(feature)
Expand Down
11 changes: 8 additions & 3 deletions lib/cucumber/ast/outline_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(raw, scenario_outline)
end

def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
cells_rows.each_with_index do |row, n|
if(visitor.options[:expand])
row.accept(visitor)
Expand Down Expand Up @@ -44,7 +44,7 @@ def visit_scenario_name(visitor, row)
@scenario_outline.visit_scenario_name(visitor, row)
end

class ExampleRow < Cells #:nodoc:
class ExampleRow < Cells #:nodoc:
class InvalidForHeaderRowError < NoMethodError
def initialize(*args)
super 'This is a header row and cannot pass or fail'
Expand All @@ -53,6 +53,11 @@ def initialize(*args)

attr_reader :scenario_outline # https://rspec.lighthouseapp.com/projects/16211/tickets/342

def initialize(table, cells)
super
@scenario_exception = nil
end

def create_step_invocations!(scenario_outline)
@scenario_outline = scenario_outline
@step_invocations = scenario_outline.step_invocations(self)
Expand All @@ -65,7 +70,7 @@ def skip_invoke!
end

def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
visitor.options[:expand] ? accept_expand(visitor) : accept_plain(visitor)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/ast/py_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def to_s
end

def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
visitor.visit_py_string(to_s)
end

Expand Down
4 changes: 3 additions & 1 deletion lib/cucumber/ast/scenario.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ def initialize(background, comment, tags, line, keyword, name, steps)
step_invocations = steps.map{|step| step.step_invocation}
@steps = @background.step_collection(step_invocations)
@background.feature_elements << self

@exception = @executed = nil
end

def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit

with_visitor(visitor) do
visitor.visit_comment(@comment) unless @comment.empty?
Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/ast/scenario_outline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ScenarioOutline #:nodoc:

module ExamplesArray #:nodoc:
def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
each do |examples|
visitor.visit_examples(examples)
end
Expand Down Expand Up @@ -39,7 +39,7 @@ def initialize(background, comment, tags, line, keyword, name, steps, example_se
end

def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
visitor.visit_comment(@comment) unless @comment.empty?
visitor.visit_tags(@tags)
visitor.visit_scenario_name(@keyword, @name, file_colon_line(@line), source_indent(first_line_length))
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/ast/step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def step_invocation_from_cells(cells)
end

def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
# The only time a Step is visited is when it is in a ScenarioOutline.
# Otherwise it's always StepInvocation that gets visited instead.
visit_step_result(visitor, first_match(visitor), @multiline_arg, :skipped, nil, nil)
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/ast/step_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(steps)
end

def accept(visitor, &proc)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
@steps.each do |step|
visitor.visit_step(step) if proc.nil? || proc.call(step)
end
Expand Down
3 changes: 2 additions & 1 deletion lib/cucumber/ast/step_invocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def worst_status(statuses)
def initialize(step, name, multiline_arg, matched_cells)
@step, @name, @multiline_arg, @matched_cells = step, name, multiline_arg, matched_cells
status!(:skipped)
@skip_invoke = @exception = @step_match = @different_table = @reported_exception = @background = nil
end

def background?
Expand All @@ -33,7 +34,7 @@ def skip_invoke!
end

def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
invoke(visitor.step_mother, visitor.options)
visit_step_result(visitor)
end
Expand Down
6 changes: 3 additions & 3 deletions lib/cucumber/ast/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def each_cells_row(&proc) #:nodoc:
end

def accept(visitor) #:nodoc:
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
cells_rows.each do |row|
visitor.visit_table_row(row)
end
Expand Down Expand Up @@ -567,7 +567,7 @@ def initialize(table, cells)
end

def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
each do |cell|
visitor.visit_table_cell(cell)
end
Expand Down Expand Up @@ -623,7 +623,7 @@ def initialize(value, table, line)
end

def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
visitor.visit_table_cell_value(value, status)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/ast/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def initialize(line, tag_names)
end

def accept(visitor)
return if $cucumber_interrupted
return if Cucumber.wants_to_quit
@tag_names.each do |tag_name|
visitor.visit_tag_name(tag_name)
end
Expand Down
5 changes: 3 additions & 2 deletions lib/cucumber/cli/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def initialize(args, out_stream = STDOUT, error_stream = STDERR)
@args = args
@out_stream = out_stream == STDOUT ? Formatter::ColorIO.new : out_stream
@error_stream = error_stream
@configuration = nil
end

def execute!(step_mother)
Expand Down Expand Up @@ -110,8 +111,8 @@ def enable_diffing

def trap_interrupt
trap('INT') do
exit!(1) if $cucumber_interrupted
$cucumber_interrupted = true
exit!(1) if Cucumber.wants_to_quit
Cucumber.wants_to_quit = true
STDERR.puts "\nExiting... Interrupt again to exit immediately."
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/cucumber/cli/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def initialize(out_stream = STDOUT, error_stream = STDERR, options = {})
@skip_profile_information = options[:skip_profile_information]
@profiles = []
@overridden_paths = []
@options = default_options
@options = default_options

@quiet = @disable_profile_loading = nil
end

def [](key)
Expand Down
4 changes: 4 additions & 0 deletions lib/cucumber/cli/profile_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ module Cli

class ProfileLoader

def initialize
@cucumber_yml = nil
end

def args_from(profile)
unless cucumber_yml.has_key?(profile)
raise(ProfileNotFound, <<-END_OF_ERROR)
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/parser/natural_language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def initialize(step_mother, lang)
raise "Language not supported: #{lang.inspect}" if @keywords.nil?
@keywords['grammar_name'] = @keywords['name'].gsub(/\s/, '')
register_adverbs(step_mother) if step_mother
@parser = nil
end

def register_adverbs(step_mother)
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/rb_support/rb_language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def initialize(step_mother)
@step_mother = step_mother
@step_definitions = []
RbDsl.rb_language = self
@world_proc = @world_modules = nil
end

# Tell the language about other i18n translations so that
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/step_mother.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def initialize
@programming_languages = []
@language_map = {}
load_natural_language('en')
@current_scenario = nil
end

def load_plain_text_features(feature_files)
Expand Down

0 comments on commit 5e88a77

Please sign in to comment.