Module: RSpec::Rails::Controller::Macros::ClassMethods

Defined in:
lib/rspec/rails/controller/macros.rb

Instance Method Summary collapse

Instance Method Details

#action!(&block) ⇒ Object



32
33
34
35
36
37
# File 'lib/rspec/rails/controller/macros.rb', line 32

def action!(&block)
  describe "action" do
    before(:each) { action! }
    instance_eval &block
  end
end

#params(params = {}, &block) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/rspec/rails/controller/macros.rb', line 39

def params(params = {}, &block)
  if block
    let(:params) { block }
  else
    let(:params) { params }
  end
end

#request(method, action, aparams = {}, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rspec/rails/controller/macros.rb', line 12

def request(method, action, aparams = {}, &block)
  description = "#{method.to_s.upcase} ##{action.to_s}"
  describe description do
    let(:params) { aparams }
    define_method :action! do
      p = params
      p = instance_eval(&p) if p.is_a?(Proc)
      send method, action, p
    end
    define_method(:run_request!) { action! } # deprecated
    instance_eval &block
  end
end

#request!(method, action, params = {}, &block) ⇒ Object



26
27
28
29
30
# File 'lib/rspec/rails/controller/macros.rb', line 26

def request!(method, action, params = {}, &block)
  request(method, action, params) do
    action! &block
  end
end