spec/ballast/concerns/common_spec.rb in ballast-1.5.3 vs spec/ballast/concerns/common_spec.rb in ballast-1.6.0

- old
+ new

@@ -55,9 +55,21 @@ subject.perform_operation(OperationMockClass, c: 3, d: 4) expect(subject.instance_variable_get(:@operation)).to eq("OPERATION 2") end end + describe "#perform_operations_chain" do + it "should perform the requested operation chain and memoize it" do + expect(Ballast::OperationsChain).to receive(:perform).with("OWNER", [:a, :b], a: 1, b: 2).and_return("OPERATION 1") + expect(Ballast::OperationsChain).to receive(:perform).with(subject, [:c, :d], c: 3, d: 4).and_return("OPERATION 2") + + subject.perform_operations_chain([:a, :b], "OWNER", a: 1, b: 2) + expect(subject.instance_variable_get(:@operation)).to eq("OPERATION 1") + subject.perform_operations_chain([:c, :d], c: 3, d: 4) + expect(subject.instance_variable_get(:@operation)).to eq("OPERATION 2") + end + end + describe "#format_short_duration" do it "should format a date" do now = DateTime.civil(2013, 12, 9, 15, 6, 00) expect(subject.format_short_duration(DateTime.civil(2013, 12, 9, 16, 6, 0), now, "ago")).to eq("now") expect(subject.format_short_duration(DateTime.civil(2013, 12, 9, 15, 5, 58), now, "")).to eq("2s") \ No newline at end of file