Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
graphql / spec / generators / graphql / interface_generator_spec.rb
Size: Mime:
# 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