Sha256: d7c03af05d9c2dac48673d6f7d051c7cb6fe9d9fd9ab51ac656f095af88b3ecd

Contents?: true

Size: 798 Bytes

Versions: 22

Compression:

Stored size: 798 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, !types.ID

  # 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

22 entries across 22 versions & 1 rubygems

Version Path
graphql-1.5.12 spec/generators/graphql/function_generator_spec.rb
graphql-1.5.11 spec/generators/graphql/function_generator_spec.rb