Skip to content

Commit

Permalink
Document how to disable Fixtures (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspth and tcannonfodder authored Dec 18, 2024
1 parent 5623b8c commit 9234cd2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Oaken is a new take on development and test data management for your Rails app. It blends the stability and storytelling from Fixtures with the dynamicness of FactoryBot/Fabricator.

> But seriously; Oaken is one of the single greatest tools I've added to my belt in the past year
>
>
> It's made cross-environment shared data, data prepping for demos, edge-case tests, and overall development much more reliable & shareable across a team
> [@tcannonfodder](https://github.com/tcannonfodder)
Expand Down Expand Up @@ -129,6 +129,25 @@ You can convert your Rails fixtures to Oaken's seeds by running:

This will convert anything in test/fixtures to db/seeds. E.g. `test/fixtures/users.yml` becomes `db/seeds/users.rb`.

### Disable fixtures

IF you've fully converted to Oaken you may no longer want fixtures when running Rails' generators,
so you can disable generating them in `config/application.rb` like this:

```ruby
module YourApp
class Application < Rails::Application
# We prefer Oaken to fixtures, so we disable them here.
config.app_generators { _1.test_framework _1.test_framework, fixture: false }
end
end
```

The `test_framework` repeating is to preserve `:test_unit` or `:rspec` respectively.

> [!NOTE]
> If you're using `FactoryBot` as well, you don't need to do this since it already replaces fixtures for you.
## Installation

Install the gem and add to the application's Gemfile by executing:
Expand Down
8 changes: 5 additions & 3 deletions lib/oaken/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class Oaken::Railtie < Rails::Railtie
initializer "oaken.lookup_paths" do
Oaken.lookup_paths << "db/seeds/#{Rails.env}"
module Oaken
class Railtie < Rails::Railtie
initializer "oaken.lookup_paths" do
Oaken.lookup_paths << "db/seeds/#{Rails.env}"
end
end
end
2 changes: 2 additions & 0 deletions test/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ class Application < Rails::Application
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")

config.app_generators { _1.test_framework _1.test_framework, fixture: false }
end
end

0 comments on commit 9234cd2

Please sign in to comment.