Skip to content

Commit

Permalink
Add block tests for as and prepare
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Gehrke committed Jun 28, 2017
1 parent fccbcc0 commit ad2d2af
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/graphql/argument_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@
arg_3 = arg_2.redefine { as :ff }
assert_equal arg_3.expose_as, "ff"
end

it "can be set in the passed block" do
argument = GraphQL::Argument.define do
name "arg"
as "arg_name"
end
assert_equal "arg_name", argument.as
end
end

describe "prepare" do
Expand All @@ -69,5 +77,14 @@
argument = GraphQL::Argument.define(name: :someNumber, type: GraphQL::INT_TYPE)
assert_equal argument.prepare(1, nil), 1
end

it "can be set in the passed block" do
prepare_proc = Proc.new { |arg, ctx| arg + ctx[:val] }
argument = GraphQL::Argument.define do
name "arg"
prepare prepare_proc
end
assert_equal argument.prepare(1, {val: 1}), 2
end
end
end

0 comments on commit ad2d2af

Please sign in to comment.