Skip to content

Commit

Permalink
Refactor configuration class to be a little less strict on the option…
Browse files Browse the repository at this point in the history
…s being set.
  • Loading branch information
bobbytables committed Apr 28, 2013
1 parent 4972fb6 commit 0642125
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/table_cloth/configuration.rb
@@ -1,8 +1,8 @@
module TableCloth
class Configuration
OPTIONS = %w(table thead th tbody tr td).map(&:to_sym)
ELEMENT_OPTIONS = %w(table thead th tbody tr td).map(&:to_sym)

OPTIONS.each do |option|
ELEMENT_OPTIONS.each do |option|
class_eval <<-OPTION, __FILE__, __LINE__+1
def #{option}
@#{option}_option ||= ActiveSupport::OrderedOptions.new
Expand Down
9 changes: 5 additions & 4 deletions spec/lib/configuration_spec.rb
Expand Up @@ -2,11 +2,12 @@

describe TableCloth::Configuration do
subject { TableCloth::Configuration.new }
let(:options) { TableCloth::Configuration::OPTIONS }

it "has accessors for all options" do
options.each do |option|
expect(subject).to respond_to option
context "element options" do
TableCloth::Configuration::ELEMENT_OPTIONS.each do |option|
it "has an accessor for #{option}" do
expect(subject).to respond_to option
end
end
end

Expand Down

0 comments on commit 0642125

Please sign in to comment.