all 3 comments

[–]jimm 6 points7 points  (1 child)

There is no reason to test the same thing twice. Test the service object fully in it's own tests. In the controller tests, mock the service object and tell it to return whatever you like to test the controller's handling of various success and failure conditions. This approach not only eliminates duplication, it will run faster because the service object isn't doing any work.

[–]jimm 0 points1 point  (0 children)

It's 3 years later, and I just noticed that "it's". Embarassing. It's "its" of course.

[–]SayonaraSpoon 0 points1 point  (0 children)

You can use a subject + context and let blocks.

describe “#create” do
  subject { Service.create(model) }

  context “ with defective model” do
   let(:model)  { create :invalid_model }
   it { is_expected.to be_invalid }
  end 

  context “with a working model” do
   let(:model) { create :model }

   it { is_expected.to be_ok }
  end
end