This causes conflicts with the way the instance variable `@file` in the
test file works with the scope of `mock_app`. Without assigning the
`@file` instance variable to a temporary variable—in this case `path`—we
won't be able to access the instance var inside the mock_app > get context.
This commit is contained in:
Kashyap 2015-10-29 18:11:31 +05:30
parent 855208a293
commit a4dc2ea93c
1 changed files with 8 additions and 4 deletions

View File

@ -778,9 +778,10 @@ class HelpersTest < Minitest::Test
end
def send_file_app(opts={})
path = @file
mock_app {
get '/file.txt' do
send_file @file, opts
send_file path, opts
end
}
end
@ -882,10 +883,11 @@ class HelpersTest < Minitest::Test
end
it "does not override Content-Type if already set and no explicit type is given" do
path = @file
mock_app do
get('/') do
content_type :png
send_file @file
send_file path
end
end
get '/'
@ -893,10 +895,11 @@ class HelpersTest < Minitest::Test
end
it "does override Content-Type even if already set, if explicit type is given" do
path = @file
mock_app do
get('/') do
content_type :png
send_file @file, :type => :gif
send_file path, :type => :gif
end
end
get '/'
@ -904,9 +907,10 @@ class HelpersTest < Minitest::Test
end
it 'can have :status option as a string' do
path = @file
mock_app do
post '/' do
send_file @file, :status => '422'
send_file path, :status => '422'
end
end
post '/'