require "spec_helper" module <%= module_name %> describe <%= class_name %> do # ========================================================================== # Prepare environment # ========================================================================== # before { Timecop.freeze } # after { Timecop.return } # ========================================================================== # Prepare variables # ========================================================================== # let!(:params) { { key: value } } # let!(:expected_result) { { something.to_struct.inspect } } # 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 # let!(:use_case) { prepare_case params } # it "does something" do # expect { use_case.run }.to change { something } # .from(something).to(something) # end # it "returns something" do # expect(use_case.run.inspect).to eq expected_result # end # it "sends 'something' to subscribers" do # expect(listener).to receive :something do |result| # expect(result.inspect).to eq expected_result # end # use_case.run # end # end # context "with some improper params" do # before { params[:something] = something } # let!(:use_case) { prepare_case params } # it "doesn't do something" do # expect { use_case.run }.not_to change { something } # .from 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