rspec-rails 1.1.11 → 1.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. data/History.txt +29 -0
  2. data/Manifest.txt +94 -94
  3. data/README.txt +5 -7
  4. data/Rakefile +14 -2
  5. data/{spec_resources/views/controller_spec/_partial.rhtml → TODO.txt} +0 -0
  6. data/features/step_definitions/people.rb +6 -0
  7. data/features/support/env.rb +13 -0
  8. data/{stories/transactions_should_rollback → features/transactions/transactions_should_rollback.feature} +4 -3
  9. data/generators/rspec/rspec_generator.rb +0 -4
  10. data/generators/rspec/templates/rspec.rake +130 -104
  11. data/generators/rspec/templates/script/spec_server +17 -8
  12. data/generators/rspec/templates/spec_helper.rb +1 -1
  13. data/generators/rspec_default_values.rb +3 -3
  14. data/generators/rspec_scaffold/templates/edit_erb_spec.rb +7 -6
  15. data/generators/rspec_scaffold/templates/index_erb_spec.rb +9 -8
  16. data/generators/rspec_scaffold/templates/new_erb_spec.rb +7 -6
  17. data/generators/rspec_scaffold/templates/show_erb_spec.rb +9 -9
  18. data/lib/spec/rails.rb +14 -2
  19. data/lib/spec/rails/example/controller_example_group.rb +16 -23
  20. data/lib/spec/rails/example/cookies_proxy.rb +5 -1
  21. data/lib/spec/rails/example/functional_example_group.rb +17 -5
  22. data/lib/spec/rails/example/helper_example_group.rb +5 -4
  23. data/lib/spec/rails/example/rails_example_group.rb +10 -15
  24. data/lib/spec/rails/example/view_example_group.rb +5 -5
  25. data/lib/spec/rails/extensions.rb +1 -3
  26. data/lib/spec/rails/extensions/action_controller/base.rb +1 -1
  27. data/lib/spec/rails/extensions/action_controller/rescue.rb +9 -5
  28. data/lib/spec/rails/extensions/action_controller/test_response.rb +11 -2
  29. data/lib/spec/rails/extensions/action_view/base.rb +4 -2
  30. data/lib/spec/rails/extensions/active_record/base.rb +1 -2
  31. data/lib/spec/rails/extensions/spec/{example → runner}/configuration.rb +12 -7
  32. data/lib/spec/rails/matchers.rb +1 -0
  33. data/lib/spec/rails/matchers/ar_be_valid.rb +41 -0
  34. data/lib/spec/rails/matchers/redirect_to.rb +4 -2
  35. data/lib/spec/rails/matchers/render_template.rb +30 -10
  36. data/lib/spec/rails/mocks.rb +11 -8
  37. data/lib/spec/rails/version.rb +3 -2
  38. data/rspec-rails.gemspec +16 -8
  39. data/spec/{rails/autotest → autotest}/mappings_spec.rb +3 -3
  40. data/{spec_resources → spec/resources}/controllers/action_view_base_spec_controller.rb +0 -0
  41. data/spec/resources/controllers/application.rb +9 -0
  42. data/{spec_resources → spec/resources}/controllers/controller_spec_controller.rb +19 -6
  43. data/{spec_resources → spec/resources}/controllers/redirect_spec_controller.rb +7 -0
  44. data/{spec_resources → spec/resources}/controllers/render_spec_controller.rb +0 -0
  45. data/{spec_resources → spec/resources}/controllers/rjs_spec_controller.rb +0 -0
  46. data/{spec_resources → spec/resources}/helpers/addition_helper.rb +0 -0
  47. data/{spec_resources → spec/resources}/helpers/explicit_helper.rb +8 -0
  48. data/{spec_resources → spec/resources}/helpers/more_explicit_helper.rb +0 -0
  49. data/{spec_resources → spec/resources}/helpers/plugin_application_helper.rb +0 -0
  50. data/{spec_resources → spec/resources}/helpers/view_spec_helper.rb +0 -0
  51. data/spec/resources/models/animal.rb +4 -0
  52. data/spec/resources/models/person.rb +18 -0
  53. data/spec/resources/models/thing.rb +3 -0
  54. data/{spec_resources/views/controller_spec/action_setting_the_assigns_hash.rhtml → spec/resources/views/controller_spec/_partial.rhtml} +0 -0
  55. data/{spec_resources → spec/resources}/views/controller_spec/action_setting_flash_after_session_reset.rhtml +0 -0
  56. data/{spec_resources → spec/resources}/views/controller_spec/action_setting_flash_before_session_reset.rhtml +0 -0
  57. data/{spec_resources/views/layouts/application.rhtml → spec/resources/views/controller_spec/action_setting_the_assigns_hash.rhtml} +0 -0
  58. data/{spec_resources → spec/resources}/views/controller_spec/action_with_errors_in_template.rhtml +0 -0
  59. data/{spec_resources → spec/resources}/views/controller_spec/action_with_template.rhtml +0 -0
  60. data/{spec_resources/views/layouts/simple.rhtml → spec/resources/views/layouts/application.rhtml} +0 -0
  61. data/{spec_resources/views/render_spec/_a_partial.rhtml → spec/resources/views/layouts/simple.rhtml} +0 -0
  62. data/{spec_resources → spec/resources}/views/objects/_object.html.erb +0 -0
  63. data/{spec_resources/views/render_spec/action_with_alternate_layout.rhtml → spec/resources/views/render_spec/_a_partial.rhtml} +0 -0
  64. data/{spec_resources/views/render_spec/some_action.rhtml → spec/resources/views/render_spec/action_with_alternate_layout.rhtml} +0 -0
  65. data/{spec_resources/views/view_spec/_partial_used_twice.rhtml → spec/resources/views/render_spec/some_action.html.erb} +0 -0
  66. data/{spec_resources → spec/resources}/views/render_spec/some_action.js.rjs +0 -0
  67. data/{spec_resources → spec/resources}/views/render_spec/some_action.rjs +0 -0
  68. data/{spec_resources → spec/resources}/views/rjs_spec/_replacement_partial.rhtml +0 -0
  69. data/{spec_resources → spec/resources}/views/rjs_spec/hide_div.rjs +0 -0
  70. data/{spec_resources → spec/resources}/views/rjs_spec/hide_page_element.rjs +0 -0
  71. data/{spec_resources → spec/resources}/views/rjs_spec/insert_html.rjs +0 -0
  72. data/{spec_resources → spec/resources}/views/rjs_spec/replace.rjs +0 -0
  73. data/{spec_resources → spec/resources}/views/rjs_spec/replace_html.rjs +0 -0
  74. data/{spec_resources → spec/resources}/views/rjs_spec/replace_html_with_partial.rjs +0 -0
  75. data/{spec_resources → spec/resources}/views/rjs_spec/visual_effect.rjs +0 -0
  76. data/{spec_resources → spec/resources}/views/rjs_spec/visual_toggle_effect.rjs +0 -0
  77. data/{spec_resources → spec/resources}/views/tag_spec/no_tags.rhtml +0 -0
  78. data/{spec_resources → spec/resources}/views/tag_spec/single_div_with_no_attributes.rhtml +0 -0
  79. data/{spec_resources → spec/resources}/views/tag_spec/single_div_with_one_attribute.rhtml +0 -0
  80. data/{spec_resources → spec/resources}/views/view_spec/_partial.rhtml +0 -0
  81. data/spec/resources/views/view_spec/_partial_used_twice.rhtml +0 -0
  82. data/{spec_resources → spec/resources}/views/view_spec/_partial_with_local_variable.rhtml +0 -0
  83. data/{spec_resources → spec/resources}/views/view_spec/_partial_with_sub_partial.rhtml +0 -0
  84. data/{spec_resources → spec/resources}/views/view_spec/_spacer.rhtml +0 -0
  85. data/{spec_resources → spec/resources}/views/view_spec/accessor.rhtml +0 -0
  86. data/{spec_resources → spec/resources}/views/view_spec/block_helper.rhtml +0 -0
  87. data/{spec_resources → spec/resources}/views/view_spec/entry_form.rhtml +0 -0
  88. data/{spec_resources → spec/resources}/views/view_spec/explicit_helper.rhtml +0 -0
  89. data/{spec_resources → spec/resources}/views/view_spec/foo/show.rhtml +0 -0
  90. data/{spec_resources → spec/resources}/views/view_spec/implicit_helper.rhtml +0 -0
  91. data/{spec_resources → spec/resources}/views/view_spec/multiple_helpers.rhtml +0 -0
  92. data/spec/resources/views/view_spec/path_params.html.erb +1 -0
  93. data/{spec_resources → spec/resources}/views/view_spec/should_not_receive.rhtml +0 -0
  94. data/{spec_resources → spec/resources}/views/view_spec/template_with_partial.rhtml +0 -0
  95. data/{spec_resources → spec/resources}/views/view_spec/template_with_partial_using_collection.rhtml +0 -0
  96. data/{spec_resources → spec/resources}/views/view_spec/template_with_partial_with_array.rhtml +0 -0
  97. data/spec/{rails → spec/rails}/example/assigns_hash_proxy_spec.rb +1 -1
  98. data/spec/spec/rails/example/configuration_spec.rb +79 -0
  99. data/spec/{rails → spec/rails}/example/controller_isolation_spec.rb +1 -7
  100. data/spec/{rails → spec/rails}/example/controller_spec_spec.rb +63 -6
  101. data/spec/{rails → spec/rails}/example/cookies_proxy_spec.rb +30 -13
  102. data/spec/{rails → spec/rails}/example/example_group_factory_spec.rb +1 -1
  103. data/spec/{rails → spec/rails}/example/helper_spec_spec.rb +28 -1
  104. data/spec/{rails → spec/rails}/example/model_spec_spec.rb +1 -1
  105. data/spec/{rails → spec/rails}/example/shared_behaviour_spec.rb +1 -1
  106. data/spec/{rails → spec/rails}/example/test_unit_assertion_accessibility_spec.rb +1 -1
  107. data/spec/{rails → spec/rails}/example/view_spec_spec.rb +22 -1
  108. data/spec/{rails → spec/rails}/extensions/action_controller_rescue_action_spec.rb +4 -1
  109. data/spec/{rails → spec/rails}/extensions/action_view_base_spec.rb +1 -1
  110. data/spec/{rails → spec/rails}/extensions/active_record_spec.rb +1 -1
  111. data/spec/{rails → spec/rails}/interop/testcase_spec.rb +6 -2
  112. data/spec/spec/rails/matchers/ar_be_valid_spec.rb +35 -0
  113. data/spec/{rails → spec/rails}/matchers/assert_select_spec.rb +1 -5
  114. data/spec/{rails → spec/rails}/matchers/errors_on_spec.rb +1 -1
  115. data/spec/{rails → spec/rails}/matchers/have_text_spec.rb +1 -1
  116. data/spec/{rails → spec/rails}/matchers/include_text_spec.rb +1 -1
  117. data/spec/{rails → spec/rails}/matchers/redirect_to_spec.rb +11 -2
  118. data/spec/{rails → spec/rails}/matchers/render_template_spec.rb +8 -4
  119. data/spec/{rails → spec/rails}/matchers/should_change_spec.rb +1 -1
  120. data/spec/{rails → spec/rails}/mocks/ar_classes.rb +0 -0
  121. data/spec/{rails → spec/rails}/mocks/mock_model_spec.rb +1 -1
  122. data/spec/{rails → spec/rails}/mocks/stub_model_spec.rb +1 -1
  123. data/spec/{rails → spec/rails}/sample_modified_fixture.rb +1 -1
  124. data/spec/{rails → spec/rails}/sample_spec.rb +1 -1
  125. data/spec/spec/rails/spec_server_spec.rb +96 -0
  126. data/spec/{rails → spec/rails}/spec_spec.rb +1 -1
  127. data/spec/spec_helper.rb +23 -14
  128. metadata +111 -100
  129. data/UPGRADE +0 -7
  130. data/generators/rspec/templates/all_stories.rb +0 -4
  131. data/generators/rspec/templates/stories_helper.rb +0 -3
  132. data/lib/spec/rails/extensions/object.rb +0 -5
  133. data/spec/rails/example/configuration_spec.rb +0 -83
  134. data/spec/rails/matchers/description_generation_spec.rb +0 -37
  135. data/spec/rails/spec_server_spec.rb +0 -96
  136. data/stories/all.rb +0 -10
  137. data/stories/configuration/stories.rb +0 -5
  138. data/stories/helper.rb +0 -6
  139. data/stories/steps/people.rb +0 -8
  140. data/stories/transactions_should_rollback.rb +0 -25
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Rails
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  describe "A shared view example_group", :shared => true do
4
4
  it "should have some tag with some text" do
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  describe "assert_equal", :shared => true do
4
4
  it "like assert_equal" do
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  describe "A template with an implicit helper", :type => :view do
4
4
  before(:each) do
@@ -249,6 +249,27 @@ describe "render 'view_spec/foo/show.rhtml'", :type => :view do
249
249
  end
250
250
  end
251
251
 
252
+ describe "setting path parameters", :type => :view do
253
+ describe "(controller)" do
254
+ it "should supercede the default path parameters" do
255
+ render "view_spec/entry_form", :path_parameters => {:controller => 'foo'}
256
+ request.path_parameters[:controller].should == 'foo'
257
+ end
258
+ end
259
+ describe "(action)" do
260
+ it "should supercede the default path parameters" do
261
+ render "view_spec/entry_form", :path_parameters => {:action => 'foo'}
262
+ request.path_parameters[:action].should == 'foo'
263
+ end
264
+ end
265
+ describe "(something arbitrary)" do
266
+ it "should supercede the default path parameters" do
267
+ render "view_spec/entry_form", :path_parameters => {:foo => 'bar'}
268
+ request.path_parameters[:foo].should == 'bar'
269
+ end
270
+ end
271
+ end
272
+
252
273
  module Spec
253
274
  module Rails
254
275
  module Example
@@ -1,10 +1,13 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  module ActionController
4
4
  describe "Rescue", "#rescue_action in default mode" do
5
5
  before(:each) do
6
6
  @fixture = Object.new
7
7
  @fixture.extend ActionController::Rescue
8
+ def @fixture.rescue_with_handler(exception)
9
+ false
10
+ end
8
11
  class << @fixture
9
12
  public :rescue_action
10
13
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
  require 'spec/mocks/errors'
3
3
 
4
4
  describe ActionView::Base, "with RSpec extensions:", :type => :view do
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  describe "A model" do
4
4
  fixtures :things
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
 
4
4
  if ActiveSupport.const_defined?(:Callbacks) && Test::Unit::TestCase.include?(ActiveSupport::Callbacks)
@@ -17,6 +17,10 @@ if ActiveSupport.const_defined?(:Callbacks) && Test::Unit::TestCase.include?(Act
17
17
  def self.run?
18
18
  @@has_been_run
19
19
  end
20
+
21
+ def self.run(options=Spec::Runner.options)
22
+ super options
23
+ end
20
24
 
21
25
  def do_some_setup
22
26
  @@setup_callback_count += 1
@@ -63,4 +67,4 @@ if ActiveSupport.const_defined?(:Callbacks) && Test::Unit::TestCase.include?(Act
63
67
  end
64
68
  end
65
69
 
66
- end
70
+ end
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe "be_valid" do
4
+ class CanBeValid
5
+ def initialize(valid)
6
+ @valid = valid
7
+ end
8
+ def valid?; @valid end
9
+ end
10
+
11
+ it "should behave like normal be_valid matcher" do
12
+ CanBeValid.new(true).should be_valid
13
+ CanBeValid.new(false).should_not be_valid
14
+ end
15
+
16
+ class CanHaveErrors
17
+ def initialize(errors)
18
+ @valid = !errors
19
+ @errors = ActiveRecord::Errors.new self
20
+ @errors.add :name, "is too short"
21
+ end
22
+ attr_reader :errors
23
+ def valid?; @valid end
24
+
25
+ def self.human_attribute_name(ignore)
26
+ "Name"
27
+ end
28
+ end
29
+
30
+ it "should show errors in the output if they're available" do
31
+ lambda {
32
+ CanHaveErrors.new(true).should be_valid
33
+ }.should fail_with(/Name is too short/)
34
+ end
35
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  # assert_select plugins for Rails
4
4
  #
@@ -35,10 +35,6 @@ class AssertSelectController < ActionController::Base
35
35
  @content = nil
36
36
  end
37
37
 
38
- def rescue_action(e)
39
- raise e
40
- end
41
-
42
38
  end
43
39
 
44
40
  class AssertSelectMailer < ActionMailer::Base
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  describe "error_on" do
4
4
  it "should provide a description including the name of what the error is on" do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  describe "have_text" do
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  describe "include_text" do
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  ['isolation','integration'].each do |mode|
4
4
  describe "redirect_to behaviour", :type => :controller do
@@ -202,7 +202,16 @@ require File.dirname(__FILE__) + '/../../spec_helper'
202
202
  route = {:controller => "nonexistant", :action => "none"}
203
203
  lambda {
204
204
  response.should redirect_to(route)
205
- }.should raise_error(ActionController::RoutingError, /(no route found to match|No route matches) \"\/nonexistant\/none\" with \{\}/)
205
+ }.should raise_error(ActionController::RoutingError, /(no route found to match|No route matches) \"\/nonexistant\/none\" with \{.*\}/)
206
+ end
207
+
208
+ it "provides a description" do
209
+ redirect_to("foo/bar").description.should == %q|redirect to "foo/bar"|
210
+ end
211
+
212
+ it "redirects to action with http method restriction" do
213
+ post 'action_to_redirect_to_action_with_method_restriction'
214
+ response.should redirect_to(:action => 'action_with_method_restriction')
206
215
  end
207
216
 
208
217
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  ['isolation','integration'].each do |mode|
4
4
  describe "response.should render_template (in #{mode} mode)",
@@ -51,14 +51,14 @@ require File.dirname(__FILE__) + '/../../spec_helper'
51
51
  post 'some_action'
52
52
  lambda do
53
53
  response.should render_template('non_existent_template')
54
- end.should fail_with(/expected \"non_existent_template\", got \"render_spec\/some_action(.rhtml)?\"/)
54
+ end.should fail_with(/expected \"non_existent_template\", got \"render_spec\/some_action(\.html\.erb)?\"/)
55
55
  end
56
56
 
57
57
  it "should fail without full path when template is associated with a different controller" do
58
58
  post 'action_which_renders_template_from_other_controller'
59
59
  lambda do
60
60
  response.should render_template('action_with_template')
61
- end.should fail_with(/expected \"action_with_template\", got \"controller_spec\/action_with_template(.rhtml)?\"/)
61
+ end.should fail_with(/expected \"action_with_template\", got \"controller_spec\/action_with_template(\.rhtml)?\"/)
62
62
  end
63
63
 
64
64
  it "should fail with incorrect full path when template is associated with a different controller" do
@@ -72,7 +72,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
72
72
  get 'some_action'
73
73
  lambda {
74
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(\.rhtml)?\"/)
75
+ }.should fail_with(/expected \"render_spec\/some_action\.rjs\", got \"render_spec\/some_action(\.html\.erb)?\"/)
76
76
  end
77
77
 
78
78
  it "should fail when TEXT is rendered" do
@@ -88,6 +88,10 @@ require File.dirname(__FILE__) + '/../../spec_helper'
88
88
  response.should render_template('action_with_alternate_layout')
89
89
  end
90
90
  end
91
+
92
+ it "provides a description" do
93
+ render_template("foo/bar").description.should == %q|render template "foo/bar"|
94
+ end
91
95
  end
92
96
 
93
97
  describe "response.should_not render_template (in #{mode} mode)",
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  describe "should change" do
4
4
  describe "handling association proxies" do
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
  require File.dirname(__FILE__) + '/ar_classes'
3
3
 
4
4
  describe "mock_model" do
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
  require File.dirname(__FILE__) + '/ar_classes'
3
3
 
4
4
  describe "stub_model" do
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
2
 
3
3
  describe "A sample spec", :type => :model do
4
4
  fixtures :animals
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
2
 
3
3
  describe "A sample spec", :type => :model do
4
4
  fixtures :animals
@@ -0,0 +1,96 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe "script/spec_server file", :shared => true do
4
+ attr_accessor :tmbundle_install_directory
5
+ attr_reader :animals_yml_path, :original_animals_content
6
+
7
+ before do
8
+ @animals_yml_path = File.expand_path("#{RAILS_ROOT}/spec/fixtures/animals.yml")
9
+ @original_animals_content = File.read(animals_yml_path)
10
+ end
11
+
12
+ after do
13
+ File.open(animals_yml_path, "w") do |f|
14
+ f.write original_animals_content
15
+ end
16
+ end
17
+
18
+ after(:each) do
19
+ system "lsof -i tcp:8989 | sed /COMMAND/d | awk '{print $2}' | xargs kill"
20
+ end
21
+
22
+ it "runs a spec" do
23
+ dir = File.expand_path(File.dirname(__FILE__))
24
+ output = ""
25
+ Timeout.timeout(10) do
26
+ loop do
27
+ output = `#{RAILS_ROOT}/script/spec #{dir}/sample_spec.rb --drb 2>&1`
28
+ break unless output.include?("No server is running")
29
+ end
30
+ end
31
+
32
+ if $?.exitstatus != 0 || output !~ /0 failures/
33
+ flunk "command 'script/spec spec/sample_spec' failed\n#{output}"
34
+ end
35
+
36
+ fixtures = YAML.load(@original_animals_content)
37
+ fixtures['pig']['name'] = "Piggy"
38
+
39
+ File.open(animals_yml_path, "w") do |f|
40
+ f.write YAML.dump(fixtures)
41
+ end
42
+
43
+ Timeout.timeout(10) do
44
+ loop do
45
+ output = `#{RAILS_ROOT}/script/spec #{dir}/sample_modified_fixture.rb --drb 2>&1`
46
+ break unless output.include?("No server is running")
47
+ end
48
+ end
49
+
50
+ if $?.exitstatus != 0 || output !~ /0 failures/
51
+ flunk "command 'script/spec spec/sample_modified_fixture' failed\n#{output}"
52
+ end
53
+ end
54
+
55
+ def start_spec_server
56
+ dir = File.dirname(__FILE__)
57
+ Thread.start do
58
+ system "cd #{RAILS_ROOT}; script/spec_server"
59
+ end
60
+
61
+ file_content = ""
62
+ end
63
+ end
64
+
65
+ describe "script/spec_server file without TextMate bundle" do
66
+ it_should_behave_like "script/spec_server file"
67
+ before(:each) do
68
+ start_spec_server
69
+ end
70
+ end
71
+
72
+ describe "script/spec_server file with TextMate bundle" do
73
+ it_should_behave_like "script/spec_server file"
74
+ before(:each) do
75
+ dir = File.dirname(__FILE__)
76
+ @tmbundle_install_directory = File.expand_path("#{Dir.tmpdir}/Library/Application Support/TextMate/Bundles")
77
+ @bundle_name = "RSpec.tmbundle"
78
+ 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}"|)
82
+ raise "Creating link to Textmate Bundle"
83
+ end
84
+ start_spec_server
85
+ end
86
+
87
+ after(:each) do
88
+ bundle_file_to_remove = "#{tmbundle_install_directory}/#{@bundle_name}"
89
+ if bundle_file_to_remove == "/"
90
+ raise "bundle file path resolved to '/' - could not call rm"
91
+ end
92
+ unless system(%Q|rm "#{bundle_file_to_remove}"|)
93
+ raise "Removing Textmate bundle link failed"
94
+ end
95
+ end
96
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
2
 
3
3
  describe "script/spec file" do
4
4
  it "should run a spec" do
@@ -1,19 +1,24 @@
1
1
  dir = File.dirname(__FILE__)
2
2
  $LOAD_PATH.unshift(File.expand_path("#{dir}/../rspec/lib"))
3
- $LOAD_PATH.unshift(File.expand_path("#{dir}/../spec_resources/controllers"))
4
- $LOAD_PATH.unshift(File.expand_path("#{dir}/../spec_resources/helpers"))
3
+ $LOAD_PATH.unshift(File.expand_path("#{dir}/resources/controllers"))
4
+ $LOAD_PATH.unshift(File.expand_path("#{dir}/resources/helpers"))
5
5
  require File.expand_path("#{dir}/../../../../spec/spec_helper")
6
- require File.expand_path("#{dir}/../spec_resources/controllers/render_spec_controller")
7
- require File.expand_path("#{dir}/../spec_resources/controllers/rjs_spec_controller")
8
- require File.expand_path("#{dir}/../spec_resources/controllers/redirect_spec_controller")
9
- require File.expand_path("#{dir}/../spec_resources/controllers/action_view_base_spec_controller")
10
- require File.expand_path("#{dir}/../spec_resources/helpers/addition_helper")
11
- require File.expand_path("#{dir}/../spec_resources/helpers/explicit_helper")
12
- require File.expand_path("#{dir}/../spec_resources/helpers/more_explicit_helper")
13
- require File.expand_path("#{dir}/../spec_resources/helpers/view_spec_helper")
14
- require File.expand_path("#{dir}/../spec_resources/helpers/plugin_application_helper")
15
-
16
- extra_controller_paths = File.expand_path("#{dir}/../spec_resources/controllers")
6
+ require File.expand_path("#{dir}/resources/controllers/application")
7
+ require File.expand_path("#{dir}/resources/controllers/render_spec_controller")
8
+ require File.expand_path("#{dir}/resources/controllers/rjs_spec_controller")
9
+ require File.expand_path("#{dir}/resources/controllers/redirect_spec_controller")
10
+ require File.expand_path("#{dir}/resources/controllers/action_view_base_spec_controller")
11
+ require File.expand_path("#{dir}/resources/helpers/addition_helper")
12
+ require File.expand_path("#{dir}/resources/helpers/explicit_helper")
13
+ require File.expand_path("#{dir}/resources/helpers/more_explicit_helper")
14
+ require File.expand_path("#{dir}/resources/helpers/view_spec_helper")
15
+ require File.expand_path("#{dir}/resources/helpers/plugin_application_helper")
16
+
17
+ require File.expand_path("#{dir}/resources/models/animal")
18
+ require File.expand_path("#{dir}/resources/models/person")
19
+ require File.expand_path("#{dir}/resources/models/thing")
20
+
21
+ extra_controller_paths = File.expand_path("#{dir}/resources/controllers")
17
22
 
18
23
  unless ActionController::Routing.controller_paths.include?(extra_controller_paths)
19
24
  ActionController::Routing.instance_eval {@possible_controllers = nil}
@@ -24,7 +29,7 @@ module Spec
24
29
  module Rails
25
30
  module Example
26
31
  class ViewExampleGroupController
27
- set_view_path File.join(File.dirname(__FILE__), "..", "spec_resources", "views")
32
+ set_view_path File.join(File.dirname(__FILE__), "..", "spec", "resources", "views")
28
33
  end
29
34
  end
30
35
  end
@@ -50,7 +55,11 @@ Spec::Runner.configure do |config|
50
55
  end
51
56
 
52
57
 
58
+ ActionController::Routing::Routes.clear! # only since we're drawing routes here
53
59
  ActionController::Routing::Routes.draw do |map|
60
+ map.connect 'action_with_method_restriction', :controller => 'redirect_spec', :action => 'action_with_method_restriction', :conditions => { :method => :get }
61
+ map.connect 'action_to_redirect_to_action_with_method_restriction', :controller => 'redirect_spec', :action => 'action_to_redirect_to_action_with_method_restriction'
62
+
54
63
  map.resources :rspec_on_rails_specs
55
64
  map.connect 'custom_route', :controller => 'custom_route_spec', :action => 'custom_route'
56
65
  map.connect ":controller/:action/:id"