yuki24 / artemis

Ruby GraphQL client on Rails that actually makes you more productive
MIT License
207 stars 14 forks source link

Multiple clients with same operation cause wrong fixtures to be used #72

Closed JanStevens closed 5 years ago

JanStevens commented 5 years ago

Hello,

When you have 2 clients with exactly the same operation the fixtures of the first client are only used. This is probably because of the following implementation https://github.com/yuki24/artemis/commit/e1f57f49ebb032553d7a6f70e48422fc9825c119 which does not keep track of the fixtures / client relation and only uses the name of the file to lookup fixtures (probably it should be client + name of file)

So when you have to clients with exactly the same query query_events and your fixutres are like this

fixtures/graphql/client_1/query_events.yml
fixtures/graphql/client_2/query_events.yml

Then when stubbing out client 2 using:

stub_graphql(Client2, :query_events).to_return(:client_2_response)

You get

Artemis::FixtureNotFound:
       Fixture `client_2_response' not found in spec/fixtures/graphql/client_1/query_events.yml
JanStevens commented 5 years ago

Ha found the issue, in find_fixture_set downcase is used but if you have a camelCase class name it should be underscore so it matches class name file name convension

'UniverseClient'.downcase => 'universeclient'

vs

'UniverseClient'.underscore => 'universe_client'
yuki24 commented 5 years ago

Good catch! Thanks for reporting. I'll fix that later tonight.

yuki24 commented 5 years ago

fixed and released as v0.5.2.