spec/unit/proxyable_spec.rb in couchrest_model-1.2.0.beta vs spec/unit/proxyable_spec.rb in couchrest_model-2.0.0.beta

- old
+ new

@@ -33,11 +33,10 @@ end it "should raise an error if called and no proxy_database_method set" do lambda { @obj.proxy_database }.should raise_error(StandardError, /Please set/) end - end describe "class methods" do @@ -72,10 +71,15 @@ it "should be provided" do @class.should respond_to(:proxy_for) end + it "should add model name to proxied model name array" do + @class.proxy_for(:cats) + @class.proxied_model_names.should eql(['Cat']) + end + it "should create a new method" do DummyProxyable.stub!(:method_defined?).and_return(true) DummyProxyable.proxy_for(:cats) DummyProxyable.new.should respond_to(:cats) end @@ -138,9 +142,29 @@ it "should overwrite the database method to provide an error" do @class.proxied_by(:company) lambda { @class.database }.should raise_error(StandardError, /database must be accessed via/) end end + + describe ".proxied_model_names" do + before do + @class = Class.new(CouchRest::Model::Base) + end + + it "should respond to proxied_model_names" do + @class.should respond_to(:proxied_model_names) + end + + it "should provide an empty array" do + @class.proxied_model_names.should be_empty + end + + it "should accept new entries" do + @class.proxied_model_names << 'Cat' + @class.proxied_model_names.first.should eql('Cat') + end + end + end describe "ModelProxy" do before :all do