Browse files

Fix Property#load specs

  • Loading branch information...
1 parent 8765c85 commit a2a84c8602b362d6ebb16a9a9bcd04ea711eb514 @solnic solnic committed Sep 13, 2011
View
4 lib/dm-core/property/binary.rb
@@ -10,7 +10,9 @@ def load(value)
end
def dump(value)
- super.dup.force_encoding("BINARY") unless value.nil?
+ value.dup.force_encoding("BINARY") unless value.nil?
+ rescue
+ value
end
end
View
14 lib/dm-core/spec/shared/semipublic/property_spec.rb
@@ -73,19 +73,13 @@ class Article
end
describe '#load' do
- before :all do
- @value = mock(@value)
- end
-
subject { @property.load(@value) }
- describe 'with a property' do
- it 'should delegate to #typecast' do
- return_value = mock(@other_value)
- @property.should_receive(:typecast).with(@value).and_return(return_value)
- should == return_value
- end
+ before do
+ @property.should_receive(:typecast).with(@value).and_return(@value)
end
+
+ it { should eql(@value) }
end
describe "#typecast" do
View
18 spec/semipublic/property/boolean_spec.rb
@@ -11,24 +11,6 @@
it_should_behave_like 'A semipublic Property'
- describe '#load' do
- before :all do
- @value = mock('value')
- end
-
- subject { @property.load(@value) }
-
- before do
- @property = @type.new(@model, @name)
- end
-
- it 'should delegate to #type.load' do
- return_value = mock('return value')
- @property.should_receive(:load).with(@value).and_return(return_value)
- should == return_value
- end
- end
-
describe '#valid?' do
[ true, false ].each do |value|
it "returns true when value is #{value.inspect}" do

0 comments on commit a2a84c8

Please sign in to comment.