Sha256: 4505503f52dd9e1983405f3f99043dcb3d83ffab934f17c7ff5e482b1ccda8ff

Contents?: true

Size: 1.46 KB

Versions: 9

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

require 'rails_helper'
require 'json'

RSpec.describe <%= controller_class_name %>Controller do
  let(:params) { {} }
  let(:json_response) { JSON.parse(response.body, symbolize_names: true) }
  
  describe 'GET #index' do
    let!(:<%= controller_class_name.singularize.underscore %>) { create(:<%= controller_class_name.singularize.underscore %>) }
    before(:each) { get :index, params: params }
    
    context 'ok' do
      it { expect(json_response[0][:id]).to eq <%= controller_class_name.singularize.underscore %>.id }               
      it { expect(response.status).to eq 200 }
    end
  end
  
  describe 'GET #show' do
    let(:<%= controller_class_name.singularize.underscore %>) { create(:<%= controller_class_name.singularize.underscore %>) }
    let(:params) { { id: <%= controller_class_name.singularize.underscore %>.id } }
    before(:each) { get :show, params: params }
    
    context 'ok' do                
      it { expect(response.status).to eq 200 }
    end
  end
  
  describe 'POST #create' do
    let(:payload_params) { {text: 'OK'} }
    let(:params) { { payload: payload_params, binaries: [{identifier: 'record', mimetype: 'video/mp4'}] } }
    before(:each) { post :create, params: params }
    
    context 'ok' do
      it { expect(<%= controller_class_name.singularize %>.count).to eq 1 }          
      it { expect(response.status).to eq 201 }
      it { expect(json_response[:binary_urls]).to_not be_nil }
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mobile_workflow-0.5.7 lib/generators/mobile_workflow/templates/controller_spec.rb.erb
mobile_workflow-0.5.6 lib/generators/mobile_workflow/templates/controller_spec.rb.erb
mobile_workflow-0.5.5 lib/generators/mobile_workflow/templates/controller_spec.rb.erb
mobile_workflow-0.5.4 lib/generators/mobile_workflow/templates/controller_spec.rb.erb
mobile_workflow-0.5.3 lib/generators/mobile_workflow/templates/controller_spec.rb.erb
mobile_workflow-0.5.2 lib/generators/mobile_workflow/templates/controller_spec.rb.erb
mobile_workflow-0.5.1 lib/generators/mobile_workflow/templates/controller_spec.rb.erb
mobile_workflow-0.5.0 lib/generators/mobile_workflow/templates/controller_spec.rb.erb
mobile_workflow-0.4.0 lib/generators/mobile_workflow/templates/controller_spec.rb.erb