From 745215936624d7145cbe2707d182e3c91df98d64 Mon Sep 17 00:00:00 2001 From: Moses Gathuku Date: Fri, 5 Apr 2024 11:13:47 +0300 Subject: [PATCH] Move movie.json to file fixtures & use file_fixture helper --- README.md | 8 ++++---- test/controllers/webhooks/movies_controller_test.rb | 4 ++-- test/fixtures/{ => files}/webhooks/movie.json | 0 3 files changed, 6 insertions(+), 6 deletions(-) rename test/fixtures/{ => files}/webhooks/movie.json (100%) diff --git a/README.md b/README.md index b285102..67f1024 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/test/controllers/webhooks/movies_controller_test.rb b/test/controllers/webhooks/movies_controller_test.rb index ffd7839..8140700 100644 --- a/test/controllers/webhooks/movies_controller_test.rb +++ b/test/controllers/webhooks/movies_controller_test.rb @@ -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 diff --git a/test/fixtures/webhooks/movie.json b/test/fixtures/files/webhooks/movie.json similarity index 100% rename from test/fixtures/webhooks/movie.json rename to test/fixtures/files/webhooks/movie.json