Skip to content

Commit

Permalink
Add spec for Virtus::Attribute#public_writer?
Browse files Browse the repository at this point in the history
  • Loading branch information
dkubb committed Jan 22, 2012
1 parent e7f8b28 commit aab2049
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 0 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
* Add missing specs:
* Add spec file spec/unit/virtus/attribute/private_writer_spec.rb for Virtus::Attribute#private_writer?
* Add spec file spec/unit/virtus/attribute/default_spec.rb for Virtus::Attribute#default
* Add spec file spec/unit/virtus/attribute/instance_variable_name_spec.rb for Virtus::Attribute#instance_variable_name
* Add spec file spec/unit/virtus/attribute/set_spec.rb for Virtus::Attribute#set!
Expand Down
24 changes: 24 additions & 0 deletions spec/unit/virtus/attribute/public_writer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'spec_helper'

describe Virtus::Attribute, '#public_writer?' do
subject { object.public_writer? }

let(:object) { described_class.new(:name, options) }
let(:options) { { :primitive => primitive, :coercion_method => coercion_method } }
let(:primitive) { stub('primitive') }
let(:coercion_method) { stub('coercion_method') }

context 'when :writer is not not specified' do
it { should be(true) }
end

{ :public => true, :protected => false, :private => false }.each do |value, expected|
context "when :writer is #{value.inspect}" do
before do
options.update(:writer => value)
end

it { should be(expected) }
end
end
end

0 comments on commit aab2049

Please sign in to comment.