Sha256: 641a6b2a5e518a063a4e782bf011d043f1e9bdf60e00ee23ee59ca8ed26ff1cc

Contents?: true

Size: 1.4 KB

Versions: 6

Compression:

Stored size: 1.4 KB

Contents

require "spec_helper"
require "fx/function"

module Fx
  describe Function do
    describe "#<=>" do
      it "delegates to `name`" do
        function_a = Function.new(
          "name" => "name_a",
          "definition" => "some defintion",
        )
        function_b = Function.new(
          "name" => "name_b",
          "definition" => "some defintion",
        )
        function_c = Function.new(
          "name" => "name_c",
          "definition" => "some defintion",
        )

        expect(function_b).to be_between(function_a, function_c)
      end
    end

    describe "#==" do
      it "compares `name` and `definition`" do
        function_a = Function.new(
          "name" => "name_a",
          "definition" => "some defintion",
        )
        function_b = Function.new(
          "name" => "name_b",
          "definition" => "some other defintion",
        )

        expect(function_a).not_to eq(function_b)
      end
    end

    describe "#to_schema" do
      it "returns a schema compatible version of the function" do
        function = Function.new(
          "name" => "uppercase_users_name",
          "definition" => "CREATE OR REPLACE TRIGGER uppercase_users_name ...",
        )

        expect(function.to_schema).to eq <<-EOS
  create_function :uppercase_users_name, sql_definition: <<-\SQL
      CREATE OR REPLACE TRIGGER uppercase_users_name ...
  SQL
        EOS
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fx-0.6.2 spec/fx/function_spec.rb
fx-0.6.1 spec/fx/function_spec.rb
fx-0.6.0 spec/fx/function_spec.rb
fx-0.5.0 spec/fx/function_spec.rb
fx-0.4.0 spec/fx/function_spec.rb
fx-0.3.1 spec/fx/function_spec.rb