File: simple_spec.rb

package info (click to toggle)
ruby-mustermann19 0.4.3%2Bgit20160621-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 756 kB
  • ctags: 445
  • sloc: ruby: 7,197; makefile: 3
file content (32 lines) | stat: -rw-r--r-- 1,040 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'mustermann/router/simple'

describe Mustermann::Router::Simple do
  describe :initialize do
    context "with implicit receiver" do
      subject(:router) { Mustermann::Router::Simple.new { on('/foo') { 'bar' } } }
      example { router.call('/foo').should be == 'bar' }
    end

    context "with explicit receiver" do
      subject(:router) { Mustermann::Router::Simple.new { |r| r.on('/foo') { 'bar' } } }
      example { router.call('/foo').should be == 'bar' }
    end

    context "with default" do
      subject(:router) { Mustermann::Router::Simple.new(default: 'bar') }
      example { router.call('/foo').should be == 'bar' }
    end
  end

  describe :[]= do
    subject(:router) { Mustermann::Router::Simple.new }
    before { router['/:name'] = proc { |*a| a } }
    example { router.call('/foo').should be == ['/foo', "name" => 'foo'] }
  end

  describe :[] do
    subject(:router) { Mustermann::Router::Simple.new }
    before { router.on('/x') { 42 } }
    example { router['/x'].call.should be == 42 }
  end
end