Skip to content

Instantly share code, notes, and snippets.

View wichru's full-sized avatar

Maciej Wicher wichru

  • Cracow
View GitHub Profile
module Elders
class StaleFinder
class << self
def call
build
end
private
def build
class UserStocksController < ApplicationController
def create
@user_stock = UserStocksCreator.new(current_user, params, flash).call
redirect_to my_portfolio_path
end
def destroy
UserStocksDestroyer.new(current_user, params, flash).call
redirect_to my_portfolio_path
end
RSpec.describe AddAnswerToQuestion do
subject { described_class.new(questionnaire: questionnaire, question: question, answer: answer).call }
let(:questionnaire) { create(:questionnaire) }
let(:question) { create(:question) }
let(:answer) { create(:answer) }
context "when question is linked to the questionnaire" do
before { add_question_to_questionnaire(questionnaire, question) }
it { expect { subject }.not_to raise_error }
@wichru
wichru / rspec_model_testing_template.rb
Created September 18, 2018 11:08 — forked from PWSdelta/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems: