Sha256: f7e1b3078802f0a7d81903a7dbac4e7866f431521529637d4a9ac24f141ceefe

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

# coding: UTF-8
require 'spec_helper'

describe Rescue::Controller::Action do

  let(:model) do # Stub of Model Class
    clazz = Class.new
    clazz.stub(:new).with(any_args()) do
      object = Object.new
      object.stub(:attributes=).and_return(true)
      object.stub(:save!).and_return(true)
      object.stub(:destroy).and_return(true)
      object
    end
    clazz.stub(:where).and_return(clazz)
    clazz.stub(:find).and_return(clazz.new)
    clazz
  end

  describe "#define" do
    let(:controller) do # Fake Controller
      clazz = model
      Class.new do
        Rescue::Controller::Action.define_call self, clazz, :@rescue
      end
    end
  
    let(:object) do
      object = controller.new
      object.stub(:rescuemodel_params).and_return({})
      object.stub(:params).and_return({})
      object
    end
  
    let(:params) { {} }
  
    [:find_call, :new_call, :create_call, :update_call, :destroy_call].each do |name|
      it "should be defined private method `#{name}`" do
        expect(controller.private_instance_methods.include? name).to be_true
      end
      it "should not raise error" do
        expect { object.send(name, params) }.not_to raise_error
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rescue-dog-0.3.4 spec/rescue/controllers/action_spec.rb