Sha256: 4427ddcad4c7b325368faee0924bcc3c5b38d6a36a4e2d7fcca33f07a9bb1340
Contents?: true
Size: 1.49 KB
Versions: 9
Compression:
Stored size: 1.49 KB
Contents
require "spec_helper" describe "Jobs", feature: true do describe "GET /jobs" do let!(:response) { get "/jobs" } it "responds successfully" do expect(response.status).to eq 200 end it "exposes an array" do expect(JSON.parse(response.body)).to be_an_instance_of(Array) end end # GET /jobs describe "POST /jobs" do def jobs_list JSON.parse get("/jobs").body end context "when params are valid" do let(:params) do { source: "/tmp/foo", target: "/tmp/bar", } end it "issues a 201 response" do expect( post("/jobs", json: params).status, ).to eq 201 end it "exposes the new job id" do response = JSON.parse post("/jobs", json: params) expect(response["id"]).not_to be_nil end it "assigns a status" do response = JSON.parse post("/jobs", json: params) expect(response["status"]).to match(/^(queued|failed)$/) end it "creates a new job" do expect { post("/jobs", json: params) }.to change { jobs_list.size }.by(1) end end end # POST /jobs describe "GET /jobs/:id" do let(:creation_response) do JSON.parse post("/jobs", json: { source: "/tmp/foo", target: "/tmp/bar" }).body end let(:job_id) { creation_response.fetch("id") } it "is properly exposed" do expect( get("/jobs/#{job_id}").status, ).to eq 200 end end # GET /jobs/:id end
Version data entries
9 entries across 9 versions & 1 rubygems