Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

response_data can't be used multiple times in 1 spec #15

Open
natematykiewicz opened this issue Jan 6, 2022 · 0 comments
Open

response_data can't be used multiple times in 1 spec #15

natematykiewicz opened this issue Jan 6, 2022 · 0 comments

Comments

@natematykiewicz
Copy link

The response_data helper is really nice, but since it uses add_helper, it's memoized. This is problematic because it's not memoized based on the arguments provided. If you use it multiple times in 1 spec, the subsequent calls don't return what you'd expect.

To work around this, we've added the following to our RSpec config to undo the memoization:

fix_response_data = Module.new do
  def response_data(*)
    raise 'Make sure this is still necessary' unless RSpec::GraphQLResponse::VERSION == '0.5.0'

    remove_instance_variable(:@response_data) if instance_variable_defined?(:@response_data)
    super
  end
end
config.prepend fix_response_data, type: :graphql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant