Permalink
Browse files

Add spec for Virtus::AttributesAccessor#define_reader_method

  • Loading branch information...
1 parent 7d2f15b commit cd8a670f99b40d3ce41491ff4c249cd2099e850b @solnic committed Mar 16, 2012
Showing with 32 additions and 1 deletion.
  1. +32 −1 spec/unit/virtus/attributes_accessor/define_reader_method_spec.rb
@@ -1,5 +1,36 @@
require 'spec_helper'
describe Virtus::AttributesAccessor, '#define_reader_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 cd8a670

Please sign in to comment.