Sha256: af1a2dba6f5232cd45ec7b429a3a013deb90a9ed65152c338b1bd65955dc2897

Contents?: true

Size: 885 Bytes

Versions: 28

Compression:

Stored size: 885 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
module Types
  module BirdType
    include Types::BaseInterface
    field :wingspan, Integer, null: false
    field :foliage, [Types::ColorType], null: true
  end
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

28 entries across 28 versions & 1 rubygems

Version Path
graphql-1.8.18 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.9.11 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.9.10 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.9.9 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.9.8 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.9.7 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.9.6 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.9.5 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.9.4 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.9.3 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.9.2 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.8.17 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.8.16 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.9.1 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.9.0 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.8.15 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.9.0.pre4 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.8.14 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.9.0.pre3 spec/integration/rails/generators/graphql/interface_generator_spec.rb
graphql-1.9.0.pre2 spec/integration/rails/generators/graphql/interface_generator_spec.rb