spec/unit/key/association_spec.rb in rest_model-0.2.1 vs spec/unit/key/association_spec.rb in rest_model-0.2.3

- old
+ new

@@ -1,69 +1,45 @@ require 'spec_helper' describe RestModel::Association do describe "#initialize" do - context "class_name" do - context "when class_name option is passed" do + context "options[:class_name]" do + context "when it's passed" do subject do RestModel::Association.new(:login, class_name: :some_class) end - it "sets passed class_name" do + it "sets class_name" do subject.instance_variable_get("@class_name").should == "SomeClass" end end - context "when class_name option is not passed" do + context "when it isn't passed" do subject {RestModel::Association.new(:login)} - it "sets default class_name" do + it "uses default class_name" do subject.instance_variable_get("@class_name").should == "Login" end end end - context "many" do - context "when many option is passed with true" do - subject do - RestModel::Association.new(:login, many: true) - end - - it "returns false to one?" do - subject.one?.should be_false - end - - it "returns true to many?" do - subject.many?.should be_true - end + context "options[:many]" do + context "when it's true" do + subject {RestModel::Association.new(:login, many: true)} + its(:one?) {should be_false} + its(:many?) {should be_true} end - context "when many option is passed with false" do - subject do - RestModel::Association.new(:login, many: false) - end - - it "returns true to one?" do - subject.one?.should be_true - end - - it "returns false to many?" do - subject.many?.should be_false - end + context "when it's false" do + subject {RestModel::Association.new(:login, many: false)} + its(:one?) {should be_true} + its(:many?) {should be_false} end - context "when many option is not passed" do - subject do - RestModel::Association.new(:login) - end - - it "returns true to one?" do - subject.one?.should be_true - end - - it "returns false to many?" do - subject.many?.should be_false - end + context "when it isn't passed" do + subject {RestModel::Association.new(:login)} + its(:one?) {should be_true} + its(:many?) {should be_false} end end end end