require "spec_helper" module <%= module_name %> describe <%= class_name %> do # ========================================================================== # Prepare context # ========================================================================== # let!(:something) { create :something } # ========================================================================== # Prepare variables # ========================================================================== # let!(:params) { { key: value } } # let(:listener) { double "listener" } # def prepare_case(params) # use_case = <%= class_name %>.new params # use_case.subscribe(listener) # use_case # end # ========================================================================== # Run tests # ========================================================================== describe "#run" do # context "with proper params" do # subject(:use_case) { prepare_case params } # it "does something" do # expect { use_case.run }.to change { something }.to(something) # end # it "returns something" do # expect(use_case.run).to eq expected_result # end # it "sends 'something' to subscribers" do # expect(listener).to receive :something do |result, messages| # expect(result).to eq expected_result # expect(messages).not_to be_blank # end # use_case.run # end # end # context "with improper params" do # before { params[:something] = something } # subject(:use_case) { prepare_case params } # it "doesn't do something" do # expect { use_case.run }.not_to change { something } # end # it "returns nil" do # expect(use_case.run).to be_nil # end # it "sends 'error' to subscribers" do # expect(listener).to receive :error do |messages| # expect(messages).not_to be_blank # end # use_case.run # end # end end end end