rspec-rails 1.1.12 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/.document +7 -0
  2. data/History.txt +55 -0
  3. data/License.txt +1 -1
  4. data/Manifest.txt +53 -48
  5. data/README.txt +5 -4
  6. data/Rakefile +9 -2
  7. data/TODO.txt +1 -0
  8. data/Upgrade.markdown +103 -0
  9. data/generators/rspec/rspec_generator.rb +1 -0
  10. data/generators/rspec/templates/rspec.rake +134 -111
  11. data/generators/rspec/templates/script/autospec +1 -0
  12. data/generators/rspec/templates/script/spec +21 -4
  13. data/generators/rspec/templates/script/spec_server +34 -107
  14. data/generators/rspec/templates/spec_helper.rb +1 -1
  15. data/generators/rspec_controller/rspec_controller_generator.rb +1 -5
  16. data/generators/rspec_scaffold/rspec_scaffold_generator.rb +13 -17
  17. data/generators/rspec_scaffold/templates/controller_spec.rb +27 -29
  18. data/generators/rspec_scaffold/templates/edit_erb_spec.rb +2 -2
  19. data/generators/rspec_scaffold/templates/helper_spec.rb +1 -1
  20. data/generators/rspec_scaffold/templates/index_erb_spec.rb +2 -2
  21. data/generators/rspec_scaffold/templates/new_erb_spec.rb +2 -2
  22. data/generators/rspec_scaffold/templates/routing_spec.rb +24 -20
  23. data/generators/rspec_scaffold/templates/show_erb_spec.rb +2 -2
  24. data/lib/spec/rails.rb +10 -9
  25. data/lib/spec/rails/example.rb +2 -2
  26. data/lib/spec/rails/example/assigns_hash_proxy.rb +1 -2
  27. data/lib/spec/rails/example/controller_example_group.rb +117 -123
  28. data/lib/spec/rails/example/functional_example_group.rb +7 -22
  29. data/lib/spec/rails/example/helper_example_group.rb +15 -33
  30. data/lib/spec/rails/example/model_example_group.rb +1 -1
  31. data/lib/spec/rails/example/render_observer.rb +0 -26
  32. data/lib/spec/rails/example/routing_example_group.rb +13 -0
  33. data/lib/spec/rails/example/routing_helpers.rb +68 -0
  34. data/lib/spec/rails/example/view_example_group.rb +50 -47
  35. data/lib/spec/rails/extensions.rb +2 -1
  36. data/lib/spec/rails/extensions/action_controller/rescue.rb +25 -8
  37. data/lib/spec/rails/extensions/action_controller/test_case.rb +16 -0
  38. data/lib/spec/rails/extensions/action_controller/test_response.rb +4 -3
  39. data/lib/spec/rails/extensions/action_view/base.rb +9 -9
  40. data/lib/spec/rails/extensions/active_record/base.rb +39 -23
  41. data/lib/spec/rails/extensions/active_support/test_case.rb +7 -0
  42. data/lib/spec/rails/extensions/spec/matchers/have.rb +8 -6
  43. data/lib/spec/rails/extensions/spec/runner/configuration.rb +12 -44
  44. data/lib/spec/rails/matchers/ar_be_valid.rb +8 -5
  45. data/lib/spec/rails/matchers/assert_select.rb +36 -21
  46. data/lib/spec/rails/matchers/have_text.rb +3 -3
  47. data/lib/spec/rails/matchers/include_text.rb +4 -4
  48. data/lib/spec/rails/matchers/redirect_to.rb +30 -19
  49. data/lib/spec/rails/matchers/render_template.rb +7 -3
  50. data/lib/spec/rails/mocks.rb +1 -1
  51. data/lib/spec/rails/spec_server.rb +97 -0
  52. data/lib/spec/rails/story_adapter.rb +4 -4
  53. data/lib/spec/rails/version.rb +2 -2
  54. data/spec/resources/controllers/controller_spec_controller.rb +14 -6
  55. data/spec/resources/controllers/example.txt +1 -0
  56. data/spec/resources/controllers/redirect_spec_controller.rb +4 -0
  57. data/spec/resources/controllers/render_spec_controller.rb +1 -1
  58. data/spec/resources/controllers/rjs_spec_controller.rb +1 -1
  59. data/spec/resources/helpers/explicit_helper.rb +1 -1
  60. data/spec/resources/views/controller_spec/{_partial.rhtml → _partial.html.erb} +0 -0
  61. data/spec/resources/views/controller_spec/{action_setting_flash_after_session_reset.rhtml → action_setting_flash_after_session_reset.html.erb} +0 -0
  62. data/spec/resources/views/controller_spec/{action_setting_flash_before_session_reset.rhtml → action_setting_flash_before_session_reset.html.erb} +0 -0
  63. data/spec/resources/views/controller_spec/{action_setting_the_assigns_hash.rhtml → action_setting_the_assigns_hash.html.erb} +0 -0
  64. data/spec/resources/views/controller_spec/{action_with_errors_in_template.rhtml → action_with_errors_in_template.html.erb} +0 -0
  65. data/spec/resources/views/controller_spec/{action_with_template.rhtml → action_with_template.html.erb} +0 -0
  66. data/spec/resources/views/layouts/{application.rhtml → application.html.erb} +0 -0
  67. data/spec/resources/views/layouts/{simple.rhtml → simple.html.erb} +0 -0
  68. data/spec/resources/views/render_spec/{_a_partial.rhtml → _a_partial.html.erb} +0 -0
  69. data/spec/resources/views/render_spec/{action_with_alternate_layout.rhtml → action_with_alternate_layout.html.erb} +0 -0
  70. data/spec/resources/views/rjs_spec/{_replacement_partial.rhtml → _replacement_partial.html.erb} +0 -0
  71. data/spec/resources/views/rjs_spec/{hide_div.rjs → hide_div.js.rjs} +0 -0
  72. data/spec/resources/views/rjs_spec/{hide_page_element.rjs → hide_page_element.js.rjs} +0 -0
  73. data/spec/resources/views/rjs_spec/{insert_html.rjs → insert_html.js.rjs} +0 -0
  74. data/spec/resources/views/rjs_spec/{replace.rjs → replace.js.rjs} +0 -0
  75. data/spec/resources/views/rjs_spec/{replace_html.rjs → replace_html.js.rjs} +0 -0
  76. data/spec/resources/views/rjs_spec/{replace_html_with_partial.rjs → replace_html_with_partial.js.rjs} +0 -0
  77. data/spec/resources/views/rjs_spec/{visual_effect.rjs → visual_effect.js.rjs} +0 -0
  78. data/spec/resources/views/rjs_spec/{visual_toggle_effect.rjs → visual_toggle_effect.js.rjs} +0 -0
  79. data/spec/resources/views/tag_spec/{no_tags.rhtml → no_tags.html.erb} +0 -0
  80. data/spec/resources/views/tag_spec/{single_div_with_no_attributes.rhtml → single_div_with_no_attributes.html.erb} +0 -0
  81. data/spec/resources/views/tag_spec/{single_div_with_one_attribute.rhtml → single_div_with_one_attribute.html.erb} +0 -0
  82. data/spec/resources/views/view_spec/{_partial.rhtml → _partial.html.erb} +0 -0
  83. data/spec/resources/views/view_spec/{_partial_used_twice.rhtml → _partial_used_twice.html.erb} +0 -0
  84. data/spec/resources/views/view_spec/{_partial_with_local_variable.rhtml → _partial_with_local_variable.html.erb} +0 -0
  85. data/spec/resources/views/view_spec/{_partial_with_sub_partial.rhtml → _partial_with_sub_partial.html.erb} +0 -0
  86. data/spec/resources/views/view_spec/{_spacer.rhtml → _spacer.html.erb} +0 -0
  87. data/spec/resources/views/view_spec/{accessor.rhtml → accessor.html.erb} +0 -0
  88. data/spec/resources/views/view_spec/{block_helper.rhtml → block_helper.html.erb} +0 -0
  89. data/spec/resources/views/view_spec/{entry_form.rhtml → entry_form.html.erb} +0 -0
  90. data/spec/resources/views/view_spec/{explicit_helper.rhtml → explicit_helper.html.erb} +0 -0
  91. data/spec/resources/views/view_spec/foo/{show.rhtml → show.html.erb} +0 -0
  92. data/spec/resources/views/view_spec/{implicit_helper.rhtml → implicit_helper.html.erb} +0 -0
  93. data/spec/resources/views/view_spec/{multiple_helpers.rhtml → multiple_helpers.html.erb} +0 -0
  94. data/spec/resources/views/view_spec/{should_not_receive.rhtml → should_not_receive.html.erb} +0 -0
  95. data/spec/resources/views/view_spec/{template_with_partial.rhtml → template_with_partial.html.erb} +0 -0
  96. data/spec/resources/views/view_spec/{template_with_partial_using_collection.rhtml → template_with_partial_using_collection.html.erb} +0 -0
  97. data/spec/resources/views/view_spec/{template_with_partial_with_array.rhtml → template_with_partial_with_array.html.erb} +0 -0
  98. data/spec/spec/rails/example/assigns_hash_proxy_spec.rb +18 -5
  99. data/spec/spec/rails/example/configuration_spec.rb +15 -29
  100. data/spec/spec/rails/example/{controller_spec_spec.rb → controller_example_group_spec.rb} +40 -96
  101. data/spec/spec/rails/example/cookies_proxy_spec.rb +32 -36
  102. data/spec/spec/rails/example/error_handling_spec.rb +90 -0
  103. data/spec/spec/rails/example/example_group_factory_spec.rb +5 -5
  104. data/spec/spec/rails/example/{helper_spec_spec.rb → helper_example_group_spec.rb} +45 -13
  105. data/spec/spec/rails/example/{model_spec_spec.rb → model_example_group_spec.rb} +3 -1
  106. data/spec/spec/rails/example/routing_example_group_spec.rb +9 -0
  107. data/spec/spec/rails/example/shared_routing_example_group_examples.rb +45 -0
  108. data/spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb +1 -1
  109. data/spec/spec/rails/example/{view_spec_spec.rb → view_example_group_spec.rb} +44 -17
  110. data/spec/spec/rails/matchers/ar_be_valid_spec.rb +10 -0
  111. data/spec/spec/rails/matchers/assert_select_spec.rb +59 -60
  112. data/spec/spec/rails/matchers/have_text_spec.rb +12 -4
  113. data/spec/spec/rails/matchers/include_text_spec.rb +11 -13
  114. data/spec/spec/rails/matchers/redirect_to_spec.rb +224 -189
  115. data/spec/spec/rails/matchers/render_template_spec.rb +169 -158
  116. data/spec/spec/rails/spec_server_spec.rb +18 -7
  117. data/spec/spec_helper.rb +21 -9
  118. metadata +68 -53
  119. data/lib/spec/rails/example/rails_example_group.rb +0 -28
  120. data/lib/spec/rails/extensions/action_controller/base.rb +0 -14
  121. data/rspec-rails.gemspec +0 -36
  122. data/spec/resources/views/render_spec/some_action.rjs +0 -1
  123. data/spec/spec/rails/example/shared_behaviour_spec.rb +0 -16
  124. data/spec/spec/rails/extensions/action_controller_rescue_action_spec.rb +0 -57
@@ -1,180 +1,191 @@
1
1
  require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
- ['isolation','integration'].each do |mode|
4
- describe "response.should render_template (in #{mode} mode)",
5
- :type => :controller do
6
- controller_name :render_spec
7
- if mode == 'integration'
8
- integrate_views
9
- end
3
+ [:response, :controller].each do |subject_method|
4
+ ['isolation','integration'].each do |mode|
5
+ describe "#{subject_method}.should render_template (in #{mode} mode)",
6
+ :type => :controller do
7
+ controller_name :render_spec
8
+ if mode == 'integration'
9
+ integrate_views
10
+ end
10
11
 
11
- it "should match a simple path" do
12
- post 'some_action'
13
- response.should render_template('some_action')
14
- end
12
+ subject { send(subject_method) }
15
13
 
16
- it "should match a less simple path" do
17
- post 'some_action'
18
- response.should render_template('render_spec/some_action')
19
- end
20
-
21
- it "should match a less simple path to another controller" do
22
- post 'action_which_renders_template_from_other_controller'
23
- response.should render_template('controller_spec/action_with_template')
24
- end
25
-
26
- it "should match a symbol" do
27
- post 'some_action'
28
- response.should render_template(:some_action)
29
- end
30
-
31
- it "should match an rjs template" do
32
- xhr :post, 'some_action'
33
- if Rails::VERSION::STRING < "2.0.0"
34
- response.should render_template('render_spec/some_action.rjs')
35
- else
36
- response.should render_template('render_spec/some_action')
14
+ it "matches an action (using a string)" do
15
+ post 'some_action'
16
+ should render_template('some_action')
37
17
  end
38
- end
39
-
40
- it "should match a partial template (simple path)" do
41
- get 'action_with_partial'
42
- response.should render_template("_a_partial")
43
- end
44
-
45
- it "should match a partial template (complex path)" do
46
- get 'action_with_partial'
47
- response.should render_template("render_spec/_a_partial")
48
- end
49
-
50
- it "should fail when the wrong template is rendered" do
51
- post 'some_action'
52
- lambda do
53
- response.should render_template('non_existent_template')
54
- end.should fail_with(/expected \"non_existent_template\", got \"render_spec\/some_action(\.html\.erb)?\"/)
55
- end
56
-
57
- it "should fail without full path when template is associated with a different controller" do
58
- post 'action_which_renders_template_from_other_controller'
59
- lambda do
60
- response.should render_template('action_with_template')
61
- end.should fail_with(/expected \"action_with_template\", got \"controller_spec\/action_with_template(\.rhtml)?\"/)
62
- end
63
-
64
- it "should fail with incorrect full path when template is associated with a different controller" do
65
- post 'action_which_renders_template_from_other_controller'
66
- lambda do
67
- response.should render_template('render_spec/action_with_template')
68
- end.should fail_with(/expected \"render_spec\/action_with_template\", got \"controller_spec\/action_with_template(\.rhtml)?\"/)
69
- end
70
-
71
- it "should fail on the wrong extension (given rhtml)" do
72
- get 'some_action'
73
- lambda {
74
- response.should render_template('render_spec/some_action.rjs')
75
- }.should fail_with(/expected \"render_spec\/some_action\.rjs\", got \"render_spec\/some_action(\.html\.erb)?\"/)
76
- end
77
-
78
- it "should fail when TEXT is rendered" do
79
- post 'text_action'
80
- lambda do
81
- response.should render_template('some_action')
82
- end.should fail_with(/expected \"some_action\", got (nil|\"\")/)
83
- end
84
-
85
- describe "with an alternate layout" do
86
- it "should say it rendered the action's template" do
87
- get 'action_with_alternate_layout'
88
- response.should render_template('action_with_alternate_layout')
18
+
19
+ if ::Rails::VERSION::STRING >= '2.3'
20
+ it "matches an action with specified extenstions" do
21
+ post 'some_action'
22
+ should render_template('some_action.html.erb')
23
+ end
24
+ end
25
+
26
+ it "matches an action (using a symbol)" do
27
+ post 'some_action'
28
+ should render_template(:some_action)
89
29
  end
90
- end
91
-
92
- it "provides a description" do
93
- render_template("foo/bar").description.should == %q|render template "foo/bar"|
94
- end
95
- end
96
-
97
- describe "response.should_not render_template (in #{mode} mode)",
98
- :type => :controller do
99
- controller_name :render_spec
100
- if mode == 'integration'
101
- integrate_views
102
- end
103
-
104
- it "should pass when the action renders nothing" do
105
- post 'action_that_renders_nothing'
106
- response.should_not render_template('action_that_renders_nothing')
107
- end
108
30
 
109
- it "should pass when the action renders nothing (symbol)" do
110
- post 'action_that_renders_nothing'
111
- response.should_not render_template(:action_that_renders_nothing)
112
- end
31
+ it "matches an action on a specific controller" do
32
+ post 'some_action'
33
+ should render_template('render_spec/some_action')
34
+ end
113
35
 
114
- it "should pass when the action does not render the template" do
115
- post 'some_action'
116
- response.should_not render_template('some_other_template')
117
- end
36
+ it "matches an action on a non-default specific controller" do
37
+ post 'action_which_renders_template_from_other_controller'
38
+ should render_template('controller_spec/action_with_template')
39
+ end
118
40
 
119
- it "should pass when the action does not render the template (symbol)" do
120
- post 'some_action'
121
- response.should_not render_template(:some_other_template)
122
- end
41
+ it "matches an rjs template" do
42
+ xhr :post, 'some_action'
43
+ should render_template('render_spec/some_action')
44
+ end
123
45
 
124
- it "should pass when the action does not render the template (named with controller)" do
125
- post 'some_action'
126
- response.should_not render_template('render_spec/some_other_template')
127
- end
46
+ it "matches a partial template (simple path)" do
47
+ get 'action_with_partial'
48
+ should render_template("_a_partial")
49
+ end
128
50
 
129
- it "should pass when the action renders the template with a different controller" do
130
- post 'action_which_renders_template_from_other_controller'
131
- response.should_not render_template('action_with_template')
132
- end
51
+ it "matches a partial template (complex path)" do
52
+ get 'action_with_partial'
53
+ should render_template("render_spec/_a_partial")
54
+ end
133
55
 
134
- it "should pass when the action renders the template (named with controller) with a different controller" do
135
- post 'action_which_renders_template_from_other_controller'
136
- response.should_not render_template('render_spec/action_with_template')
137
- end
56
+ it "fails when the wrong template is rendered" do
57
+ post 'some_action'
58
+ lambda do
59
+ should render_template('non_existent_template')
60
+ end.should fail_with(/expected \"non_existent_template\", got \"render_spec\/some_action(\.html\.erb)?\"/)
61
+ end
138
62
 
139
- it "should pass when TEXT is rendered" do
140
- post 'text_action'
141
- response.should_not render_template('some_action')
142
- end
63
+ it "fails when template is associated with a different controller but controller is not specified" do
64
+ post 'action_which_renders_template_from_other_controller'
65
+ lambda do
66
+ should render_template('action_with_template')
67
+ end.should fail_with(/expected \"action_with_template\", got \"controller_spec\/action_with_template(\.html\.erb)?\"/)
68
+ end
143
69
 
144
- it "should fail when the action renders the template" do
145
- post 'some_action'
146
- lambda do
147
- response.should_not render_template('some_action')
148
- end.should fail_with("expected not to render \"some_action\", but did")
149
- end
70
+ it "fails with incorrect full path when template is associated with a different controller" do
71
+ post 'action_which_renders_template_from_other_controller'
72
+ lambda do
73
+ should render_template('render_spec/action_with_template')
74
+ end.should fail_with(/expected \"render_spec\/action_with_template\", got \"controller_spec\/action_with_template(\.html\.erb)?\"/)
75
+ end
150
76
 
151
- it "should fail when the action renders the template (symbol)" do
152
- post 'some_action'
153
- lambda do
154
- response.should_not render_template(:some_action)
155
- end.should fail_with("expected not to render \"some_action\", but did")
156
- end
77
+ it "fails on the wrong extension" do
78
+ get 'some_action'
79
+ lambda {
80
+ should render_template('render_spec/some_action.js.rjs')
81
+ }.should fail_with(/expected \"render_spec\/some_action\.js\.rjs\", got \"render_spec\/some_action(\.html\.erb)?\"/)
82
+ end
157
83
 
158
- it "should fail when the action renders the template (named with controller)" do
159
- post 'some_action'
160
- lambda do
161
- response.should_not render_template('render_spec/some_action')
162
- end.should fail_with("expected not to render \"render_spec/some_action\", but did")
163
- end
84
+ it "faild when TEXT is rendered" do
85
+ post 'text_action'
86
+ lambda do
87
+ should render_template('some_action')
88
+ end.should fail_with(/expected \"some_action\", got (nil|\"\")/)
89
+ end
164
90
 
165
- it "should fail when the action renders the partial" do
166
- post 'action_with_partial'
167
- lambda do
168
- response.should_not render_template('_a_partial')
169
- end.should fail_with("expected not to render \"_a_partial\", but did")
91
+ describe "with an alternate layout" do
92
+ it "says it rendered the action's layout" do
93
+ pending("record rendering of layouts") do
94
+ get 'action_with_alternate_layout'
95
+ should render_template('layouts/simple')
96
+ end
97
+ end
98
+ end
99
+
100
+ it "provides a description" do
101
+ render_template("foo/bar").description.should == %q|render template "foo/bar"|
102
+ end
170
103
  end
171
104
 
172
- it "should fail when the action renders the partial (named with controller)" do
173
- post 'action_with_partial'
174
- lambda do
175
- response.should_not render_template('render_spec/_a_partial')
176
- end.should fail_with("expected not to render \"render_spec/_a_partial\", but did")
105
+ describe "#{subject_method}.should_not render_template (in #{mode} mode)",
106
+ :type => :controller do
107
+ controller_name :render_spec
108
+ if mode == 'integration'
109
+ integrate_views
110
+ end
111
+
112
+ subject { send(subject_method) }
113
+
114
+ it "passes when the action renders nothing" do
115
+ post 'action_that_renders_nothing'
116
+ should_not render_template('action_that_renders_nothing')
117
+ end
118
+
119
+ it "passes when the action renders nothing (symbol)" do
120
+ post 'action_that_renders_nothing'
121
+ should_not render_template(:action_that_renders_nothing)
122
+ end
123
+
124
+ it "passes when the action does not render the template" do
125
+ post 'some_action'
126
+ should_not render_template('some_other_template')
127
+ end
128
+
129
+ it "passes when the action does not render the template (symbol)" do
130
+ post 'some_action'
131
+ should_not render_template(:some_other_template)
132
+ end
133
+
134
+ it "passes when the action does not render the template (named with controller)" do
135
+ post 'some_action'
136
+ should_not render_template('render_spec/some_other_template')
137
+ end
138
+
139
+ it "passes when the action renders the template with a different controller" do
140
+ post 'action_which_renders_template_from_other_controller'
141
+ should_not render_template('action_with_template')
142
+ end
143
+
144
+ it "passes when the action renders the template (named with controller) with a different controller" do
145
+ post 'action_which_renders_template_from_other_controller'
146
+ should_not render_template('render_spec/action_with_template')
147
+ end
148
+
149
+ it "passes when TEXT is rendered" do
150
+ post 'text_action'
151
+ should_not render_template('some_action')
152
+ end
153
+
154
+ it "fails when the action renders the template" do
155
+ post 'some_action'
156
+ lambda do
157
+ should_not render_template('some_action')
158
+ end.should fail_with("expected not to render \"some_action\", but did")
159
+ end
160
+
161
+ it "fails when the action renders the template (symbol)" do
162
+ post 'some_action'
163
+ lambda do
164
+ should_not render_template(:some_action)
165
+ end.should fail_with("expected not to render \"some_action\", but did")
166
+ end
167
+
168
+ it "fails when the action renders the template (named with controller)" do
169
+ post 'some_action'
170
+ lambda do
171
+ should_not render_template('render_spec/some_action')
172
+ end.should fail_with("expected not to render \"render_spec/some_action\", but did")
173
+ end
174
+
175
+ it "fails when the action renders the partial" do
176
+ post 'action_with_partial'
177
+ lambda do
178
+ should_not render_template('_a_partial')
179
+ end.should fail_with("expected not to render \"_a_partial\", but did")
180
+ end
181
+
182
+ it "fails when the action renders the partial (named with controller)" do
183
+ post 'action_with_partial'
184
+ lambda do
185
+ should_not render_template('render_spec/_a_partial')
186
+ end.should fail_with("expected not to render \"render_spec/_a_partial\", but did")
187
+ end
188
+
177
189
  end
178
-
179
190
  end
180
191
  end
@@ -1,7 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper'
2
2
 
3
3
  describe "script/spec_server file", :shared => true do
4
- attr_accessor :tmbundle_install_directory
4
+ attr_accessor :tmbundle_install_directory, :tmbundle_source_directory
5
5
  attr_reader :animals_yml_path, :original_animals_content
6
6
 
7
7
  before do
@@ -22,7 +22,7 @@ describe "script/spec_server file", :shared => true do
22
22
  it "runs a spec" do
23
23
  dir = File.expand_path(File.dirname(__FILE__))
24
24
  output = ""
25
- Timeout.timeout(10) do
25
+ Timeout.timeout(20) do
26
26
  loop do
27
27
  output = `#{RAILS_ROOT}/script/spec #{dir}/sample_spec.rb --drb 2>&1`
28
28
  break unless output.include?("No server is running")
@@ -40,7 +40,7 @@ describe "script/spec_server file", :shared => true do
40
40
  f.write YAML.dump(fixtures)
41
41
  end
42
42
 
43
- Timeout.timeout(10) do
43
+ Timeout.timeout(20) do
44
44
  loop do
45
45
  output = `#{RAILS_ROOT}/script/spec #{dir}/sample_modified_fixture.rb --drb 2>&1`
46
46
  break unless output.include?("No server is running")
@@ -71,14 +71,25 @@ end
71
71
 
72
72
  describe "script/spec_server file with TextMate bundle" do
73
73
  it_should_behave_like "script/spec_server file"
74
+ def tmbundle_directory
75
+ current_directory = File.expand_path("#{File.dirname(__FILE__)}/../../../../../../")
76
+ directories = current_directory.split('/')
77
+ while directories.any?
78
+ current_directory = File.join(*directories)
79
+ bundle_directory = File.join(current_directory, @bundle_name)
80
+ return bundle_directory if File.directory?(bundle_directory)
81
+ directories.pop
82
+ end
83
+ end
84
+
74
85
  before(:each) do
75
- dir = File.dirname(__FILE__)
76
86
  @tmbundle_install_directory = File.expand_path("#{Dir.tmpdir}/Library/Application Support/TextMate/Bundles")
77
87
  @bundle_name = "RSpec.tmbundle"
88
+ @tmbundle_source_directory = tmbundle_directory
89
+
78
90
  FileUtils.mkdir_p(tmbundle_install_directory)
79
- bundle_dir = File.expand_path("#{dir}/../../../../../../#{@bundle_name}")
80
- File.directory?(bundle_dir).should be_true
81
- unless system(%Q|ln -s #{bundle_dir} "#{tmbundle_install_directory}"|)
91
+ File.directory?(tmbundle_source_directory).should be_true
92
+ unless system(%Q|ln -s #{tmbundle_source_directory} "#{tmbundle_install_directory}"|)
82
93
  raise "Creating link to Textmate Bundle"
83
94
  end
84
95
  start_spec_server
@@ -5,6 +5,7 @@ $LOAD_PATH.unshift(File.expand_path("#{dir}/resources/helpers"))
5
5
  require File.expand_path("#{dir}/../../../../spec/spec_helper")
6
6
  require File.expand_path("#{dir}/resources/controllers/application")
7
7
  require File.expand_path("#{dir}/resources/controllers/render_spec_controller")
8
+ require File.expand_path("#{dir}/resources/controllers/controller_spec_controller")
8
9
  require File.expand_path("#{dir}/resources/controllers/rjs_spec_controller")
9
10
  require File.expand_path("#{dir}/resources/controllers/redirect_spec_controller")
10
11
  require File.expand_path("#{dir}/resources/controllers/action_view_base_spec_controller")
@@ -29,7 +30,7 @@ module Spec
29
30
  module Rails
30
31
  module Example
31
32
  class ViewExampleGroupController
32
- set_view_path File.join(File.dirname(__FILE__), "..", "spec", "resources", "views")
33
+ prepend_view_path File.join(File.dirname(__FILE__), "..", "spec", "resources", "views")
33
34
  end
34
35
  end
35
36
  end
@@ -49,19 +50,30 @@ class Proc
49
50
  end
50
51
  end
51
52
 
52
- Spec::Runner.configure do |config|
53
- config.before(:each, :type => :controller) do
54
- end
55
- end
56
-
57
-
58
- ActionController::Routing::Routes.clear! # only since we're drawing routes here
59
53
  ActionController::Routing::Routes.draw do |map|
60
54
  map.connect 'action_with_method_restriction', :controller => 'redirect_spec', :action => 'action_with_method_restriction', :conditions => { :method => :get }
61
55
  map.connect 'action_to_redirect_to_action_with_method_restriction', :controller => 'redirect_spec', :action => 'action_to_redirect_to_action_with_method_restriction'
62
56
 
63
57
  map.resources :rspec_on_rails_specs
64
- map.connect 'custom_route', :controller => 'custom_route_spec', :action => 'custom_route'
58
+ map.custom_route 'custom_route', :controller => 'custom_route_spec', :action => 'custom_route'
65
59
  map.connect ":controller/:action/:id"
66
60
  end
67
61
 
62
+ module HelperMethods
63
+ def method_in_module_included_in_configuration
64
+ end
65
+ end
66
+
67
+ module HelperMacros
68
+ def accesses_configured_helper_methods
69
+ it "has access to methods in modules included in configuration" do
70
+ method_in_module_included_in_configuration
71
+ end
72
+ end
73
+ end
74
+
75
+ Spec::Runner.configure do |config|
76
+ config.include HelperMethods
77
+ config.extend HelperMacros
78
+ end
79
+