|
3 | 3 | require 'spec_helper'
|
4 | 4 |
|
5 | 5 | describe "recognize-path" do
|
6 |
| - before do |
7 |
| - FooController = Class.new(ActionController::Base) |
8 |
| - BoomsController = Class.new(ActionController::Base) |
9 |
| - routes = Rails.application.routes |
10 |
| - routes.draw { |
11 |
| - root(:to => 'foo#index', :constraints => {:host => 'example.com'}) |
12 |
| - resources :booms |
13 |
| - } |
14 |
| - routes.finalize! |
15 |
| - end |
16 |
| - |
17 |
| - after do |
18 |
| - [:FooController, :BoomsController].each { |const| |
19 |
| - Object.__send__(:remove_const, const) |
20 |
| - } |
21 |
| - end |
22 |
| - |
23 | 6 | it 'fails gracefully if no path is given' do
|
24 | 7 | output = mock_pry('recognize-path', 'exit-all')
|
25 | 8 | _(output).must_match \
|
|
28 | 11 |
|
29 | 12 | it "prints info about controller/action that is bound to the given path" do
|
30 | 13 | output = mock_pry('recognize-path example.com', 'exit-all')
|
31 |
| - _(output).must_match(/controller.+foo/) |
| 14 | + _(output).must_match(/controller.+cars/) |
32 | 15 | _(output).must_match(/action.+index/)
|
33 | 16 | end
|
34 | 17 |
|
35 | 18 | it "accepts short path" do
|
36 |
| - output = mock_pry('recognize-path /booms/1/edit', 'exit-all') |
| 19 | + output = mock_pry('recognize-path /cars/1/edit', 'exit-all') |
37 | 20 | _(output).must_match(/action.+edit/)
|
38 |
| - _(output).must_match(/controller.+booms/) |
| 21 | + _(output).must_match(/controller.+cars/) |
39 | 22 | _(output).must_match(/id.+1/)
|
40 | 23 | end
|
41 | 24 |
|
42 | 25 | it "accepts -m switch" do
|
43 |
| - output = mock_pry('recognize-path example.com/booms -m post', 'exit-all') |
44 |
| - _(output).must_match(/controller.+booms/) |
| 26 | + output = mock_pry('recognize-path example.com/cars -m post', 'exit-all') |
| 27 | + _(output).must_match(/controller.+cars/) |
45 | 28 | _(output).must_match(/action.+create/)
|
46 | 29 | end
|
47 | 30 |
|
48 | 31 | it "doesn't accept unknown methods" do
|
49 |
| - output = mock_pry('recognize-path example.com/booms -m posty', 'exit-all') |
| 32 | + output = mock_pry('recognize-path example.com/cars -m posty', 'exit-all') |
50 | 33 | _(output).must_match 'Unknown HTTP method: posty'
|
51 | 34 | end
|
52 | 35 |
|
|
0 commit comments