Permalink
Browse files

Add spec for Virtus::AttributesAccessor#defined_writer_method

  • Loading branch information...
1 parent cd8a670 commit a96f18ab5cffb56c6315192b49b8a5652067e728 @solnic committed Mar 16, 2012
Showing with 32 additions and 1 deletion.
  1. +32 −1 spec/unit/virtus/attributes_accessor/define_writer_method_spec.rb
@@ -1,5 +1,36 @@
require 'spec_helper'
describe Virtus::AttributesAccessor, '#define_writer_method' do
- it 'should have spec'
+ subject { described_class.new('Test') }
+
+ let(:attribute) { mock('attribute') }
+
+ if RUBY_VERSION < '1.9'
+ let(:method_name) { 'foo_bar=' }
+ else
+ let(:method_name) { :foo_bar= }
+ end
+
+ before do
+ subject.define_reader_method(attribute, method_name, visibility)
+ end
+
+ context "with public visibility" do
+ let(:visibility) { :public }
+
+ its(:public_instance_methods) { should include(method_name) }
+ end
+
+ context "with private visibility" do
+ let(:visibility) { :private }
+
+ its(:private_instance_methods) { should include(method_name) }
+ end
+
+ context "with protected visibility" do
+ let(:visibility) { :protected }
+
+ its(:protected_instance_methods) { should include(method_name) }
+ end
end
+

0 comments on commit a96f18a

Please sign in to comment.