Class: ShouldaRouting::Routes::Spec

Inherits:
Object
  • Object
show all
Defined in:
lib/shoulda_routing/routes/spec.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionObject

Returns the value of attribute action.



5
6
7
# File 'lib/shoulda_routing/routes/spec.rb', line 5

def action
  @action
end

#controllerObject

Returns the value of attribute controller.



5
6
7
# File 'lib/shoulda_routing/routes/spec.rb', line 5

def controller
  @controller
end

#methodObject

Returns the value of attribute method.



5
6
7
# File 'lib/shoulda_routing/routes/spec.rb', line 5

def method
  @method
end

#paramsObject

Returns the value of attribute params.



5
6
7
# File 'lib/shoulda_routing/routes/spec.rb', line 5

def params
  @params
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/shoulda_routing/routes/spec.rb', line 5

def path
  @path
end

#viaObject

Returns the value of attribute via.



5
6
7
# File 'lib/shoulda_routing/routes/spec.rb', line 5

def via
  @via
end

Class Method Details

.execute {|generator| ... } ⇒ Object

Yields:

  • (generator)


22
23
24
25
26
# File 'lib/shoulda_routing/routes/spec.rb', line 22

def self.execute
  generator = self.new
  yield(generator) if block_given?
  generator.test!
end

Instance Method Details

#test!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/shoulda_routing/routes/spec.rb', line 7

def test!
  via         = @via        || :get
  path        = @path       || "/"
  controller  = @controller || ""
  action      = @action     || :index
  params      = @params     || {}
  method      = @method     || :to

  RSpec::Core::DSL.describe type: :routing do
    it "routes to #{path}" do
      expect(via => path).send method, route_to("#{controller}##{action}", params)
    end
  end
end