Skip to content

Commit

Permalink
Cleanup for #125
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Sep 16, 2015
1 parent 4bae469 commit 25e731f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/lotus/action/mime.rb
Expand Up @@ -422,7 +422,7 @@ def accepts
end
end

# @since 0.5.0 - TODO: Confirm?
# @since 0.5.0
# @api private
def default_response_type
self.class.format_to_mime_type(configuration.default_response_format) if configuration.default_response_format
Expand Down
6 changes: 2 additions & 4 deletions lib/lotus/controller/configuration.rb
Expand Up @@ -427,6 +427,7 @@ def format(hash)
# Gets the value
# @return [Symbol,nil]
#
# @since 0.5.0
#
# @see Lotus::Action::Mime
#
Expand All @@ -441,8 +442,6 @@ def format(hash)
# Lotus::Controller.configure do
# default_request_format :html
# end
#
# @since 0.5.0 TODO: Confirm?
def default_request_format(format = nil)
if format
@default_request_format = Utils::Kernel.Symbol(format)
Expand Down Expand Up @@ -483,6 +482,7 @@ def default_format(format = nil)
# Gets the value
# @return [Symbol,nil]
#
# @since 0.5.0
#
# @see Lotus::Action::Mime
#
Expand All @@ -497,8 +497,6 @@ def default_format(format = nil)
# Lotus::Controller.configure do
# default_response_format :json
# end
#
# @since 0.5.0 TODO: Confirm?
def default_response_format(format = nil)
if format
@default_response_format = Utils::Kernel.Symbol(format)
Expand Down
17 changes: 13 additions & 4 deletions test/configuration_test.rb
Expand Up @@ -198,24 +198,33 @@ def hash
end
end

require 'lotus/utils/io'
describe "when not previously set" do
it 'returns nil' do
@configuration.default_format.must_be_nil
Lotus::Utils::IO.silence_warnings do
@configuration.default_format.must_be_nil
end
end
end

describe "when set" do
before do
@configuration.default_format :html
Lotus::Utils::IO.silence_warnings do
@configuration.default_format :html
end
end

it 'returns the value' do
@configuration.default_format.must_equal :html
Lotus::Utils::IO.silence_warnings do
@configuration.default_format.must_equal :html
end
end
end

it 'raises an error if the given format cannot be coerced into symbol' do
-> { @configuration.default_format(23) }.must_raise TypeError
Lotus::Utils::IO.silence_warnings do
-> { @configuration.default_format(23) }.must_raise TypeError
end
end
end

Expand Down

0 comments on commit 25e731f

Please sign in to comment.