Sha256: 9828dcafc0d5d7acdf5dc1d2144db6b2b412fe11f0c51a2ea17738aa584c8e67

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 KB

Contents

require "spec_helper"

module Chanko
  describe Controller do
    describe ".unit_action" do
      let(:controller_class) do
        Class.new(ActionController::Base) do
          include Chanko::Controller
          unit_action(:example_unit, :test)
          unit_action(:example_unit, :foo, :bar)
          unit_action(:example_unit, :error)
          ext_action(:example_unit, :alias)

          def head(code)
            "Bad Request #{code}"
          end
        end
      end

      let(:controller) do
        controller_class.new
      end

      it "defines an action to invoke unit function" do
        controller.test.should == "test"
      end

      it "defines 2 actions at one line" do
        controller.foo.should == "foo"
        controller.bar.should == "bar"
      end

      it "is aliased with `ext_action`" do
        controller.alias.should == "alias"
      end

      context "when invoke is fallen back" do
        it "halts with 400 status code" do
          controller.error.should == "Bad Request 400"
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
chanko-2.0.6 spec/chanko/controller_spec.rb
chanko-2.0.5 spec/chanko/controller_spec.rb
chanko-2.0.4 spec/chanko/controller_spec.rb
chanko-2.0.3 spec/chanko/controller_spec.rb
chanko-2.0.2 spec/chanko/controller_spec.rb
chanko-2.0.1 spec/chanko/controller_spec.rb
chanko-2.0.0 spec/chanko/controller_spec.rb