Sha256: 39b56f9b75a5b7209d1fbc3412d74c6837a9ee0070c087f7c1ac13ce06358243
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
require 'helper' describe Toy::Object do uses_objects('User') subject { User.new } it_should_behave_like 'ActiveModel' it "adds model naming" do model_name = User.model_name model_name.should == 'User' model_name.singular.should == 'user' model_name.plural.should == 'users' end it "adds to_model" do user = User.new user.to_model.should == user end describe "#persisted?" do it "returns false" do User.new.persisted?.should be_false end end describe "#to_key" do it "returns [id] if persisted" do user = User.new user.stub(:persisted?).and_return(true) user.to_key.should == [user.id] end it "returns nil if not persisted" do User.new.to_key.should be_nil end end describe "#to_param" do it "returns key joined by - if to_key present" do user = User.new user.stub(:persisted?).and_return(true) user.to_param.should == user.to_key.join('-') end it "returns nil if to_key nil" do User.new.to_param.should be_nil end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
toystore-0.12.0 | spec/toy/object_spec.rb |
toystore-0.11.0 | spec/toy/object_spec.rb |