Sha256: 25558063f1a08298527e104f3dfc5601b2e5dd6c5c581bd1f59ca91d9b8ee9b0
Contents?: true
Size: 1.85 KB
Versions: 1
Compression:
Stored size: 1.85 KB
Contents
# encoding: utf-8 require "spec_helper" module Okei describe "Find unit" do # ========================================================================== # Prepare context # ========================================================================== let!(:unit) { create :unit, code: "ТЫС ЧЕЛ-ЧАС" } before do { "1000" => "ТЫС", "ЧЕЛОВЕКО" => "ЧЕЛ", "ЧАСОВ" => "ЧАС", "ТЫС ЧЕЛ ЧАС" => "ТЫС ЧЕЛ-ЧАС" }.each { |synonym, text| create :word, synonym: synonym, text: text } 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 "1000 человеко-часов" } 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"] %w(uuid name code num int_code base factor measure) .each { |key| expect(received[key]).to eq unit.send(key) } end end context "with wrong text" do before { call_request "wrong" } 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
okei-0.0.2 | spec/requests/okei/api/v1/find_unit_spec.rb |