Skip to content

Commit

Permalink
Add docs for strict_attributes mode.
Browse files Browse the repository at this point in the history
Also make the spec a bit more comprehensive.
  • Loading branch information
ged committed Oct 1, 2015
1 parent 939b33d commit 913cd0c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/inversion/template.rb
Expand Up @@ -82,6 +82,11 @@
# a purposeful delay between reloads for busy servers. Defaults to +0+
# (disabled).
#
# [:strict_attributes]
# Disable getting/setting attributes that aren't explicitly declared with a tag.
# Trying to get/set an attribute that isn't declared in the template with this
# option enabled will result in a NoMethodError being raised.
#
#
class Inversion::Template
extend Loggability
Expand Down
5 changes: 4 additions & 1 deletion spec/inversion/template_spec.rb
Expand Up @@ -127,9 +127,12 @@


it "raises instead of generating an accessor if configured with strict attributes" do
tmpl = described_class.new( '', strict_attributes: true )
tmpl = described_class.new( '<?attr bar ?>', strict_attributes: true )
expect { tmpl.foo = :bar }.to raise_error( NoMethodError, "no tag attribute 'foo' (strict mode)" )
expect { tmpl.foo }.to raise_error( NoMethodError, "no tag attribute 'foo' (strict mode)")

tmpl.bar = :foo
expect( tmpl.bar ).to eq( :foo )
end


Expand Down

0 comments on commit 913cd0c

Please sign in to comment.