Skip to content

Commit c73a756

Browse files
authored
Merge pull request #28 from cacheventures/update-readme
Update README
2 parents 0905ff4 + ffa2cee commit c73a756

File tree

1 file changed

+65
-6
lines changed

1 file changed

+65
-6
lines changed

README.md

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
Mongoid::Includes
2-
=====================
1+
# Mongoid::Includes
32

43
[![Gem Version](https://badge.fury.io/rb/mongoid_includes.svg)](https://rubygems.org/gems/mongoid_includes)
54
[![Build Status](https://github.com/cacheventures/mongoid_includes/workflows/CI/badge.svg)](https://github.com/cacheventures/mongoid_includes/actions)
65

76
`Mongoid::Includes` improves eager loading in Mongoid, supporting polymorphic associations, and nested eager loading.
87

9-
### Usage
8+
## Usage
109

1110
```ruby
1211
Album.includes(:songs).includes(:musicians, from: :band)
@@ -19,8 +18,10 @@ released_only = ->(albums) { albums.where(released: true) }
1918
Musician.includes(:band, with: ->(bands) { bands.limit(2).includes(:albums, with: released_only) })
2019
```
2120

22-
### Pro Tip
21+
## Pro Tip
22+
2323
Since you can modify the queries for the associations, you can use `only` and make your queries even faster:
24+
2425
```ruby
2526
Band.includes :musicians, with: ->(musicians) { musicians.only(:id, :name) }
2627
```
@@ -36,10 +37,10 @@ Band.includes :musicians, with: ->(musicians) { musicians.only(:id, :name) }
3637
Add this line to your application's Gemfile and run `bundle install`:
3738

3839
```ruby
39-
gem 'mongoid_includes'
40+
gem 'mongoid_includes'
4041
```
4142

42-
Or install it yourself running:
43+
Or install it yourself by running:
4344

4445
```sh
4546
gem install mongoid_includes
@@ -48,3 +49,61 @@ gem install mongoid_includes
4849
## License
4950

5051
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
52+
53+
## Running tests
54+
55+
To run the full test suite locally:
56+
57+
```sh
58+
bundle install
59+
bundle exec rspec
60+
# or use the bundled binary
61+
bin/rspec
62+
```
63+
64+
To run the tests against the Mongoid 8 matrix (this project provides a separate Gemfile at `gemfiles/mongoid8.gemfile`), set `BUNDLE_GEMFILE` to that file before installing or running the suite:
65+
66+
```sh
67+
# install gems for the mongoid8 Gemfile
68+
BUNDLE_GEMFILE=gemfiles/mongoid8.gemfile bundle install
69+
70+
# run the specs using that Gemfile
71+
BUNDLE_GEMFILE=gemfiles/mongoid8.gemfile bundle exec rspec
72+
# or
73+
BUNDLE_GEMFILE=gemfiles/mongoid8.gemfile bin/rspec
74+
```
75+
76+
If you only need to run a single spec file while using the alternate Gemfile, pass the path to `rspec` as usual, for example:
77+
78+
```sh
79+
BUNDLE_GEMFILE=gemfiles/mongoid8.gemfile bundle exec rspec spec/mongoid/includes/criteria_spec.rb
80+
```
81+
82+
## Contributing
83+
84+
Contributions are welcome. If you'd like to report a bug, suggest an improvement, or submit a patch, please follow these steps:
85+
86+
1. Fork the repository on GitHub.
87+
2. Create a feature branch from `master` (or from the branch you're targeting):
88+
89+
```sh
90+
git switch -c my-feature-branch
91+
```
92+
93+
3. Make your changes. Add or update tests when appropriate.
94+
4. Run the test suite locally to ensure everything passes:
95+
96+
```sh
97+
bundle install
98+
bundle exec rspec
99+
```
100+
101+
5. Commit your changes with a clear message and push your branch to your fork:
102+
103+
```sh
104+
git add -A
105+
git commit -m "Short, descriptive message"
106+
git push origin my-feature-branch
107+
```
108+
109+
6. Open a Pull Request against the `master` branch of this repository. In your PR description, explain the problem, what you changed, and any notes about compatibility or required steps.

0 commit comments

Comments
 (0)