1
AnagramsControllerでshowアクションを実行する必要があるリクエスト仕様があります。私はのように見える私の要求仕様を実行
anagrams GET /anagrams(.:format) anagrams#show
仕様はRails APIプロジェクトのコントローラーアクションに当たっていません
:
これは私のルートファイルが
resources :anagrams, only: [] do get '/', to: 'anagrams#show', on: :collection end
どのようなものか、私は私のルートを熊手とき、私は私が私が欲しいのルートを持っていることがわかりますですこの
require "rails_helper"
RSpec.describe "Anagram API", type: :request do
describe "GET /anagrams" do
context "fetch for words with anagrams" do
it "finds the anagrams" do
get "/anagrams", params: {word: ["read"]}
expect(JSON.parse(response.body)).to eq(["dare", "dear"])
expect(response).to have_http_status(200)
end
end
end
end
は、私はテストが私のコントローラでshowアクションを打つことを期待
F
Failures:
1) Anagram API GET /anagrams fetch for words with anagrams finds the anagrams
Failure/Error: expect(JSON.parse(response.body)).to eq(["dare", "dear"])
JSON::ParserError:
757: unexpected token at '<!DOCTYPE html>
<html>
<head>
<title>SyntaxError at /anagrams</title>
</head>
<body>
<style>
/* Basic reset */
* {
margin: 0;
padding: 0; and on and on and on
私はコントローラでshowアクションでbinding.pryを持っており、スペックはてこに当たっていない:私はスペックを実行したときに
class AnagramsController < ApplicationController
def show
word_passed_in = params[:word].first
results = AnagramFinder.fetch_anagrams(word_passed_in)
end
json_response(results)
end
private
def anagram_params
params.require(:word)
end
end
はしかし、私はこれを参照してください。
うんであるべきです。それが問題でした!私は今恥ずかしい感じ!オースティオに感謝 – NicoleHall