Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ Style/SpaceAfterColon:
Style/SpaceAfterComma:
Description: Use spaces after commas.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
Enabled: false
Enabled: true

# Supports --auto-correct
Style/SpaceAfterControlKeyword:
Expand Down
2 changes: 1 addition & 1 deletion bin/enable-executable
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require 'fileutils'
puts 'Ensuring test files are executable.'

# Assume that this file lives in #{base}/bin
base = File.join(__dir__,'..')
base = File.join(__dir__, '..')
files = Dir.glob("#{base}/**/*test.rb") + Dir.glob("#{base}/bin/*")

files.each do |file|
Expand Down
2 changes: 1 addition & 1 deletion bin/executable-tests-check
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'minitest/autorun'

# Assume that this file lives in #{base}/bin
base = File.join(__dir__,'..')
base = File.join(__dir__, '..')
files = Dir.glob("#{base}/exercises/**/*test.rb") + Dir.glob("#{base}/bin/*")

files.each do |file|
Expand Down
2 changes: 1 addition & 1 deletion exercises/connect/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def prepare_board(game)

def start_of(winner)
case winner
when BLACK then (0...@height).map { |y| Position.new(0,y) }
when BLACK then (0...@height).map { |y| Position.new(0, y) }
when WHITE then (0...@width).map { |x| Position.new(x, 0) }
end
end
Expand Down
2 changes: 1 addition & 1 deletion exercises/diamond/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.make_diamond(letter)
middle = total_lines/2
letter_char_code = 65
(0..total_lines - 1).each do |i|
line = Array.new(total_lines," ") # creates a line in each loop
line = Array.new(total_lines, " ") # creates a line in each loop
if i == 0 || i == total_lines - 1 # placing the letter A in the beginning and end
line[middle] = "A"
else
Expand Down
12 changes: 6 additions & 6 deletions exercises/simple-linked-list/simple_linked_list_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,26 @@ def test_list_multiple_to_array
second = Element.new(2)
third = Element.new(3)
list.push(first).push(second).push(third)
assert_equal [3,2,1], list.to_a
assert_equal [3, 2, 1], list.to_a
end

def test_list_create_from_array
skip
array = [1,2,3]
array = [1, 2, 3]
list = SimpleLinkedList.new(array)
assert_equal [3,2,1], list.to_a
assert_equal [3, 2, 1], list.to_a
end

def test_list_created_from_array_still_made_up_of_elements
skip
array = [1,2,3]
array = [1, 2, 3]
list = SimpleLinkedList.new(array)
assert_equal Element, list.pop.class
end

def test_list_from_array_still_acts_as_lifo
skip
array = [1,2,3]
array = [1, 2, 3]
list = SimpleLinkedList.new(array)
element = list.pop
assert_equal 3, element.datum
Expand All @@ -111,7 +111,7 @@ def test_list_in_place_reverse!
list = SimpleLinkedList.new
list.push(first).push(second).push(third)

assert_equal [1,2,3], list.reverse!.to_a
assert_equal [1, 2, 3], list.reverse!.to_a
end

def test_list_in_place_reverse_are_the_same_elements
Expand Down
2 changes: 1 addition & 1 deletion lib/all_your_base_cases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def input_of_zero?
end

def handle_special_cases
[4,2] if row['input_digits'] == [0, 6, 0]
[4, 2] if row['input_digits'] == [0, 6, 0]
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/alphametics_cases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def workload
"input = %s\n" % input,
"expected = %s\n" % expect,
"assert_equal expected, Alphametics.solve(input)"
indent(body,4)
indent(body, 4)
end

def runtime_comment
Expand All @@ -30,7 +30,7 @@ def runtime_comment
"# The obvious algorithm can take a long time to solve this puzzle,\n",
"# but an optimised solution can solve it fairly quickly.\n",
"# (It's OK to submit your solution without getting this test to pass.)\n"
indent(comments,2)
indent(comments, 2)
end
end

Expand All @@ -41,7 +41,7 @@ def slow?
end

def expected_values
"{ #{indent(expected_values_as_lines,17)} }"
"{ #{indent(expected_values_as_lines, 17)} }"
end

def expected_values_as_lines
Expand All @@ -50,7 +50,7 @@ def expected_values_as_lines
end

def expected_values_as_strings
expected.sort.map { |(key,value)| "'#{key}' => #{value}" }
expected.sort.map { |(key, value)| "'#{key}' => #{value}" }
end

def add_trailing_comma_and_newline(lines)
Expand Down
2 changes: 1 addition & 1 deletion lib/generator/files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Generator
module Files
class Readable
attr_reader :filename, :repository_root
def initialize(filename:,repository_root: nil)
def initialize(filename:, repository_root: nil)
@filename = filename
@repository_root = repository_root
end
Expand Down
6 changes: 3 additions & 3 deletions lib/generator/files/track_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ def available(track_path)
end

def filename(exercise_name)
"#{exercise_name.tr('-','_')}_cases"
"#{exercise_name.tr('-', '_')}_cases"
end

def proc_name(exercise_name)
filename(exercise_name).split('_').map(&:capitalize).join
end

def exercise_name(filename)
%r{([^/]*)_cases\.rb$}.match(filename).captures[0].tr('_','-')
%r{([^/]*)_cases\.rb$}.match(filename).captures[0].tr('_', '-')
end
end

Expand Down Expand Up @@ -71,7 +71,7 @@ def update_version(version)
end

class MinitestTestsFile < Writable
def generate(template:,values:)
def generate(template:, values:)
content = ERB.new(template, nil, '<>').result values.get_binding
save(content)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/grains_cases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def skipped
private

def underscore_format(number)
number.to_s.reverse.gsub(/...(?=.)/,'\&_').reverse
number.to_s.reverse.gsub(/...(?=.)/, '\&_').reverse
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/isogram_cases.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class IsogramCase < OpenStruct

def name
format('test_%s', description.downcase.gsub(/[ -]/,'_'))
format('test_%s', description.downcase.gsub(/[ -]/, '_'))
end

def assertion
Expand Down
2 changes: 1 addition & 1 deletion lib/pangram_cases.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class PangramCase < OpenStruct
def name
'test_%s' % description.downcase.tr_s(" -'", '_').sub(/_$/,'')
'test_%s' % description.downcase.tr_s(" -'", '_').sub(/_$/, '')
end

def workload
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/xruby/lib/alpha_cases.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class AlphaCase < OpenStruct

def name
format('test_%s', description.downcase.gsub(/[ -]/,'_'))
format('test_%s', description.downcase.gsub(/[ -]/, '_'))
end

def assertion
Expand Down
2 changes: 1 addition & 1 deletion test/generator/command_line_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_parse

def test_invalid_metadata_repository_outputs_message_to_stderr
paths = Paths.new(metadata: 'test/fixtures/nonexistent', track: nil)
expected_stderr = <<-MESSAGE.gsub(/^ {6}/,'')
expected_stderr = <<-MESSAGE.gsub(/^ {6}/, '')
'x-common' repository not found.
Try running the command:
git clone https://github.com/exercism/x-common.git "test/fixtures/nonexistent"
Expand Down
2 changes: 1 addition & 1 deletion test/generator/template_values_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_test_cases
end

def test_get_binding
subject = TemplateValues.new(sha1: nil,version: nil, test_cases: nil)
subject = TemplateValues.new(sha1: nil, version: nil, test_cases: nil)
assert_instance_of Binding, subject.get_binding
end
end
Expand Down