README.md in rspec-graphql_matchers-0.5 vs README.md in rspec-graphql_matchers-0.6

- old
+ new

@@ -10,10 +10,11 @@ ## Usage The matchers currently supported are: - `expect(a_graphql_object).to have_a_field(field_name).that_returns(valid_type)` + - `expect(a_graphql_object).to interface(interface_name, ...)` - `expect(a_mutation_type).to have_a_return_field(field_name).returning(valid_type)` - `expect(a_mutation_type).to have_an_input_field(field_name).of_type(valid_type)` - `expect(a_field).to be_of_type(valid_type)` - `expect(an_input).to accept_arguments(hash_of_arg_names_and_valid_types)` - `expect(an_input).to accept_arguments(hash_of_arg_names_and_valid_types)` @@ -31,10 +32,12 @@ PostType = GraphQL::ObjectType.define do name "Post" description "A blog post" + interfaces [GraphQL::Relay::Node.interface] + field :id, !types.ID field :comments, !types[types.String] field :subposts, PostType do @@ -104,15 +107,10 @@ it { is_expected.to be_of_type('[String]!') } end end ``` -Having to define `types` everywhere is quite annoying. If you prefer, you can -just `include RSpec::GraphqlMatchers::TypesHelper` once -(for example in your `spec_helper.rb`) -and the `types` shortcut will be available within the include context. - ### 3) Test the arguments accepted by a field with `accept_arguments` matcher: ```ruby describe PostType do describe 'subposts' do @@ -130,10 +128,24 @@ it { is_expected.not_to accept_arguments(a_whole_bunch_of_args) } end end ``` +### 4) Test an object's interface implementations: + +```ruby +describe PostType do + it 'interfaces Node' do + expect(subject).to implement('Node') + end + + # Accepts arguments as an array and type objects directly + it { is_expected.to implement(GraphQL::Relay::Node.interface) } + it { is_expected.not_to implement('OtherInterface') } +end +``` + The spec will only pass if all attributes/types specified in the hash are defined on the field. For better fluency, `accept_arguments` is also available in singular form, as `accept_argument`. @@ -154,8 +166,7 @@ contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. ## License -The gem is available as open source under the terms of the +The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). -