routespec 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. data/README.txt +66 -0
  2. data/Rakefile +26 -0
  3. data/bin/routespec +29 -0
  4. data/lib/routespec.rb +22 -0
  5. data/lib/routespec/builder.rb +111 -0
  6. data/lib/routespec/dyr.rb +50 -0
  7. data/lib/routespec/fyle.rb +72 -0
  8. data/lib/routespec/parser.rb +143 -0
  9. data/lib/routespec/railtie.rb +7 -0
  10. data/lib/routespec/routespec/requests/.gitkeep +0 -0
  11. data/lib/routespec/routespec/support/.gitkeep +0 -0
  12. data/lib/routespec/routespec/templates/default_spec.erb +24 -0
  13. data/lib/routespec/tasks.rb +18 -0
  14. data/lib/routespec/tasks/routespec.rake +22 -0
  15. data/lib/routespec/template_vars.rb +7 -0
  16. data/lib/routespec/version.rb +3 -0
  17. data/test/files/awesome.yml +1 -0
  18. data/test/files/response_code_vcr_spec.erb +24 -0
  19. data/test/files/routes.txt +12 -0
  20. data/test/files/routes.yml +193 -0
  21. data/test/files/routes_hash.rb +159 -0
  22. data/test/files/routes_hash_2.rb +153 -0
  23. data/test/files/routes_hash_3.rb +1 -0
  24. data/test/files/tasks_routes.txt +21 -0
  25. data/test/files/template_spec.erb +13 -0
  26. data/test/files/unclean.txt +11 -0
  27. data/test/rails311/Gemfile +4 -0
  28. data/test/rails311/Gemfile.lock +90 -0
  29. data/test/rails311/README +261 -0
  30. data/test/rails311/Rakefile +7 -0
  31. data/test/rails311/app/assets/images/rails.png +0 -0
  32. data/test/rails311/app/assets/javascripts/application.js +9 -0
  33. data/test/rails311/app/assets/javascripts/beers.js +2 -0
  34. data/test/rails311/app/assets/javascripts/chips.js +2 -0
  35. data/test/rails311/app/assets/javascripts/sports.js +2 -0
  36. data/test/rails311/app/assets/stylesheets/application.css +7 -0
  37. data/test/rails311/app/assets/stylesheets/beers.css +4 -0
  38. data/test/rails311/app/assets/stylesheets/chips.css +4 -0
  39. data/test/rails311/app/assets/stylesheets/scaffold.css +56 -0
  40. data/test/rails311/app/assets/stylesheets/sports.css +4 -0
  41. data/test/rails311/app/controllers/application_controller.rb +3 -0
  42. data/test/rails311/app/controllers/beers_controller.rb +83 -0
  43. data/test/rails311/app/controllers/chips_controller.rb +83 -0
  44. data/test/rails311/app/controllers/sports_controller.rb +83 -0
  45. data/test/rails311/app/helpers/application_helper.rb +2 -0
  46. data/test/rails311/app/helpers/beers_helper.rb +2 -0
  47. data/test/rails311/app/helpers/chips_helper.rb +2 -0
  48. data/test/rails311/app/helpers/sports_helper.rb +2 -0
  49. data/test/rails311/app/models/beer.rb +2 -0
  50. data/test/rails311/app/models/chip.rb +2 -0
  51. data/test/rails311/app/models/sport.rb +2 -0
  52. data/test/rails311/app/views/beers/_form.html.erb +17 -0
  53. data/test/rails311/app/views/beers/edit.html.erb +6 -0
  54. data/test/rails311/app/views/beers/index.html.erb +21 -0
  55. data/test/rails311/app/views/beers/new.html.erb +5 -0
  56. data/test/rails311/app/views/beers/show.html.erb +5 -0
  57. data/test/rails311/app/views/chips/_form.html.erb +17 -0
  58. data/test/rails311/app/views/chips/edit.html.erb +6 -0
  59. data/test/rails311/app/views/chips/index.html.erb +21 -0
  60. data/test/rails311/app/views/chips/new.html.erb +5 -0
  61. data/test/rails311/app/views/chips/show.html.erb +5 -0
  62. data/test/rails311/app/views/layouts/application.html.erb +14 -0
  63. data/test/rails311/app/views/sports/_form.html.erb +17 -0
  64. data/test/rails311/app/views/sports/edit.html.erb +6 -0
  65. data/test/rails311/app/views/sports/index.html.erb +21 -0
  66. data/test/rails311/app/views/sports/new.html.erb +5 -0
  67. data/test/rails311/app/views/sports/show.html.erb +5 -0
  68. data/test/rails311/config.ru +4 -0
  69. data/test/rails311/config/application.rb +48 -0
  70. data/test/rails311/config/boot.rb +6 -0
  71. data/test/rails311/config/database.yml +25 -0
  72. data/test/rails311/config/environment.rb +5 -0
  73. data/test/rails311/config/environments/development.rb +30 -0
  74. data/test/rails311/config/environments/production.rb +60 -0
  75. data/test/rails311/config/environments/test.rb +39 -0
  76. data/test/rails311/config/initializers/backtrace_silencers.rb +7 -0
  77. data/test/rails311/config/initializers/inflections.rb +10 -0
  78. data/test/rails311/config/initializers/mime_types.rb +5 -0
  79. data/test/rails311/config/initializers/secret_token.rb +7 -0
  80. data/test/rails311/config/initializers/session_store.rb +8 -0
  81. data/test/rails311/config/initializers/wrap_parameters.rb +14 -0
  82. data/test/rails311/config/locales/en.yml +5 -0
  83. data/test/rails311/config/routes.rb +64 -0
  84. data/test/rails311/db/development.sqlite3 +0 -0
  85. data/test/rails311/db/migrate/20111227222038_create_beers.rb +8 -0
  86. data/test/rails311/db/migrate/20111227222056_create_chips.rb +8 -0
  87. data/test/rails311/db/migrate/20111227222113_create_sports.rb +8 -0
  88. data/test/rails311/db/schema.rb +31 -0
  89. data/test/rails311/db/seeds.rb +7 -0
  90. data/test/rails311/db/test.sqlite3 +0 -0
  91. data/test/rails311/doc/README_FOR_APP +2 -0
  92. data/test/rails311/log/development.log +28 -0
  93. data/test/rails311/log/test.log +0 -0
  94. data/test/rails311/public/404.html +26 -0
  95. data/test/rails311/public/422.html +26 -0
  96. data/test/rails311/public/500.html +26 -0
  97. data/test/rails311/public/favicon.ico +0 -0
  98. data/test/rails311/public/index.html +241 -0
  99. data/test/rails311/public/robots.txt +5 -0
  100. data/test/rails311/script/rails +6 -0
  101. data/test/rails311/spec/routespec/requests/beers/beers_spec.rb +74 -0
  102. data/test/rails311/spec/routespec/requests/chips/chips_spec.rb +74 -0
  103. data/test/rails311/spec/routespec/requests/sports/sports_spec.rb +74 -0
  104. data/test/rails311/spec/routespec/support/routes.txt +21 -0
  105. data/test/rails311/spec/routespec/support/routes.yml +322 -0
  106. data/test/rails311/spec/routespec/templates/default_spec.erb +24 -0
  107. data/test/rails311/test/fixtures/beers.yml +11 -0
  108. data/test/rails311/test/fixtures/chips.yml +11 -0
  109. data/test/rails311/test/fixtures/sports.yml +11 -0
  110. data/test/rails311/test/functional/beers_controller_test.rb +49 -0
  111. data/test/rails311/test/functional/chips_controller_test.rb +49 -0
  112. data/test/rails311/test/functional/sports_controller_test.rb +49 -0
  113. data/test/rails311/test/performance/browsing_test.rb +12 -0
  114. data/test/rails311/test/test_helper.rb +13 -0
  115. data/test/rails311/test/unit/beer_test.rb +7 -0
  116. data/test/rails311/test/unit/chip_test.rb +7 -0
  117. data/test/rails311/test/unit/helpers/beers_helper_test.rb +4 -0
  118. data/test/rails311/test/unit/helpers/chips_helper_test.rb +4 -0
  119. data/test/rails311/test/unit/helpers/sports_helper_test.rb +4 -0
  120. data/test/rails311/test/unit/sport_test.rb +7 -0
  121. data/test/rails311/vendor/cache/actionmailer-3.1.1.gem +0 -0
  122. data/test/rails311/vendor/cache/actionpack-3.1.1.gem +0 -0
  123. data/test/rails311/vendor/cache/activemodel-3.1.1.gem +0 -0
  124. data/test/rails311/vendor/cache/activerecord-3.1.1.gem +0 -0
  125. data/test/rails311/vendor/cache/activeresource-3.1.1.gem +0 -0
  126. data/test/rails311/vendor/cache/activesupport-3.1.1.gem +0 -0
  127. data/test/rails311/vendor/cache/arel-2.2.1.gem +0 -0
  128. data/test/rails311/vendor/cache/builder-3.0.0.gem +0 -0
  129. data/test/rails311/vendor/cache/erubis-2.7.0.gem +0 -0
  130. data/test/rails311/vendor/cache/hike-1.2.1.gem +0 -0
  131. data/test/rails311/vendor/cache/i18n-0.6.0.gem +0 -0
  132. data/test/rails311/vendor/cache/json-1.6.4.gem +0 -0
  133. data/test/rails311/vendor/cache/mail-2.3.0.gem +0 -0
  134. data/test/rails311/vendor/cache/mime-types-1.17.2.gem +0 -0
  135. data/test/rails311/vendor/cache/multi_json-1.0.4.gem +0 -0
  136. data/test/rails311/vendor/cache/polyglot-0.3.3.gem +0 -0
  137. data/test/rails311/vendor/cache/rack-1.3.5.gem +0 -0
  138. data/test/rails311/vendor/cache/rack-cache-1.1.gem +0 -0
  139. data/test/rails311/vendor/cache/rack-mount-0.8.3.gem +0 -0
  140. data/test/rails311/vendor/cache/rack-ssl-1.3.2.gem +0 -0
  141. data/test/rails311/vendor/cache/rack-test-0.6.1.gem +0 -0
  142. data/test/rails311/vendor/cache/rails-3.1.1.gem +0 -0
  143. data/test/rails311/vendor/cache/railties-3.1.1.gem +0 -0
  144. data/test/rails311/vendor/cache/rake-0.9.2.2.gem +0 -0
  145. data/test/rails311/vendor/cache/rdoc-3.12.gem +0 -0
  146. data/test/rails311/vendor/cache/sprockets-2.0.3.gem +0 -0
  147. data/test/rails311/vendor/cache/sqlite3-1.3.5.gem +0 -0
  148. data/test/rails311/vendor/cache/thor-0.14.6.gem +0 -0
  149. data/test/rails311/vendor/cache/tilt-1.3.3.gem +0 -0
  150. data/test/rails311/vendor/cache/treetop-1.4.10.gem +0 -0
  151. data/test/rails311/vendor/cache/tzinfo-0.3.31.gem +0 -0
  152. data/test/sandbox/awsome.txt +1 -0
  153. data/test/sandbox/cerveja/muito_legal/cool/cool_spec.rb +1 -0
  154. data/test/sandbox/cerveja/rad/rad_spec.rb +1 -0
  155. data/test/sandbox/cool.txt +4 -0
  156. data/test/sandbox/rails_root/routespec/templates/default_spec.erb +24 -0
  157. data/test/sandbox/requests/dynamic/dynamic_spec.rb +17 -0
  158. data/test/sandbox/requests/errors/errors_spec.rb +36 -0
  159. data/test/sandbox/requests/info_panel/info_panel_spec.rb +16 -0
  160. data/test/sandbox/requests/legacy/legacy_spec.rb +26 -0
  161. data/test/sandbox/requests2/dynamic/dynamic_spec.rb +17 -0
  162. data/test/sandbox/requests2/errors/errors_spec.rb +36 -0
  163. data/test/sandbox/requests2/info_panel/info_panel_spec.rb +16 -0
  164. data/test/sandbox/requests2/legacy/legacy_spec.rb +26 -0
  165. data/test/sandbox/routes.txt +21 -0
  166. data/test/sandbox/routes.yml +193 -0
  167. data/test/sandbox/seu_jorge.yml +3 -0
  168. data/test/test_builder.rb +118 -0
  169. data/test/test_config.rb +5 -0
  170. data/test/test_dyr.rb +56 -0
  171. data/test/test_fyle.rb +59 -0
  172. data/test/test_parser.rb +84 -0
  173. data/test/test_rails311.rb +15 -0
  174. data/test/test_routespec.rb +8 -0
  175. data/test/test_tasks.rb +26 -0
  176. data/test/test_template_vars.rb +18 -0
  177. metadata +382 -0
@@ -0,0 +1,16 @@
1
+ require "spec_helper"
2
+
3
+ #
4
+ # routes
5
+ # info_panel_edit GET /info_panel/edit(.:format) {:controller=>"info_panel", :action=>"edit"}
6
+ #
7
+ describe "info_panel response status codes" do
8
+ describe "GET /info_panel/edit(.:format)" do
9
+ it "should have a response", :vcr do
10
+ format = nil
11
+ get info_panel_edit_path(:format => format)
12
+ response.status.should be(200)
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ #
4
+ # routes
5
+ # /index.cfm(.:format) {:controller=>"legacy", :action=>"index"}
6
+ # /listingid=:id(.:format) {:id=>/[0-9]+/, :controller=>"legacy", :action=>"listingid"}
7
+ #
8
+ describe "legacy response status codes" do
9
+ describe "GET /index.cfm(.:format)" do
10
+ it "should have a response", :vcr do
11
+ format = nil
12
+ get "/index#{format ? "." : nil}cfm.#{format}"
13
+ response.status.should be(200)
14
+ end
15
+ end
16
+
17
+ describe "GET /listingid=:id(.:format)" do
18
+ it "should have a response", :vcr do
19
+ id = "REPLACE"
20
+ format = nil
21
+ get "/listingid=#{id}#{format ? "." : nil}#{format}"
22
+ response.status.should be(200)
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ #
4
+ # routes
5
+ # dynamic_controller /:controller/render_event_response(.:format) {:action=>"render_event_response"}
6
+ #
7
+ describe "dynamic response status codes" do
8
+ describe "GET /:controller/render_event_response(.:format)" do
9
+ it "should have a response", :vcr do
10
+ controller = "REPLACE"
11
+ format = nil
12
+ get dynamic_controller_path(:controller => controller, :format => format)
13
+ response.status.should be(200)
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,36 @@
1
+ require "spec_helper"
2
+
3
+ #
4
+ # routes
5
+ # POST /errors(.:format) {:action=>"create", :controller=>"errors"}
6
+ # PUT /errors/:id(.:format) {:action=>"update", :controller=>"errors"}
7
+ # DELETE /errors/:id(.:format) {:action=>"destroy", :controller=>"errors"}
8
+ #
9
+ describe "errors response status codes" do
10
+ describe "POST /errors(.:format)" do
11
+ it "should have a response", :vcr do
12
+ format = nil
13
+ post "/errors#{format ? "." : nil}#{format}"
14
+ response.status.should be(201)
15
+ end
16
+ end
17
+
18
+ describe "PUT /errors/:id(.:format)" do
19
+ it "should have a response", :vcr do
20
+ id = "REPLACE"
21
+ format = nil
22
+ put "/errors/#{id}#{format ? "." : nil}#{format}"
23
+ response.status.should be(200)
24
+ end
25
+ end
26
+
27
+ describe "DELETE /errors/:id(.:format)" do
28
+ it "should have a response", :vcr do
29
+ id = "REPLACE"
30
+ format = nil
31
+ delete "/errors/#{id}#{format ? "." : nil}#{format}"
32
+ response.status.should be(200)
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,16 @@
1
+ require "spec_helper"
2
+
3
+ #
4
+ # routes
5
+ # info_panel_edit GET /info_panel/edit(.:format) {:controller=>"info_panel", :action=>"edit"}
6
+ #
7
+ describe "info_panel response status codes" do
8
+ describe "GET /info_panel/edit(.:format)" do
9
+ it "should have a response", :vcr do
10
+ format = nil
11
+ get info_panel_edit_path(:format => format)
12
+ response.status.should be(200)
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ #
4
+ # routes
5
+ # /index.cfm(.:format) {:controller=>"legacy", :action=>"index"}
6
+ # /listingid=:id(.:format) {:id=>/[0-9]+/, :controller=>"legacy", :action=>"listingid"}
7
+ #
8
+ describe "legacy response status codes" do
9
+ describe "GET /index.cfm(.:format)" do
10
+ it "should have a response", :vcr do
11
+ format = nil
12
+ get "/index#{format ? "." : nil}cfm.#{format}"
13
+ response.status.should be(200)
14
+ end
15
+ end
16
+
17
+ describe "GET /listingid=:id(.:format)" do
18
+ it "should have a response", :vcr do
19
+ id = "REPLACE"
20
+ format = nil
21
+ get "/listingid=#{id}#{format ? "." : nil}#{format}"
22
+ response.status.should be(200)
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,21 @@
1
+ sports GET /sports(.:format) {:action=>"index", :controller=>"sports"}
2
+ POST /sports(.:format) {:action=>"create", :controller=>"sports"}
3
+ new_sport GET /sports/new(.:format) {:action=>"new", :controller=>"sports"}
4
+ edit_sport GET /sports/:id/edit(.:format) {:action=>"edit", :controller=>"sports"}
5
+ sport GET /sports/:id(.:format) {:action=>"show", :controller=>"sports"}
6
+ PUT /sports/:id(.:format) {:action=>"update", :controller=>"sports"}
7
+ DELETE /sports/:id(.:format) {:action=>"destroy", :controller=>"sports"}
8
+ chips GET /chips(.:format) {:action=>"index", :controller=>"chips"}
9
+ POST /chips(.:format) {:action=>"create", :controller=>"chips"}
10
+ new_chip GET /chips/new(.:format) {:action=>"new", :controller=>"chips"}
11
+ edit_chip GET /chips/:id/edit(.:format) {:action=>"edit", :controller=>"chips"}
12
+ chip GET /chips/:id(.:format) {:action=>"show", :controller=>"chips"}
13
+ PUT /chips/:id(.:format) {:action=>"update", :controller=>"chips"}
14
+ DELETE /chips/:id(.:format) {:action=>"destroy", :controller=>"chips"}
15
+ beers GET /beers(.:format) {:action=>"index", :controller=>"beers"}
16
+ POST /beers(.:format) {:action=>"create", :controller=>"beers"}
17
+ new_beer GET /beers/new(.:format) {:action=>"new", :controller=>"beers"}
18
+ edit_beer GET /beers/:id/edit(.:format) {:action=>"edit", :controller=>"beers"}
19
+ beer GET /beers/:id(.:format) {:action=>"show", :controller=>"beers"}
20
+ PUT /beers/:id(.:format) {:action=>"update", :controller=>"beers"}
21
+ DELETE /beers/:id(.:format) {:action=>"destroy", :controller=>"beers"}
@@ -0,0 +1,193 @@
1
+ ---
2
+ :dynamic:
3
+ - :raw: dynamic_controller /:controller/render_event_response(.:format) {:action=>"render_event_response"}
4
+ :helper: dynamic_controller
5
+ :http_verb: GET
6
+ :path: /:controller/render_event_response(.:format)
7
+ :action: render_event_response
8
+ :controller:
9
+ :symbols:
10
+ - controller
11
+ - format
12
+ :address:
13
+ - dynamic
14
+ :status_code: 200
15
+ :helper_path: dynamic_controller_path(:controller => controller, :format => format)
16
+ :vars:
17
+ - controller = "REPLACE"
18
+ - format = nil
19
+ :info_panel:
20
+ - :raw: info_panel_edit GET /info_panel/edit(.:format) {:controller=>"info_panel", :action=>"edit"}
21
+ :helper: info_panel_edit
22
+ :http_verb: GET
23
+ :path: /info_panel/edit(.:format)
24
+ :action: edit
25
+ :controller: info_panel
26
+ :symbols:
27
+ - format
28
+ :address:
29
+ - info_panel
30
+ :status_code: 200
31
+ :helper_path: info_panel_edit_path(:format => format)
32
+ :vars:
33
+ - format = nil
34
+ :errors:
35
+ - :raw: POST /errors(.:format) {:action=>"create", :controller=>"errors"}
36
+ :helper:
37
+ :http_verb: POST
38
+ :path: /errors(.:format)
39
+ :action: create
40
+ :controller: errors
41
+ :symbols:
42
+ - format
43
+ :address:
44
+ - errors
45
+ :status_code: 201
46
+ :helper_path: "\"/errors#{format ? \".\" : nil}#{format}\""
47
+ :vars:
48
+ - format = nil
49
+ - :raw: PUT /errors/:id(.:format) {:action=>"update", :controller=>"errors"}
50
+ :helper:
51
+ :http_verb: PUT
52
+ :path: /errors/:id(.:format)
53
+ :action: update
54
+ :controller: errors
55
+ :symbols:
56
+ - id
57
+ - format
58
+ :address:
59
+ - errors
60
+ :status_code: 200
61
+ :helper_path: "\"/errors/#{id}#{format ? \".\" : nil}#{format}\""
62
+ :vars:
63
+ - id = "REPLACE"
64
+ - format = nil
65
+ - :raw: DELETE /errors/:id(.:format) {:action=>"destroy", :controller=>"errors"}
66
+ :helper:
67
+ :http_verb: DELETE
68
+ :path: /errors/:id(.:format)
69
+ :action: destroy
70
+ :controller: errors
71
+ :symbols:
72
+ - id
73
+ - format
74
+ :address:
75
+ - errors
76
+ :status_code: 200
77
+ :helper_path: "\"/errors/#{id}#{format ? \".\" : nil}#{format}\""
78
+ :vars:
79
+ - id = "REPLACE"
80
+ - format = nil
81
+ :legacy:
82
+ - :raw: /index.cfm(.:format) {:controller=>"legacy", :action=>"index"}
83
+ :helper:
84
+ :http_verb: GET
85
+ :path: /index.cfm(.:format)
86
+ :action: index
87
+ :controller: legacy
88
+ :symbols:
89
+ - format
90
+ :address:
91
+ - legacy
92
+ :status_code: 200
93
+ :helper_path: "\"/index#{format ? \".\" : nil}cfm.#{format}\""
94
+ :vars:
95
+ - format = nil
96
+ - :raw: /listingid=:id(.:format) {:id=>/[0-9]+/, :controller=>"legacy", :action=>"listingid"}
97
+ :helper:
98
+ :http_verb: GET
99
+ :path: /listingid=:id(.:format)
100
+ :action: listingid
101
+ :controller: legacy
102
+ :symbols:
103
+ - id
104
+ - format
105
+ :address:
106
+ - legacy
107
+ :status_code: 200
108
+ :helper_path: "\"/listingid=#{id}#{format ? \".\" : nil}#{format}\""
109
+ :vars:
110
+ - id = "REPLACE"
111
+ - format = nil
112
+ :agents_and_offices:
113
+ :listings:
114
+ - :raw: /mls/:id(.:format) {:controller=>"agents_and_offices/listings", :action=>"mls"}
115
+ :helper:
116
+ :http_verb: GET
117
+ :path: /mls/:id(.:format)
118
+ :action: mls
119
+ :controller: agents_and_offices/listings
120
+ :symbols:
121
+ - id
122
+ - format
123
+ :address:
124
+ - agents_and_offices
125
+ - listings
126
+ :status_code: 200
127
+ :helper_path: "\"/mls/#{id}#{format ? \".\" : nil}#{format}\""
128
+ :vars:
129
+ - id = "REPLACE"
130
+ - format = nil
131
+ :enquiries:
132
+ - :raw: agent_listing_enquiries POST /agents/:agent_id/listings/:listing_id/enquiries(.:format) {:action=>"create", :controller=>"agents_and_offices/enquiries"}
133
+ :helper: agent_listing_enquiries
134
+ :http_verb: POST
135
+ :path: /agents/:agent_id/listings/:listing_id/enquiries(.:format)
136
+ :action: create
137
+ :controller: agents_and_offices/enquiries
138
+ :symbols:
139
+ - agent_id
140
+ - listing_id
141
+ - format
142
+ :address:
143
+ - agents_and_offices
144
+ - enquiries
145
+ :status_code: 201
146
+ :helper_path: agent_listing_enquiries_path(:agent_id => agent_id, :listing_id => listing_id, :format => format)
147
+ :vars:
148
+ - agent_id = "REPLACE"
149
+ - listing_id = "REPLACE"
150
+ - format = nil
151
+ - :raw: new_agent_listing_enquiry GET /agents/:agent_id/listings/:listing_id/enquiries/new(.:format) {:action=>"new", :controller=>"agents_and_offices/enquiries"}
152
+ :helper: new_agent_listing_enquiry
153
+ :http_verb: GET
154
+ :path: /agents/:agent_id/listings/:listing_id/enquiries/new(.:format)
155
+ :action: new
156
+ :controller: agents_and_offices/enquiries
157
+ :symbols:
158
+ - agent_id
159
+ - listing_id
160
+ - format
161
+ :address:
162
+ - agents_and_offices
163
+ - enquiries
164
+ :status_code: 200
165
+ :helper_path: new_agent_listing_enquiry_path(:agent_id => agent_id, :listing_id => listing_id, :format => format)
166
+ :vars:
167
+ - agent_id = "REPLACE"
168
+ - listing_id = "REPLACE"
169
+ - format = nil
170
+ :photos:
171
+ - :raw: agent_listing_gallery_photo GET /agents/:agent_id/listings/:listing_id/galleries/:gallery_id/photos/:id(.:format) {:action=>"show", :controller=>"agents_and_offices/photos"}
172
+ :helper: agent_listing_gallery_photo
173
+ :http_verb: GET
174
+ :path: /agents/:agent_id/listings/:listing_id/galleries/:gallery_id/photos/:id(.:format)
175
+ :action: show
176
+ :controller: agents_and_offices/photos
177
+ :symbols:
178
+ - agent_id
179
+ - listing_id
180
+ - gallery_id
181
+ - id
182
+ - format
183
+ :address:
184
+ - agents_and_offices
185
+ - photos
186
+ :status_code: 200
187
+ :helper_path: agent_listing_gallery_photo_path(:agent_id => agent_id, :listing_id => listing_id, :gallery_id => gallery_id, :id => id, :format => format)
188
+ :vars:
189
+ - agent_id = "REPLACE"
190
+ - listing_id = "REPLACE"
191
+ - gallery_id = "REPLACE"
192
+ - id = "REPLACE"
193
+ - format = nil
@@ -0,0 +1,3 @@
1
+ ---
2
+ 2: Sao Gronca
3
+ 4: Ana Carolina
@@ -0,0 +1,118 @@
1
+ require "test/unit"
2
+ require "routespec"
3
+
4
+ class TestBuilder < Test::Unit::TestCase
5
+ def setup
6
+ @files = "#{File.dirname(__FILE__)}/files"
7
+ @sandbox = "#{File.dirname(__FILE__)}/sandbox"
8
+ end
9
+
10
+ def test_text_to_yaml
11
+ input_file_name = "#{@files}/routes.txt"
12
+ output_file_name = "#{@sandbox}/routes.yml"
13
+ FileUtils.rm_f(output_file_name)
14
+ refute File.exist?(output_file_name)
15
+ ret = Routespec::Builder.text_to_yaml(input_file_name, output_file_name)
16
+ assert_equal true, ret
17
+ assert File.exist?(output_file_name)
18
+ assert_equal IO.read("#{@files}/routes.yml"), IO.read(output_file_name)
19
+ end
20
+
21
+ def test_yaml_to_specs_with_dir_name
22
+ dir_name = "#{@sandbox}/requests2"
23
+ input_file_name = "#{@files}/routes.yml"
24
+ template_file_name = "#{@files}/response_code_vcr_spec.erb"
25
+ FileUtils.rm_rf dir_name
26
+ refute Dir.exist?(dir_name)
27
+ ret = Routespec::Builder.yaml_to_specs(input_file_name, template_file_name, dir_name)
28
+ assert_equal true, ret
29
+ assert Dir.exist?(dir_name)
30
+ exp_entries = [".", "..", "dynamic", "errors", "info_panel", "legacy"]
31
+ assert_equal exp_entries, Dir.entries(dir_name)
32
+ end
33
+
34
+ def test_yaml_to_specs_without_dir_name
35
+ input_file_name_orig = "#{@files}/routes.yml"
36
+ input_file_name_temp = "#{@sandbox}/routes.yml"
37
+ template_file_name = "#{@files}/response_code_vcr_spec.erb"
38
+ exp_dir_name = "#{@sandbox}/requests"
39
+ assert File.exist?(input_file_name_orig)
40
+ FileUtils.rm_rf input_file_name_temp
41
+ refute File.exist?(input_file_name_temp)
42
+ FileUtils.cp input_file_name_orig, input_file_name_temp
43
+ assert File.exist?(input_file_name_temp)
44
+ FileUtils.rm_rf exp_dir_name
45
+ refute Dir.exist?(exp_dir_name)
46
+ ret = Routespec::Builder.yaml_to_specs(input_file_name_temp, template_file_name)
47
+ assert_equal true, ret
48
+ assert Dir.exist?(exp_dir_name)
49
+ exp_entries = [".", "..", "dynamic", "errors", "info_panel", "legacy"]
50
+ assert_equal exp_entries, Dir.entries(exp_dir_name)
51
+ end
52
+
53
+ def test_hash_to_specs
54
+ dir_name = "#{@sandbox}/cerveja"
55
+ file_name_1 = "#{dir_name}/rad/rad_spec.rb"
56
+ file_name_2 = "#{dir_name}/muito_legal/cool/cool_spec.rb"
57
+ node_1 = {file_name_1 => {:address => ["rad"], :content => "skol"}}
58
+ node_2 = {file_name_2 => {:address => ["muito_legal", "cool"], :content => "bavaria"}}
59
+ hash = node_1.merge node_2
60
+ FileUtils.rm_rf dir_name
61
+ refute Dir.exist? dir_name
62
+ ret = Routespec::Builder.hash_to_specs(hash, dir_name)
63
+ assert_equal true, ret
64
+ assert File.exist? file_name_1
65
+ assert File.exist? file_name_2
66
+ assert Dir.exist? dir_name
67
+ assert Dir.exist? "#{dir_name}/rad"
68
+ assert Dir.exist? "#{dir_name}/muito_legal"
69
+ assert Dir.exist? "#{dir_name}/muito_legal/cool"
70
+ assert_equal "skol", IO.read(file_name_1)
71
+ assert_equal "bavaria", IO.read(file_name_2)
72
+ end
73
+
74
+ def test_template_text
75
+ template_file_name = "#{@files}/template_spec.erb"
76
+ assert File.exist? template_file_name
77
+ ret = Routespec::Builder.template_text(template_file_name)
78
+ exp = "require \"spec_helper\"\n\n#\n# some text\n#\ndescribe \"<%= @name %>\" do\n describe \"<%= @desc_1 %>\" do\n it \"should have a <%= @desc_2 %>\" do\n response.status.should be(<%= @response %>)\n end\n end\n\nend"
79
+ assert_equal exp, ret
80
+ end
81
+
82
+ def test_clean_lines
83
+ file_name = "#{@files}/unclean.txt"
84
+ file_text = IO.read file_name
85
+ ret = Routespec::Builder.clean_lines(file_text)
86
+ assert_equal "dirty\n\ndirty\ndirty\n\ndirty\n\n\ndirty\n\ndirty", ret
87
+ end
88
+
89
+ def test_template_init
90
+ hash = {:name => "homem", :desc_1 => "vai para a choperia", :desc_2 => "beer", :response => "\"awesome!\""}
91
+ template_file_name = "#{@files}/template_spec.erb"
92
+ assert File.exist? template_file_name
93
+ ret = Routespec::Builder.template_init(hash, template_file_name)
94
+ exp = "require \"spec_helper\"\n\n#\n# some text\n#\ndescribe \"homem\" do\n describe \"vai para a choperia\" do\n it \"should have a beer\" do\n response.status.should be(\"awesome!\")\n end\n end\n\nend"
95
+ assert_equal exp, ret
96
+ end
97
+
98
+ def test_array_to_objects
99
+ array = [{:beer => "Bohemia"}, {:beer => "Skol"}, {:beer => "Brahma"}]
100
+ ret = Routespec::Builder.array_to_objects(array)
101
+ assert_kind_of Array, ret
102
+ assert_kind_of OpenStruct, ret.first
103
+ assert_equal "Bohemia", ret[0].beer
104
+ assert_equal "Skol", ret[1].beer
105
+ assert_equal "Brahma", ret[2].beer
106
+ end
107
+
108
+ def test_build
109
+ template_file_name = "#{@files}/response_code_vcr_spec.erb"
110
+ hash_file_name = "#{@files}/routes_hash_2.rb"
111
+ hash = eval("#{IO.read(hash_file_name)}")
112
+ assert_kind_of Hash, hash
113
+ ret = Routespec::Builder.build(hash, hash.keys, template_file_name)
114
+ assert_kind_of Hash, ret
115
+ exp = IO.read("#{@files}/routes_hash_3.rb").sub(/\n$/, "")
116
+ assert_equal exp, ret.to_s
117
+ end
118
+ end