Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add spec for Virtus::AttributesAccessor#define_reader_method

  • Loading branch information...
commit cd8a670f99b40d3ce41491ff4c249cd2099e850b 1 parent 7d2f15b
@solnic authored
View
33 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
+
Please sign in to comment.
Something went wrong with that request. Please try again.