Last active
October 12, 2023 18:22
-
-
Save Lucas-Barret/b3db09d231165703e5f31ba52487ec60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/inline' | |
gemfile(true) do | |
source 'https://rubygems.org' | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem 'graphql' | |
gem 'minitest' | |
end | |
require 'minitest/autorun' | |
class SchemaTest < GraphQL::Schema | |
class Testable < GraphQL::Schema::Object | |
field :tested, Boolean | |
end | |
class Query < GraphQL::Schema::Object | |
field :testable, Testable , null: true | |
def testable | |
{ tested: true } | |
end | |
end | |
query(Query) | |
end | |
class TestMeme < Minitest::Test | |
def setup | |
@query = <<-GQL | |
{ | |
testable { | |
name | |
} | |
} | |
GQL | |
end | |
def test_that_kitty_can_eat | |
assert_equal SchemaTest.execute(@query).to_h.dig('data','testable'), {"tested"=>true} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment