Skip to content

Commit 5a43719

Browse files
committed
Fix Layout/LineLength offenses
1 parent 65b32f8 commit 5a43719

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

exe/convert_to_should_syntax

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ def usage(msg = nil)
2121
puts " ..."
2222
puts " end"
2323
puts
24-
puts "A copy of the old file will be left under #{TMP} in case\nthis script just seriously screws up"
24+
puts "A copy of the old file will be left under #{TMP} in case"
25+
puts "this script just seriously screws up"
2526
puts
2627
exit (msg ? 2 : 0)
2728
end
2829

2930
usage("Wrong number of arguments.") unless ARGV.size == 1
30-
usage("Temp directory '#{TMP}' is not valid. Set TMPDIR environment variable to a writeable directory.") unless File.directory?(TMP) && File.writable?(TMP)
31+
32+
unless File.directory?(TMP) && File.writable?(TMP)
33+
usage("Temp directory '#{TMP}' is not valid. \
34+
Set TMPDIR environment variable to a writeable directory.")
35+
end
3136

3237
file = ARGV.shift
3338
tmpfile = File.join(TMP, File.basename(file))
@@ -39,4 +44,5 @@ contents.gsub!(/def test_should_(\S+)/) {|line| "should \"#{$1.tr('_', ' ')}\" d
3944
contents.gsub!(/def test_(\S+)/) {|line| "should \"RENAME ME: test #{$1.tr('_', ' ')}\" do"}
4045
File.open(file, 'w') { |f| f.write(contents) }
4146

42-
puts "File '#{file}' has been converted to 'should' syntax. Old version has been stored in '#{tmpfile}'"
47+
puts "File '#{file}' has been converted to 'should' syntax. \
48+
Old version has been stored in '#{tmpfile}'"

lib/shoulda/context/assertions.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ module Assertions
66
# assert_same_elements([:a, :b, :c], [:c, :a, :b]) => passes)
77
def assert_same_elements(a1, a2, msg = nil)
88
[:select, :inject, :size].each do |m|
9-
[a1, a2].each {|a| assert_respond_to(a, m, "Are you sure that #{a.inspect} is an array? It doesn't respond to #{m}.") }
9+
[a1, a2].each do |a|
10+
assert_respond_to(a, m,
11+
"Are you sure that #{a.inspect} is an array? It doesn't respond to #{m}.",)
12+
end
1013
end
1114

1215
assert a1h = a1.inject({}) { |h,e| h[e] ||= a1.select { |i| i == e }.size; h }

lib/shoulda/context/context.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ class Context # :nodoc:
77
attr_accessor :setup_blocks # blocks given via setup methods
88
attr_accessor :teardown_blocks # blocks given via teardown methods
99
attr_accessor :shoulds # array of hashes representing the should statements
10+
# rubocop:disable Layout/LineLength
1011
attr_accessor :should_eventuallys # array of hashes representing the should eventually statements
12+
# rubocop:enable Layout/LineLength
1113

1214
# accessor with cache
1315
def subject_block
@@ -213,4 +215,3 @@ def method_missing(method, *args, &blk)
213215
class DuplicateTestError < RuntimeError; end
214216
end
215217
end
216-

test/shoulda/context_test.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def self.context_macro(&blk)
2828
end
2929

3030
should "be named correctly" do
31-
assert_match(/^test: context with setup block and a subcontext should be named correctly/, normalized_name)
31+
assert_match(/^test: context with setup block and a subcontext should be named correctly/,
32+
normalized_name)
3233
end
3334

3435
should "run the setup blocks in order" do
@@ -37,9 +38,14 @@ def self.context_macro(&blk)
3738
end
3839

3940
context_macro do
41+
# rubocop:disable Layout/LineLength
4042
should "have name set right" do
41-
assert_match(/^test: context with setup block with a subcontext made by a macro should have name set right/, normalized_name)
43+
assert_match(
44+
/^test: context with setup block with a subcontext made by a macro should have name set right/,
45+
normalized_name
46+
)
4247
end
48+
# rubocop:enable Layout/LineLength
4349

4450
should "run the setup block of that context macro" do
4551
assert_equal :foo, @context_macro
@@ -108,11 +114,13 @@ def hello; "hi"; end
108114
teardown { cleanup_count -= 1 }
109115
end
110116

117+
# rubocop:disable Layout/LineLength
111118
2.times do |i|
112119
should "also call all setups and all teardowns in parent and subcontext (check ##{i + 1})" do
113120
assert_equal 4, cleanup_count
114121
end
115122
end
123+
# rubocop:enable Layout/LineLength
116124

117125
end
118126

test/shoulda/convert_to_should_syntax_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def non_test_method
4747

4848
def test_convert_to_should_syntax
4949
File.open(FIXTURE_PATH, "w") {|f| f.write(BEFORE_FIXTURE)}
50-
cmd = "#{RUBY} #{File.join(File.dirname(__FILE__), '../../exe/convert_to_should_syntax')} #{FIXTURE_PATH}"
50+
cmd = "#{RUBY} #{File.join(File.dirname(__FILE__),
51+
'../../exe/convert_to_should_syntax',)} #{FIXTURE_PATH}"
5152
output = `#{cmd}`
5253
File.unlink($1) if output.match(/has been stored in '([^']+)/)
5354
assert_match(/has been converted/, output)

0 commit comments

Comments
 (0)