Skip to content
Browse files

Add spec for Virtus::ClassMethods#attributes

* Make sure the deprecation warning is returned
  • Loading branch information...
1 parent 9e1bd9d commit 5bbc3af0fb969b094c754caf2b8ec4673ea1fd80 @dkubb dkubb committed Jun 11, 2012
Showing with 23 additions and 0 deletions.
  1. +23 −0 spec/unit/virtus/class_methods/attributes_spec.rb
View
23 spec/unit/virtus/class_methods/attributes_spec.rb
@@ -0,0 +1,23 @@
+require 'spec_helper'
+
+describe Virtus::ClassMethods, '#attributes' do
+ subject { object.attributes }
+
+ before do
+ @original_stderr, $stderr = $stderr, StringIO.new
+ end
+
+ after do
+ $stderr = @original_stderr
+ end
+
+ let(:object) { Class.new { extend Virtus::ClassMethods } }
+
+ it { should be_instance_of(Virtus::AttributeSet) }
+
+ it 'returns a deprecation warning' do
+ lambda { subject }.should change { $stderr.string.dup }.from('').to(
+ "#{object}.attributes is deprecated. Use #{object}.attribute_set instead: #{__FILE__}:4\n"
+ )
+ end
+end

0 comments on commit 5bbc3af

Please sign in to comment.
Something went wrong with that request. Please try again.