0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ArgumentError、Failure/Error httpリクエスト

Posted at
RSpec.describe UsersController,type: :controller do
...
    it "user/newページがレンダリングされる", :new do
      get "new"
      expect(response.body).to render_template(:new)
    end
....
  end
end

get "/example"で失敗しました。

exampleグループ(つまりdescribe or contextブロック)上でgetは使用可能ではありません。それぞれのexample(つまりitブロック)またはexampleのスコープ内の実行されるコンストラクトからしか利用できません。

Failure/Error: get "/example"
  `get` is not available on an example group (e.g. a `describe` or `context` block). It is only available from within individual examples (e.g. `it` blocks) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc).
RSpec.describe UsersController,type: :controller do
  render_views
    # createアクション
  describe "newアクション" do
    before(:new) do # :newからスコープを決める:exampleへ変更して解決
      get "new"
    end
   
    .....
  end
end

引数のエラー

フックに対してメタデータとしてシンボルを使ってスコープ (example, context)またはスコープエイリアス(each, all)を明示的に与えなければならない。

ArgumentError:
  You must explicitly give a scope (example, context) or scope alias (each, all) when using symbols as metadata for a hook.

注意::example:contextスコープはそれぞれ:each:allとして利用可能です。好きな方を使って下さい

Note: the :example and :context scopes are also available as :each and :all, respectively. Use whichever you prefer.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?