diff --git a/exe/convert_to_should_syntax b/exe/convert_to_should_syntax index ebdda984..e69a6103 100755 --- a/exe/convert_to_should_syntax +++ b/exe/convert_to_should_syntax @@ -21,13 +21,18 @@ def usage(msg = nil) puts " ..." puts " end" puts - puts "A copy of the old file will be left under #{TMP} in case\nthis script just seriously screws up" + puts "A copy of the old file will be left under #{TMP} in case" + puts "this script just seriously screws up" puts exit (msg ? 2 : 0) end usage("Wrong number of arguments.") unless ARGV.size == 1 -usage("Temp directory '#{TMP}' is not valid. Set TMPDIR environment variable to a writeable directory.") unless File.directory?(TMP) && File.writable?(TMP) + +unless File.directory?(TMP) && File.writable?(TMP) + usage("Temp directory '#{TMP}' is not valid. \ +Set TMPDIR environment variable to a writeable directory.") +end file = ARGV.shift tmpfile = File.join(TMP, File.basename(file)) @@ -39,4 +44,5 @@ contents.gsub!(/def test_should_(\S+)/) {|line| "should \"#{$1.tr('_', ' ')}\" d contents.gsub!(/def test_(\S+)/) {|line| "should \"RENAME ME: test #{$1.tr('_', ' ')}\" do"} File.open(file, 'w') { |f| f.write(contents) } -puts "File '#{file}' has been converted to 'should' syntax. Old version has been stored in '#{tmpfile}'" +puts "File '#{file}' has been converted to 'should' syntax. \ +Old version has been stored in '#{tmpfile}'" diff --git a/lib/shoulda/context/assertions.rb b/lib/shoulda/context/assertions.rb index f2732a08..ba29dc9b 100644 --- a/lib/shoulda/context/assertions.rb +++ b/lib/shoulda/context/assertions.rb @@ -6,7 +6,10 @@ module Assertions # assert_same_elements([:a, :b, :c], [:c, :a, :b]) => passes) def assert_same_elements(a1, a2, msg = nil) [:select, :inject, :size].each do |m| - [a1, a2].each {|a| assert_respond_to(a, m, "Are you sure that #{a.inspect} is an array? It doesn't respond to #{m}.") } + [a1, a2].each do |a| + assert_respond_to(a, m, + "Are you sure that #{a.inspect} is an array? It doesn't respond to #{m}.",) + end end assert a1h = a1.inject({}) { |h,e| h[e] ||= a1.select { |i| i == e }.size; h } diff --git a/lib/shoulda/context/context.rb b/lib/shoulda/context/context.rb index c15b2ffc..6fad0e04 100644 --- a/lib/shoulda/context/context.rb +++ b/lib/shoulda/context/context.rb @@ -7,7 +7,9 @@ class Context # :nodoc: attr_accessor :setup_blocks # blocks given via setup methods attr_accessor :teardown_blocks # blocks given via teardown methods attr_accessor :shoulds # array of hashes representing the should statements + # rubocop:disable Layout/LineLength attr_accessor :should_eventuallys # array of hashes representing the should eventually statements + # rubocop:enable Layout/LineLength # accessor with cache def subject_block @@ -213,4 +215,3 @@ def method_missing(method, *args, &blk) class DuplicateTestError < RuntimeError; end end end - diff --git a/test/shoulda/context_test.rb b/test/shoulda/context_test.rb index 61036e93..d93c5885 100644 --- a/test/shoulda/context_test.rb +++ b/test/shoulda/context_test.rb @@ -28,7 +28,8 @@ def self.context_macro(&blk) end should "be named correctly" do - assert_match(/^test: context with setup block and a subcontext should be named correctly/, normalized_name) + assert_match(/^test: context with setup block and a subcontext should be named correctly/, + normalized_name) end should "run the setup blocks in order" do @@ -37,9 +38,14 @@ def self.context_macro(&blk) end context_macro do + # rubocop:disable Layout/LineLength should "have name set right" do - assert_match(/^test: context with setup block with a subcontext made by a macro should have name set right/, normalized_name) + assert_match( + /^test: context with setup block with a subcontext made by a macro should have name set right/, + normalized_name + ) end + # rubocop:enable Layout/LineLength should "run the setup block of that context macro" do assert_equal :foo, @context_macro @@ -108,11 +114,13 @@ def hello; "hi"; end teardown { cleanup_count -= 1 } end + # rubocop:disable Layout/LineLength 2.times do |i| should "also call all setups and all teardowns in parent and subcontext (check ##{i + 1})" do assert_equal 4, cleanup_count end end + # rubocop:enable Layout/LineLength end diff --git a/test/shoulda/convert_to_should_syntax_test.rb b/test/shoulda/convert_to_should_syntax_test.rb index c984f728..69b85225 100644 --- a/test/shoulda/convert_to_should_syntax_test.rb +++ b/test/shoulda/convert_to_should_syntax_test.rb @@ -47,7 +47,8 @@ def non_test_method def test_convert_to_should_syntax File.open(FIXTURE_PATH, "w") {|f| f.write(BEFORE_FIXTURE)} - cmd = "#{RUBY} #{File.join(File.dirname(__FILE__), '../../exe/convert_to_should_syntax')} #{FIXTURE_PATH}" + cmd = "#{RUBY} #{File.join(File.dirname(__FILE__), + '../../exe/convert_to_should_syntax',)} #{FIXTURE_PATH}" output = `#{cmd}` File.unlink($1) if output.match(/has been stored in '([^']+)/) assert_match(/has been converted/, output)