Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Extinguishing the Flame War on Quality and Auto...

Extinguishing the Flame War on Quality and Automated Testing

Atomic Object

June 25, 2014
Tweet

More Decks by Atomic Object

Other Decks in Technology

Transcript

  1. @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
  2. @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
  3. @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
  4. @atomicobject http://spin.atomicobject.com @AnthonySBaker 3 Takeaways Test From The Outside In

    Test Should Support Your Development, Not Impede it Be Pragmatic