Share
Embed
Extinguishing the Flame War on Quality and Automated Testing
Atomic Object
June 25, 2014
Transcript
25 slides
-
@atomicobject http://spin.atomicobject.com @AnthonySBaker Twitter : @AnthonySBaker http://spin.atomicobject.com Extinguishing The Flame
War On Quality And Automated Testing -
@atomicobject http://spin.atomicobject.com @AnthonySBaker class PeopleController < ApplicationController before_action :ensure_admin def
create @person = current_account.people.create!(people_params) WelcomeMailer.deliver_welcome(@person) respond_to do |format| format.html do redirect_to @person end format.json do render :show, status: :created, location: @person end end end end -
@atomicobject http://spin.atomicobject.com @AnthonySBaker class PeopleController < ApplicationController before_action :ensure_admin def
create @result = PersonCreateCommand.call(current_account, current_person, people_params) respond_to do |format| format.html do redirect_to @result.object end format.json do render :show, status: :created, location: @result.object end end end end -
@atomicobject http://spin.atomicobject.com @AnthonySBaker describe Api::V1::ThingController do before do inject_admin_token @user
= create(:user) end describe "GET 'index'" do it "returns http success when authenticated with a token" do get :index expect(response).to be_success end it "returns 401 unauthorized when not authenticated with a token" do @request.headers["Authorization"] = nil get :index expect(response.status).to eq(401) end it "returns 401 unauthorized when not authenticated as an admin" do inject_token(@user) get :index expect(response.status).to eq(401) end it "returns all of the things" do create_list(:thing, 5) get :index expect(json_response.length).to eq(5) end end end -
@atomicobject http://spin.atomicobject.com @AnthonySBaker 3 Takeaways Test From The Outside In
Test Should Support Your Development, Not Impede it -
@atomicobject http://spin.atomicobject.com @AnthonySBaker 3 Takeaways Test From The Outside In
Test Should Support Your Development, Not Impede it Be Pragmatic