Sha256: 1b082e46b8c71904f1b577f414b7cc1ad027dec933fe3557065de26dca42a6cc

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'
module Marty
  RSpec.describe DiagnosticController, type: :controller do
    before(:each) { @routes = Marty::Engine.routes }
    let(:json_response) { JSON.parse(response.body) }

    describe 'GET #op' do
      it 'returns http success' do
        get :op, format: :json, op: 'version'
        expect(response).to have_http_status(:success)
      end

      it 'a request injects the request object into Diagnostic classes' do
        get :op, format: :json, op: 'version'
        expect(Diagnostic::Reporter.request).not_to eq(nil)
      end

      it 'returns the current version JSON' do
        get :op, format: :json, op: 'version', data: 'true'

        # generate version data and declare all values consistent
        versions = Diagnostic::Version.generate.each_with_object({}){
          |(n, v),h|
          h[n] = v.each{|t, r| r['consistent'] = true}
        }

        expected = {
          'data' => {
            'Diagnostic::Version' => versions
          }
        }

        expect(assigns('result')).to eq(expected)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
marty-1.1.8 spec/controllers/diagnostic_controller_spec.rb
marty-1.1.7 spec/controllers/diagnostic_controller_spec.rb
marty-1.1.6 spec/controllers/diagnostic_controller_spec.rb