Skip to content

Commit

Permalink
More test fixes.
Browse files Browse the repository at this point in the history
* Make sure allow_mult is true when testing conflicts.
* Make Time types compare properly on both sides of the expectation.
* For some reason ActiveModel classes have strange behavior when
  unnamed. We just remove the class constant at the end of each run.
  • Loading branch information
seancribbs committed Jan 25, 2012
1 parent 17d0ca4 commit f09ebf0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Gemfile.rails30
@@ -1,3 +1,3 @@
gem 'activemodel', '~> 3.0.0'
gem 'activemodel', '~> 3.0.11'

instance_eval File.read(File.expand_path('../Gemfile', __FILE__))
5 changes: 1 addition & 4 deletions spec/integration/ripple/conflict_resolution_spec.rb
Expand Up @@ -37,11 +37,8 @@ class ConflictedJob
property :title, String
end

before :all do
ConflictedPerson.bucket.allow_mult = true
end

before(:each) do
ConflictedPerson.bucket.allow_mult ||= true
ConflictedPerson.on_conflict { } # reset to no-op
end

Expand Down
2 changes: 1 addition & 1 deletion spec/ripple/persistence_spec.rb
Expand Up @@ -63,7 +63,7 @@
end

it "should instantiate and save a new object to riak" do
json = @widget.attributes.merge(:size => 10, :shipped_at => "2000-01-01T20:15:01Z", :_type => 'Widget')
json = @widget.attributes.merge(:size => 10, :shipped_at => Time.utc(2000,"jan",1,20,15,1), :_type => 'Widget')
@client.should_receive(:store_object) do |obj, _, _, _|
obj.key.should be_nil
obj.data.should == json
Expand Down
15 changes: 7 additions & 8 deletions spec/ripple/validations_spec.rb
Expand Up @@ -3,20 +3,16 @@
describe Ripple::Validations do
# require 'support/models/box'
let(:klass) do
Class.new do
class self.class::Valid
include Ripple::Document
self.bucket_name = "validators"

# Anonymous classes have no name
def self.model_name
@_model_name ||= ActiveModel::Name.new(self, nil, "Valid")
end
end
self.class::Valid
end

subject { klass.new }
let(:client) { Ripple.client }

after(:each) { self.class.send :remove_const, :Valid }
before :each do
client.stub(:store_object => true)
end
Expand Down Expand Up @@ -88,15 +84,18 @@ def self.model_name
lambda { klass.create! }.should raise_error(Ripple::DocumentInvalid)
end


it "should automatically add validations from property options" do
klass.property :size, Integer, :inclusion => {:in => 1..30 }

subject.size = 0
subject.should be_invalid
end

it "should run validations at the correct lifecycle state" do
klass.property :size, Integer, :inclusion => {:in => 1..30, :on => :update }
subject.stub!(:new).and_return(true)

subject.stub!(:new?).and_return(true)
subject.size = 0
subject.should be_valid
end
Expand Down

0 comments on commit f09ebf0

Please sign in to comment.