From ef2c38955ec86cdbd14eff821de23c7e9a03a88e Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Thu, 14 Mar 2013 22:33:53 +0530 Subject: [PATCH 1/2] Cleanup unused variables --- test/integration_helper.rb | 2 +- test/request_test.rb | 2 +- test/streaming_test.rb | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/integration_helper.rb b/test/integration_helper.rb index 57124fbe..b991ad29 100644 --- a/test/integration_helper.rb +++ b/test/integration_helper.rb @@ -60,7 +60,7 @@ module IntegrationHelper def alive? 3.times { get('/ping') } true - rescue Errno::ECONNREFUSED, Errno::ECONNRESET, EOFError, SystemCallError, OpenURI::HTTPError, Timeout::Error => error + rescue Errno::ECONNREFUSED, Errno::ECONNRESET, EOFError, SystemCallError, OpenURI::HTTPError, Timeout::Error false end diff --git a/test/request_test.rb b/test/request_test.rb index 25599b6d..7654cd41 100644 --- a/test/request_test.rb +++ b/test/request_test.rb @@ -38,7 +38,7 @@ class RequestTest < Test::Unit::TestCase 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', 'rack.input' => StringIO.new('foo=bar') ) - params = Sinatra::Base.new!.send(:indifferent_hash).replace(request.params) + Sinatra::Base.new!.send(:indifferent_hash).replace(request.params) dumped = Marshal.dump(request.params) assert_equal 'bar', Marshal.load(dumped)['foo'] end diff --git a/test/streaming_test.rb b/test/streaming_test.rb index 71dc8db6..6e3c034d 100644 --- a/test/streaming_test.rb +++ b/test/streaming_test.rb @@ -41,9 +41,9 @@ class StreamingTest < Test::Unit::TestCase it 'calls the callback after it is done' do step = 0 final = 0 - stream = Stream.new { |o| 10.times { step += 1 }} + stream = Stream.new { 10.times { step += 1 }} stream.callback { final = step } - stream.each { |str| } + stream.each { } assert_equal 10, final end @@ -52,7 +52,7 @@ class StreamingTest < Test::Unit::TestCase final = 0 stream = Stream.new(Stream, :keep_open) { |o| 10.times { step += 1 } } stream.callback { final = step } - stream.each { |str| } + stream.each { } assert_equal 0, final end @@ -61,7 +61,7 @@ class StreamingTest < Test::Unit::TestCase stream = Stream.new { } stream.callback { a = true } stream.callback { b = true } - stream.each { |str| } + stream.each { } assert a, 'should trigger first callback' assert b, 'should trigger second callback' end @@ -110,7 +110,7 @@ class StreamingTest < Test::Unit::TestCase it 'does not trigger an infinite loop if you call close in a callback' do stream = Stream.new { |out| out.callback { out.close }} - stream.each { |str| } + stream.each { } end it 'gives access to route specific params' do From ce4ad87480fd246cea6dd8b5ef6f00e5d0ec7042 Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Fri, 15 Mar 2013 15:44:10 +0530 Subject: [PATCH 2/2] Use |_| instead of vars; fix typo --- test/streaming_test.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/streaming_test.rb b/test/streaming_test.rb index 6e3c034d..d307d3b6 100644 --- a/test/streaming_test.rb +++ b/test/streaming_test.rb @@ -3,7 +3,7 @@ require File.expand_path('../helper', __FILE__) class StreamingTest < Test::Unit::TestCase Stream = Sinatra::Helpers::Stream - it 'returns the concatinated body' do + it 'returns the concatenated body' do mock_app do get('/') do stream do |out| @@ -41,18 +41,18 @@ class StreamingTest < Test::Unit::TestCase it 'calls the callback after it is done' do step = 0 final = 0 - stream = Stream.new { 10.times { step += 1 }} + stream = Stream.new { |_| 10.times { step += 1 }} stream.callback { final = step } - stream.each { } + stream.each {|_|} assert_equal 10, final end it 'does not trigger the callback if close is set to :keep_open' do step = 0 final = 0 - stream = Stream.new(Stream, :keep_open) { |o| 10.times { step += 1 } } + stream = Stream.new(Stream, :keep_open) { |_| 10.times { step += 1 } } stream.callback { final = step } - stream.each { } + stream.each {|_|} assert_equal 0, final end @@ -61,7 +61,7 @@ class StreamingTest < Test::Unit::TestCase stream = Stream.new { } stream.callback { a = true } stream.callback { b = true } - stream.each { } + stream.each {|_| } assert a, 'should trigger first callback' assert b, 'should trigger second callback' end @@ -110,7 +110,7 @@ class StreamingTest < Test::Unit::TestCase it 'does not trigger an infinite loop if you call close in a callback' do stream = Stream.new { |out| out.callback { out.close }} - stream.each { } + stream.each { |_| } end it 'gives access to route specific params' do