2020-12-01から1ヶ月間の記事一覧
scopeみたいにフィルタリングした要素について、フィルタリング対象の要素について let(:included) { Item.new(price: 250) } let(:not_included) { Item.new(price: 300) } let(:array) { [included, not_included] } subject(array.filtering) it '250円以…
最近細かく引っかかっていたので。 URLヘルパのnew, editの修飾子は前に付く xxxx_new_pathかnew_xxxx_pathかよく迷っていたけど、 new_xxxx_path, edit_xxxx_path のほうが正解。namespaceで # routes.rb namespace 'admin' do resources xxxxs end となっ…
特定のオブジェクトにあるメソッドの中身を実行せず結果だけ返して欲しい場合 allowとreceiveを使ってスタブの指定をします。 allow(some_object).to receive(:method_name).and_return(return_value) 特定のクラスのインスタンス全てにあるメソッドの中身を…