Sha256: 502e146be80b8b7c776d5a831e50ae0699f5a11fc4aead1f9b6e4360c6611fd8
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
require "spec_helper" # stand ins for Rails application controller # it is extended by the railtie class ActionController class Base; end end class ApplicationController < ActionController::Base include LayoutByAction::Able def self.layout(method); end end class YourController < ApplicationController; end module LayoutByAction describe YourController do let!(:layout_by_action) { { new: "alt_one", [:show, :index] => "alt_two" } } let!(:default) { nil } before { described_class.layout_by_action default, layout_by_action } it "should add layout_by_action to subclasses of application controller" do expect(described_class).to respond_to(:layout_by_action) end it "should provide the specified layout when a single action is used" do expect(subject.layout_by_action(:new)).to eq "alt_one" end it "should provide the right layout when an array of actions are used" do [:show, :index].each do |action| expect(subject.layout_by_action(action)).to eq "alt_two" end end context "when a default is provided" do let!(:default) { "default" } it "should use the default layout for an action not specified" do expect(subject.layout_by_action(:default)).to eq "default" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
layout_by_action-0.0.2 | spec/lib/layout_by_action/able_spec.rb |