Sha256: d79a35336f02e6dbe4dfd6af64d16d5bf9a02a3c174dbe642373b7d7de6a64c2

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe ColorsController, :type => :controller do

  it "should allow multiple .power directives" do
    controller.stub :current_power => Power.new(:red => true, :blue => false)
    expect { get :show, :id => '1' }.to raise_error(Consul::Powerless)
    controller.stub :current_power => Power.new(:red => false, :blue => true)
    expect { get :show, :id => '1' }.to raise_error(Consul::Powerless)
    controller.stub :current_power => Power.new(:red => true, :blue => true)
    expect { get :show, :id => '1' }.to_not raise_error
  end

  it 'should be able to map multiple powers to methods' do
    controller.stub :current_power => Power.new(:red => true, :blue => false)
    controller.send(:red_scope).should == 'red'
    controller.send(:blue_scope).should be_nil
    controller.stub :current_power => Power.new(:red => false, :blue => true)
    controller.send(:red_scope).should be_nil
    controller.send(:blue_scope).should == 'blue'
  end

  it 'should make a mapped power method private' do
    controller.stub :current_power => Power.new
    expect { controller.red_scope }.to raise_error(NoMethodError)
    expect { controller.send(:red_scope) }.to_not raise_error
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
consul-0.12.2 spec/shared/consul/controllers/colors_controller_spec.rb
consul-0.12.1 spec/shared/consul/controllers/colors_controller_spec.rb
consul-0.12.0 spec/shared/consul/controllers/colors_controller_spec.rb
consul-0.11.2 spec/shared/consul/controllers/colors_controller_spec.rb
consul-0.11.1 spec/shared/consul/controllers/colors_controller_spec.rb
consul-0.11.0 spec/shared/consul/controllers/colors_controller_spec.rb
consul-0.10.2 spec/shared/consul/controllers/colors_controller_spec.rb
consul-0.10.1 spec/shared/consul/controllers/colors_controller_spec.rb
consul-0.10.0 spec/shared/consul/controllers/colors_controller_spec.rb