Sha256: b767dc76b24d8d25797fb9bcbfcb8caf8df7881db6fced626acac65a8f203f85

Contents?: true

Size: 996 Bytes

Versions: 1

Compression:

Stored size: 996 Bytes

Contents

require 'spec_helper'

# :nodoc:
module ControllerResources
  RSpec.describe Extension do
    # :nodoc:
    class MockController < ActionController::Base
      include Extension

      resource :model do |r|
        r.search :name
        r.modify :name, :password
      end
    end

    subject { MockController }

    let(:controller) { subject.new }

    let(:resource) { subject._resource }

    it 'defines a resource object' do
      expect(resource).to be_present
      expect(resource).to be_a(Resource)
    end

    it 'configures the resource object' do
      expect(resource.model_name).to eq(:model)
      expect(resource.collection_name).to eq(:models)
    end

    it 'saves params' do
      expect(resource.search_params).to eq([:name])
      expect(resource.edit_params).to eq([:name, :password])
    end

    it 'publishes params to instance method' do
      expect(controller).to respond_to(:search_params)
      expect(controller).to respond_to(:edit_params)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
controller_resources-0.0.6 spec/lib/controller_resources/extension_spec.rb