-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
131 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Configuration holds RubyBBCode configuration | ||
class Configuration | ||
# Defines how to treat unknown tags | ||
# * :exception throws and exception | ||
# * :text converts it into a text | ||
# * :ignore removes it from the output | ||
attr_reader :ignore_unknown_tags | ||
|
||
def initialize | ||
@ignore_unknown_tags = :text | ||
end | ||
|
||
def ignore_unknown_tags=(value) | ||
raise 'ignore_unknown_tags must be either :exception, :text or :ignore' unless %i[exception text ignore].include? value | ||
|
||
@ignore_unknown_tags = value | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'test_helper' | ||
|
||
class ConfigurationTest < MiniTest::Test | ||
def before_setup | ||
RubyBBCode.reset | ||
end | ||
|
||
def test_configuration | ||
refute_equal :ignore, RubyBBCode.configuration.ignore_unknown_tags | ||
|
||
RubyBBCode.configuration.ignore_unknown_tags = :ignore | ||
|
||
assert_equal :ignore, RubyBBCode.configuration.ignore_unknown_tags | ||
end | ||
|
||
def test_configuration_reset | ||
refute_equal :exception, RubyBBCode.configuration.ignore_unknown_tags | ||
|
||
RubyBBCode.configuration.ignore_unknown_tags = :exception | ||
|
||
assert_equal :exception, RubyBBCode.configuration.ignore_unknown_tags | ||
|
||
RubyBBCode.reset | ||
|
||
refute_equal :exception, RubyBBCode.configuration.ignore_unknown_tags | ||
end | ||
|
||
def test_configuration_block | ||
refute_equal :ignore, RubyBBCode.configuration.ignore_unknown_tags | ||
|
||
RubyBBCode.configure do |config| | ||
config.ignore_unknown_tags = :ignore | ||
end | ||
|
||
assert_equal :ignore, RubyBBCode.configuration.ignore_unknown_tags | ||
end | ||
end |