Sha256: e768789951497081f5124a1fa168fa5190707411bea95f736cbbc5014305c255

Contents?: true

Size: 806 Bytes

Versions: 9

Compression:

Stored size: 806 Bytes

Contents

# frozen_string_literal: true
require "spec_helper"
require "generators/graphql/function_generator"

class GraphQLGeneratorsFunctionGeneratorTest < BaseGeneratorTest
  tests Graphql::Generators::FunctionGenerator

  test "it generates an empty function by name" do
    run_generator(["FindRecord"])

    expected_content = <<-RUBY
class Functions::FindRecord < GraphQL::Function
  # Define `initialize` to store field-level options, eg
  #
  #     field :myField, function: Functions::FindRecord.new(type: MyType)
  #
  # attr_reader :type
  # def initialize(type:)
  #   @type = type
  # end

  # add arguments by type:
  # argument :id, !GraphQL::ID_TYPE

  # Resolve function:
  def call(obj, args, ctx)
  end
end
RUBY

    assert_file "app/graphql/functions/find_record.rb", expected_content
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
graphql-1.5.7.1 spec/generators/graphql/function_generator_spec.rb
graphql-1.5.10 spec/generators/graphql/function_generator_spec.rb
graphql-1.5.9 spec/generators/graphql/function_generator_spec.rb
graphql-1.5.8 spec/generators/graphql/function_generator_spec.rb
graphql-1.5.7 spec/generators/graphql/function_generator_spec.rb
graphql-1.5.6 spec/generators/graphql/function_generator_spec.rb
graphql-1.5.5 spec/generators/graphql/function_generator_spec.rb
graphql-1.5.4 spec/generators/graphql/function_generator_spec.rb
graphql-1.5.3 spec/generators/graphql/function_generator_spec.rb