spec/unit/model_spec.rb in evil-client-3.1.0 vs spec/unit/model_spec.rb in evil-client-3.2.0

- old
+ new

@@ -106,21 +106,43 @@ { first_name: "Joe", last_name: "Doe", email: "joe@example.com" } end subject { model } - it "behaves like a model" do - expect(subject).to be_a klass - expect(subject.email).to eq "joe@example.com" - end + context "with kwargs" do + let(:model) { klass.new(**options) } - it "injects options from the other model" do - expect(subject.first_name).to eq "Joe" - expect(subject.last_name).to eq "Doe" + it "behaves like a model" do + expect(subject).to be_a klass + expect(subject.email).to eq "joe@example.com" + end + + it "injects options from the other model" do + expect(subject.first_name).to eq "Joe" + expect(subject.last_name).to eq "Doe" + end + + it "injects memoizers from the other model" do + expect(subject.name).to eq "Joe Doe" + end end - it "injects memoizers from the other model" do - expect(subject.name).to eq "Joe Doe" + context "with hash argument" do + let(:model) { klass.new(options) } + + it "behaves like a model" do + expect(subject).to be_a klass + expect(subject.email).to eq "joe@example.com" + end + + it "injects options from the other model" do + expect(subject.first_name).to eq "Joe" + expect(subject.last_name).to eq "Doe" + end + + it "injects memoizers from the other model" do + expect(subject.name).to eq "Joe Doe" + end end context "with invalid options" do let(:options) { { email: "joe@example.com" } }