Sha256: c1cfa18a9d84149c55fb9a804ba4f6ffd524eafd9f29d448afa926a1b5417d2c
Contents?: true
Size: 1.49 KB
Versions: 12
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
12 entries across 12 versions & 1 rubygems