Sha256: 8ec6f63822ba3058c2402e9d5b74814853e4b56d8420323d5bfc2754ac94285e

Contents?: true

Size: 856 Bytes

Versions: 1

Compression:

Stored size: 856 Bytes

Contents

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

class GraphQLGeneratorsInterfaceGeneratorTest < BaseGeneratorTest
  tests Graphql::Generators::InterfaceGenerator

  test "it generates fields with types" do
    commands = [
      # GraphQL-style:
      ["Bird", "wingspan:Int!", "foliage:[Color]"],
      # Ruby-style:
      ["BirdType", "wingspan:Integer!", "foliage:[Types::ColorType]"],
      # Mixed
      ["BirdType", "wingspan:!Int", "foliage:[Color]"],
    ]

    expected_content = <<-RUBY
class Types::BirdType < Types::BaseInterface
  field :wingspan, Integer, null: false
  field :foliage, [Types::ColorType], null: true
end
RUBY

    commands.each do |c|
      prepare_destination
      run_generator(c)
      assert_file "app/graphql/types/bird_type.rb", expected_content
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graphql-1.8.2 spec/generators/graphql/interface_generator_spec.rb