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

Move movie.json to file fixtures & use file_fixture helper #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,13 @@ First, let's create a JSON file to represent our webhook. If you have a lot of w
We'll start by creating a folder for our webhooks in `test/fixtures` and then create a JSON file for our Movie webhook.

```bash
mkdir test/fixtures/webhooks
mkdir test/fixtures/files/webhooks
```

And create a file for our Movie webhook.

```bash
touch test/fixtures/webhooks/movie.json
touch test/fixtures/files/webhooks/movie.json
```

```json
Expand All @@ -470,8 +470,8 @@ require 'test_helper'
class Webhooks::MoviesControllerTest < ActionDispatch::IntegrationTest
def setup
# Load the webhook data from the JSON file
file_path = Rails.root.join('test', 'fixtures', 'webhooks', 'movie.json')
@webhook = JSON.parse(File.read(file_path))
file_path = file_fixture('webhooks/movie.json')
@webhook = JSON.parse(file_path.read)
end

test 'should consume webhook' do
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/webhooks/movies_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
class Webhooks::MoviesControllerTest < ActionDispatch::IntegrationTest
def setup
# Load the webhook data from the JSON file
file_path = Rails.root.join('test', 'fixtures', 'webhooks', 'movie.json')
@webhook = JSON.parse(File.read(file_path))
file_path = file_fixture('webhooks/movie.json')
@webhook = JSON.parse(file_path.read)
end

test 'should consume webhook' do
Expand Down