Class: Raccoon::Controller
- Inherits:
-
Object
- Object
- Raccoon::Controller
- Defined in:
- lib/raccoon/controller.rb
Instance Attribute Summary collapse
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
Class Method Summary collapse
Instance Method Summary collapse
- #add(router = nil, &block) ⇒ Object
-
#initialize(&proc) ⇒ Controller
constructor
A new instance of Controller.
Constructor Details
#initialize(&proc) ⇒ Controller
Returns a new instance of Controller.
7 8 9 |
# File 'lib/raccoon/controller.rb', line 7 def initialize &proc instance_eval &proc end |
Instance Attribute Details
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
5 6 7 |
# File 'lib/raccoon/controller.rb', line 5 def routes @routes end |
Class Method Details
.case(&block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/raccoon/controller.rb', line 33 def case &block new(&block).routes.each do |router| describe router.controller_class, type: :controller do render_views if ::Raccoon.config.render_views before do router.before.call end context "when requests #{router.method.to_s.upcase} #{router.controller}##{router.action}" do let(:params) { router.params.call } # Check HTTP Response Code it "should be #{Rack::Utils::HTTP_STATUS_CODES[router.response_code]}" do send(router.method, router.action, params) expect(response.response_code).to eq(router.response_code) end end after do router.after.call end end end end |