Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add spec for Virtus::AttributesAccessor#defined_writer_method

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