Sha256: 8d526ed9fe5a83d7500be57603269cf71070753a3717d8db25db211871c018ee

Contents?: true

Size: 831 Bytes

Versions: 3

Compression:

Stored size: 831 Bytes

Contents

require 'rails_helper'

module JpAddress
  RSpec.describe ZipcodesController, type: :controller do
    routes { JpAddress::Engine.routes }

    describe "GET #search" do
      it "returns http success" do
        get :search
        expect(response).to have_http_status(:success)
      end
      it "returns valid data when a vaild zip is passed" do
        create(:jp_address_zipcode)
        get :search, zip: '5330033'
        expect(response.body).to match '"zip":"5330033","prefecture":"大阪府","city":"大阪市東淀川区","town":"東中島"'
      end
      it "returns empty data when a invaild zip is passed" do
        create(:jp_address_zipcode)
        get :search, zip: '9999999'
        expect(response.body).to match '"id":null,"zip":null,"prefecture":null,"city":null,"town":null'
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jp_address-0.0.3 spec/controllers/jp_address/zipcodes_controller_spec.rb
jp_address-0.0.2 spec/controllers/jp_address/zipcodes_controller_spec.rb
jp_address-0.0.1 spec/controllers/jp_address/zipcodes_controller_spec.rb