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

Improve testing modes #26

Merged
merged 2 commits into from
Jun 28, 2022
Merged

Improve testing modes #26

merged 2 commits into from
Jun 28, 2022

Conversation

thomasleese
Copy link
Contributor

@thomasleese thomasleese commented Jun 28, 2022

This makes two changes to the built-in testing modes to make them easier to use:

  • Fixes a bug where fake! currently doesn't work as the stubbed insert method has the wrong signature.
  • Adds a paragraph in the documentation explaining how to use the testing modes.

The stub client, used in the fake testing mode, currently doesn't work
as it's defined as only taking one argument, but in reality this method
should accept two. Rather than hard coding the two arguments, I've
defined it to accept any number of arguments.

I've also added a test to avoid this issue from coming up again. I think
it was 02dc49c which introduced this
bug when using the fake testing mode.
This will mean users of this library have a better understanding of the
testing modes available and how to use them.
thomasleese added a commit to DFE-Digital/apply-for-qualified-teacher-status that referenced this pull request Jun 28, 2022
This changes the way we disable DfE Analytics in our tests by using the
built-in DfE Analytics fake testing mode.

Note that this depends on
DFE-Digital/dfe-analytics#26.
thomasleese added a commit to DFE-Digital/apply-for-qualified-teacher-status that referenced this pull request Jun 28, 2022
This changes the way we disable DfE Analytics in our tests by using the
built-in DfE Analytics fake testing mode.

Note that this depends on
DFE-Digital/dfe-analytics#26.
it 'does not go out to the network' do
request = stub_analytics_event_submission

DfE::Analytics::Testing.fake! do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block isn't necessary as it's the default state, set in the body of the Testing module (also a la sidekiq) — could rename spec and/or add something to the docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's true that this is default, but I wanted this test to be explicit in case that changes in the future. It's clear that whatever might change around this test, we're at least using the fake testing mode in it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I'm with you

Copy link
Contributor

@duncanjbrown duncanjbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @thomasleese!

@duncanjbrown duncanjbrown merged commit b165b4e into DFE-Digital:main Jun 28, 2022
thomasleese added a commit to DFE-Digital/apply-for-qualified-teacher-status that referenced this pull request Jun 30, 2022
This changes the way we disable DfE Analytics in our tests by using the
built-in DfE Analytics fake testing mode.

Note that this depends on
DFE-Digital/dfe-analytics#26.
thomasleese added a commit to DFE-Digital/apply-for-qualified-teacher-status that referenced this pull request Jun 30, 2022
This changes the way we disable DfE Analytics in our tests by using the
built-in DfE Analytics fake testing mode.

Note that this depends on
DFE-Digital/dfe-analytics#26.
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

Successfully merging this pull request may close these issues.

2 participants