Commit c9e2cb2

mo khan <mo.m.khan@shopify.com>
2020-12-23 23:44:27
test: start to test schema
1 parent ae339b9
Changed files (5)
bin/test
@@ -5,4 +5,8 @@ set -e
 cd "$(dirname "$0")/.."
 
 ./bin/setup
-bundle exec ruby -Ilib:test -r test_helper test/**/*.rb
+if [ $# -eq 0 ]; then
+  bundle exec ruby -Ilib:test -r test_helper test/**/*.rb
+else
+  bundle exec ruby -Ilib:test -r test_helper "$@"
+fi
lib/types/cake.rb
@@ -1,5 +1,7 @@
 module Types
   class Cake < GraphQL::Schema::Object
     field :name, String, null: false
+    #field :created_at, DateTime, null: false
+    #field :updated_at, DateTime, null: false
   end
 end
lib/types/query.rb
@@ -1,5 +1,10 @@
 module Types
+  class User < GraphQL::Schema::Object
+    field :username, String, null: false
+  end
+
   class Query < GraphQL::Schema::Object
+    #field :me, User, null: false
     field :me, String, null: false
     field :cakes, [Cake], null: false
 
test/integration/server_test.rb
@@ -14,7 +14,7 @@ class ServerTest < Minitest::Test
     refute_empty last_response.body
 
     json = JSON.parse(last_response.body)
-    assert_equal 'mo', json['data']['me']
+    assert_equal 'mo', json['data']['me']['name']
   end
 
   def test_get_graphql_with_post_body
test/unit/schema_test.rb
@@ -0,0 +1,9 @@
+
+class SchemaTest < Minitest::Test
+  def test_me
+    result = Schema.execute("{me}")
+
+    assert result
+    puts result.inspect
+  end
+end