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

(WIP) Refactor tests #108

Closed
wants to merge 13 commits into from
Closed

(WIP) Refactor tests #108

wants to merge 13 commits into from

Conversation

jrmhaig
Copy link
Collaborator

@jrmhaig jrmhaig commented Jul 20, 2021

Making the specs clearer by splitting them out into tests that each check a single thing. Ultimately, the goal is to remove spec/lib/amoeba_spec.rb while maintaining the same test coverage.

Some bugs have been discovered during this refactor; #106, #107

To do

  • Field preprocessing
  • has_many associations
  • has_many/through associations
  • has_one associations
  • has_one/through associations
  • many-to-many association copying or cloning
  • has_and_belongs_to_many associations
  • Single table inheritance
  • Inclusive, exclusive and indiscriminate styles
  • Recursive copying

@coveralls
Copy link

coveralls commented Jul 20, 2021

Coverage Status

Coverage increased (+0.1%) to 95.439% when pulling dc8541d on jrmhaig:new_tests into 99d0775 on amoeba-rb:master.

@jrmhaig jrmhaig force-pushed the new_tests branch 4 times, most recently from 4d8b586 to ba6be0d Compare July 25, 2021 15:45
@jrmhaig jrmhaig force-pushed the new_tests branch 3 times, most recently from 464c3db to 47000d9 Compare July 30, 2021 08:57
@jrmhaig jrmhaig force-pushed the new_tests branch 2 times, most recently from 4122db1 to 1c3f9ea Compare August 7, 2021 11:41
@jrmhaig jrmhaig force-pushed the new_tests branch 2 times, most recently from a135849 to 936771e Compare August 15, 2021 16:25
Basic tests for associations defined as:

```ruby
has_many :children_one
has_many :children_two, through: :join_table
```
When models are created fresh for each test the configuration may be cached by
ActiveSupport. This results in tests failing if they are executed after others
that use the same model names with different associations. The method for
caching this information was changed for Rails 7 meaning that is is no longer
necessary to explicitly clear the cache. The change was made here:

  rails/rails@14d4edd
These may be superfluous. It is effectively testing Amoeba on the intermediate
Child model rather than on the Parent table, which has the has_one/through
association.
To help with refactoring of the tests, `docs/associations.md` contains a table
showing which configuration options are covered in the spec files for each of
the association types:

* `has_one`
* `has_many`
* `has_and_belongs_to_many`
@jrmhaig
Copy link
Collaborator Author

jrmhaig commented Oct 1, 2023

Closing in favour of a more gradual approach.

@jrmhaig jrmhaig closed this Oct 1, 2023
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