describe Celsius::Transformation do describe ".require_directory" do it "requires all *.rb files in the given directory" do described_class.require_directory "#{File.dirname(__FILE__)}/../assets/transformation" expect(defined?(SomeClass)).to eq("constant") end end describe "#sequence" do let(:steps_array) do [ -> { } ] end let(:transformation) do steps = steps_array Class.new(described_class) do sequence steps end end it "is a wrapper for the steps setter" do expect(transformation.steps).to be(steps_array) end end describe "#apply" do let(:transformation) do step_class = Class.new(described_class::Step) do def call transformation.target = source.dup end end step_lambda = -> (transformation) do transformation.target.upcase! end Class.new(described_class) do sequence [ step_class, step_lambda ] end.new end context "if no :source or :to option is given" do it "raises an error" do expect { transformation.apply }.to raise_error(ArgumentError) end end it "applies the transformation" do some_string = "foo" expect(transformation.apply(to: some_string)).to eq(some_string.upcase) expect(some_string).to eq("foo") end end end