Skip to content

Commit

Permalink
Improve specs (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
tagliala authored Jan 20, 2025
1 parent 639ebf1 commit 4b89861
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions spec/lib/colore/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
require 'spec_helper'

RSpec.describe Colore::Client do
let(:client) { described_class.new app: 'client_test', base_uri: 'http://localhost:9240/' }
let(:client) { described_class.new app: app, base_uri: 'http://localhost:9240/' }
let(:filename) { fixture('quickfox.jpg') }
let(:app) { 'client_test' }

describe '.generate_doc_id' do
it 'runs' do
expect(described_class.generate_doc_id.to_s).not_to eq ''
expect(described_class.generate_doc_id).not_to be_empty
end
end

describe '#generate_doc_id' do
it 'runs' do
expect(client.generate_doc_id.to_s).not_to eq ''
expect(client.generate_doc_id).not_to be_empty
end
end

Expand Down Expand Up @@ -48,8 +49,8 @@
)
expect(rsp).not_to be_nil
expect(rsp['status']).to eq 201
expect(rsp['description'].to_s).not_to eq ''
expect(rsp['path'].to_s).not_to eq ''
expect(rsp['description']).not_to be_empty
expect(rsp['path']).to eq "/document/#{app}/#{doc_id}/#{Colore::CURRENT}/#{filename.basename}"
end

it 'fails if document exists' do
Expand Down Expand Up @@ -92,8 +93,8 @@
content: File.read(filename)
)
expect(rsp['status']).to eq 201
expect(rsp['description'].to_s).not_to eq ''
expect(rsp['path'].to_s).not_to eq ''
expect(rsp['description']).not_to be_empty
expect(rsp['path']).to eq "/document/#{app}/#{doc_id}/#{Colore::CURRENT}/#{filename.basename}"
end

it 'fails on an invalid doc_id' do
Expand All @@ -118,7 +119,7 @@
)
rsp = client.update_title(doc_id: doc_id, title: 'This is a new title')
expect(rsp['status']).to eq 200
expect(rsp['description'].to_s).not_to eq ''
expect(rsp['description']).not_to be_empty
end

it 'fails on an invalid doc_id' do
Expand All @@ -144,7 +145,7 @@
action: 'ocr'
)
expect(rsp['status']).to eq 202
expect(rsp['description'].to_s).not_to eq ''
expect(rsp['description']).not_to be_empty
end
end

Expand All @@ -159,7 +160,7 @@
)
rsp = client.delete_document(doc_id: doc_id)
expect(rsp['status']).to eq 200
expect(rsp['description'].to_s).not_to eq ''
expect(rsp['description']).not_to be_empty
end
end

Expand All @@ -179,7 +180,7 @@
)
rsp = client.delete_version(doc_id: doc_id, version: 'v001')
expect(rsp['status']).to eq 200
expect(rsp['description'].to_s).not_to eq ''
expect(rsp['description']).not_to be_empty
end

it 'refuses to delete the current version' do
Expand Down Expand Up @@ -234,7 +235,7 @@
)
rsp = client.get_document_info doc_id: doc_id
expect(rsp['status']).to eq 200
expect(rsp['description'].to_s).not_to eq ''
expect(rsp['description']).not_to be_empty
expect(rsp['current_version']).to eq 'v001'
expect(rsp['versions']).not_to be_nil
expect(rsp['title']).to eq 'Sample document'
Expand Down

0 comments on commit 4b89861

Please sign in to comment.