Sha256: 4605187ba6dbfa5700129dbb2dfc2b9603d331e7f1a02437a9eff660c1d3a228
Contents?: true
Size: 1.67 KB
Versions: 3
Compression:
Stored size: 1.67 KB
Contents
# encoding: utf-8 require "spec_helper" module Okei describe "Find unit" do # ========================================================================== # Prepare context # ========================================================================== let!(:unit) { create :unit, code: "ТЫС М/С2" } let!(:text) { "километров в сек" } before do allow(Corrector::Parse).to receive(:new) do |str, scope:| (str == text) && (scope == "okei") ? unit.code : str end end # ========================================================================== # Prepare variables # ========================================================================== def call_request(text) get "okei/api/v1/units/search", text: text end # ========================================================================== # Run tests # ========================================================================== context "with proper text" do before { call_request text } it "responds with 200" do expect(response.status).to eq 200 end it "responds with proper json" do expect(response.body).to match_json_schema(:get_unit) end it "responds with requested unit" do received = JSON.parse(response.body)["unit"] expect(received["uuid"]).to eq unit.uuid end end context "with wrong text" do before { call_request "wrong text" } it "responds with 404" do expect(response.status).to eq 404 end it "responds with proper json" do expect(response.body).to match_json_schema(:get_errors) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
okei-1.0.2 | spec/requests/okei/api/v1/find_unit_spec.rb |
okei-1.0.1 | spec/requests/okei/api/v1/find_unit_spec.rb |
okei-1.0.0 | spec/requests/okei/api/v1/find_unit_spec.rb |