Skip to content

Instantly share code, notes, and snippets.

@naichilab
Last active January 21, 2016 11:40
Show Gist options
  • Save naichilab/5f250a5f90c9d7d28ca0 to your computer and use it in GitHub Desktop.
Save naichilab/5f250a5f90c9d7d28ca0 to your computer and use it in GitHub Desktop.
ラムダ式で定義しておいて、callで呼び出す方法
context '有効なパラメータの場合' do
let(:create_user) { -> { post :create, user: attributes_for(:user) } }
it 'リクエストは302 リダイレクトとなること' do
create_user.call
expect(response.status).to eq 302
end
it 'データベースに新しいユーザーが登録されること' do
expect{
create_user.call
}.to change(User, :count).by(1)
end
it 'rootにリダイレクトすること' do
create_user.call
expect(response).to redirect_to root_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment