fortitude 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.fix_bundler_for_jruby_17 +26 -0
  3. data/.gitignore +1 -0
  4. data/.travis.yml +33 -40
  5. data/CHANGES.md +44 -0
  6. data/CONTRIBUTORS.md +26 -0
  7. data/Rakefile +1 -1
  8. data/ext/com/fortituderuby/ext/fortitude/FortitudeNativeLibrary.java +45 -33
  9. data/ext/fortitude_native_ext/fortitude_native_ext.c +23 -23
  10. data/fortitude.gemspec +25 -8
  11. data/lib/fortitude/erector.rb +26 -18
  12. data/lib/fortitude/errors.rb +15 -4
  13. data/lib/fortitude/extensions/fortitude_ruby_ext.rb +35 -10
  14. data/lib/fortitude/rails/helpers.rb +59 -2
  15. data/lib/fortitude/rails/railtie.rb +238 -157
  16. data/lib/fortitude/rails/renderer.rb +15 -0
  17. data/lib/fortitude/rails/rendering_methods.rb +46 -33
  18. data/lib/fortitude/rails/template_handler.rb +49 -18
  19. data/lib/fortitude/rails/yielded_object_outputter.rb +3 -2
  20. data/lib/fortitude/rendering_context.rb +14 -5
  21. data/lib/fortitude/support/method_overriding.rb +90 -0
  22. data/lib/fortitude/support/staticized_method.rb +12 -0
  23. data/lib/fortitude/version.rb +1 -1
  24. data/lib/fortitude/widget/content.rb +4 -2
  25. data/lib/fortitude/widget/files.rb +17 -11
  26. data/lib/fortitude/widget/helpers.rb +7 -1
  27. data/lib/fortitude/widget/integration.rb +4 -0
  28. data/lib/fortitude/widget/localization.rb +63 -4
  29. data/lib/fortitude/widget/rendering.rb +17 -10
  30. data/lib/fortitude_jruby_native_ext.jar +0 -0
  31. data/spec/helpers/fortitude_rails_helpers.rb +26 -4
  32. data/spec/rails/capture_system_spec.rb +1 -1
  33. data/spec/rails/class_loading_system_spec.rb +16 -2
  34. data/spec/rails/complex_helpers_system_spec.rb +29 -0
  35. data/spec/rails/data_passing_system_spec.rb +2 -2
  36. data/spec/rails/development_mode_system_spec.rb +1 -1
  37. data/spec/rails/erector_coexistence_system_spec.rb +1 -1
  38. data/spec/rails/helpers_system_spec.rb +20 -2
  39. data/spec/rails/layouts_system_spec.rb +1 -1
  40. data/spec/rails/rendering_system_spec.rb +4 -4
  41. data/spec/rails/rules_system_spec.rb +2 -2
  42. data/spec/rails/templates/class_loading_system_spec/app/views/some_namespace/some_other_namespace/placeholder.rb +5 -0
  43. data/spec/rails/templates/complex_helpers_system_spec/app/controllers/complex_helpers_system_spec_controller.rb +4 -0
  44. data/spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/label_block_test.rb +9 -0
  45. data/spec/rails/templates/helpers_system_spec/app/controllers/helpers_system_spec_controller.rb +4 -0
  46. data/spec/rails/templates/helpers_system_spec/app/controllers/home_controller.rb +9 -0
  47. data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/rails_helpers_without_automatic_helper_access.rb +37 -0
  48. data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/url_helpers_without_automatic_helper_access.rb +45 -0
  49. data/spec/rails/templates/helpers_system_spec/config/initializers/host.rb +1 -0
  50. data/spec/rails/templates/helpers_system_spec/config/routes.rb +7 -0
  51. data/spec/rails/templates/static_method_system_spec/app/views/static_method_system_spec/localization.rb +1 -1
  52. data/spec/rails/templates/view_paths_system_spec/app/controllers/view_paths_system_spec_controller.rb +15 -0
  53. data/spec/rails/templates/view_paths_system_spec/config/application.rb +30 -0
  54. data/spec/rails/templates/view_paths_system_spec/view_path_one/baseone/basetwo/base_class_one.rb +5 -0
  55. data/spec/rails/templates/view_paths_system_spec/view_path_one/view_paths_system_spec/added_view_path.html.rb +5 -0
  56. data/spec/rails/templates/view_paths_system_spec/view_path_one/view_paths_system_spec/autoloading_from_added_view_path.html.rb +5 -0
  57. data/spec/rails/templates/view_paths_system_spec/view_path_two/view_paths_system_spec/added_view_path_from_controller.html.rb +5 -0
  58. data/spec/rails/templates/view_paths_system_spec/view_path_two/view_paths_system_spec/added_view_path_from_controller_with_impossible_to_guess_name.html.rb +14 -0
  59. data/spec/rails/view_paths_system_spec.rb +19 -0
  60. data/spec/system/escaping_system_spec.rb +10 -2
  61. data/spec/system/helpers_system_spec.rb +37 -6
  62. data/spec/system/inline_system_spec.rb +19 -0
  63. data/spec/system/static_method_system_spec.rb +16 -0
  64. data/spec/system/tag_rendering_system_spec.rb +4 -4
  65. data/spec/system/widget_class_from_spec.rb +39 -0
  66. data/spec/system/yield_system_spec.rb +53 -1
  67. metadata +54 -22
@@ -41,10 +41,16 @@ module Fortitude
41
41
  "effective_block = block"
42
42
  end
43
43
 
44
+ call_part = if source_method_name.to_s =~ /\=\s*$/
45
+ ".send(:#{source_method_name}, "
46
+ else
47
+ ".#{source_method_name}("
48
+ end
49
+
44
50
  text = <<-EOS
45
51
  def #{name}(*args, &block)
46
52
  #{block_transform}
47
- #{prefix}(@_fortitude_rendering_context.helpers_object.#{source_method_name}(*args, &effective_block))#{suffix}
53
+ #{prefix}(@_fortitude_rendering_context.helpers_object#{call_part}*args, &effective_block))#{suffix}
48
54
  end
49
55
  EOS
50
56
 
@@ -98,6 +98,10 @@ module Fortitude
98
98
  end
99
99
  end
100
100
 
101
+ _fortitude_on_class_inheritable_attribute_change(:translation_base) do |attribute_name, old_value, new_value|
102
+ ::Fortitude::Widget._fortitude_ensure_translation_base_supported_if_needed!
103
+ end
104
+
101
105
  _fortitude_on_class_inheritable_attribute_change(:start_and_end_comments) do |attribute_name, old_value, new_value|
102
106
  if new_value
103
107
  around_content :start_and_end_comments
@@ -8,13 +8,72 @@ module Fortitude
8
8
 
9
9
  LOCALIZED_CONTENT_PREFIX = "localized_content_"
10
10
 
11
- # PUBLIC API
12
- def t(key, *args)
11
+ # We do some funny voodoo here, for performance reasons. In localized Rails applications, #t
12
+ # ("translate this string") is called a LOT. Even small slowdowns in its performance can have a big impact.
13
+ # As such, we work hard to make this go fast.
14
+ #
15
+ # We'd like to support our .translation_base method, which prepends a translation base to any keys passed to #t
16
+ # that aren't globally specified (e.g., ".foo.bar", not "foo.bar"), but with as little overhead as possible.
17
+ # (Most people won't use that feature.) So here's what we do:
18
+ #
19
+ # - We create one method, #_fortitude_t_without_translation_base, that simply passes through to the helper
20
+ # method #t on whatever our helpers object is. This is the "fast" method.
21
+ # - We create a second method, #_fortutude_t_with_translation_base, that checks the translation_base and applies
22
+ # it as needed before calling through to the method #t on whatever our helpers object is. This is the "slow"
23
+ # method.
24
+ # - By default, we alias the fast method to #t. However, we also have a callback whenever translation_base
25
+ # is changed (_fortitude_on_class_inheritable_attribute_change(:translation_base), in
26
+ # lib/fortitude/widget/integration.rb) that calls our class method
27
+ # _fortitude_ensure_translation_base_supported_if_needed!. In turn, that checks recursively to see if _any_
28
+ # widget is using the translation_base feature, and, if so, aliases the slow method to #t -- otherwise, it
29
+ # aliases the fast method to #t.
30
+ #
31
+ # The net result is that we only have to use the slow method if anybody's actually using the translation_base
32
+ # feature. Otherwise, we can use the fast method. While both of them are plenty "fast" according to most
33
+ # standards, the difference in performance between them is significant enough (~10-15%) that it makes sense
34
+ # to perform this optimization. Again, real-world localized Rails applications call #t a _lot_.
35
+
36
+ # INTERNAL USE ONLY
37
+ def _fortitude_t_with_translation_base(key, *args)
13
38
  base = self.class.translation_base
14
39
  if base && key.to_s =~ /^\./
15
- super("#{base}#{key}", *args)
40
+ invoke_helper(:t, "#{base}#{key}", *args)
16
41
  else
17
- super(key, *args)
42
+ invoke_helper(:t, key, *args)
43
+ end
44
+ end
45
+
46
+ # INTERNAL USE ONLY
47
+ def _fortitude_t_without_translation_base(*args)
48
+ invoke_helper(:t, *args)
49
+ end
50
+
51
+ # PUBLIC API
52
+ alias_method :t, :_fortitude_t_without_translation_base
53
+
54
+ module ClassMethods
55
+ # INTERNAL USE ONLY
56
+ def _fortitude_ensure_translation_base_supported_if_needed!
57
+ unless equal?(::Fortitude::Widget)
58
+ raise ArgumentError, "You must only ever call this on Fortitude::Widget, not #{self}"
59
+ end
60
+
61
+ if _fortitude_translation_base_support_needed?
62
+ alias_method :t, :_fortitude_t_with_translation_base
63
+ else
64
+ alias_method :t, :_fortitude_t_without_translation_base
65
+ end
66
+ end
67
+
68
+ # INTERNAL USE ONLY
69
+ def _fortitude_translation_base_support_needed?
70
+ _fortitude_translation_base_support_needed_for_this_class? ||
71
+ (direct_subclasses.any?(&:_fortitude_translation_base_support_needed?))
72
+ end
73
+
74
+ # INTERNAL USE ONLY
75
+ def _fortitude_translation_base_support_needed_for_this_class?
76
+ translation_base && translation_base.to_s.strip.length > 0
18
77
  end
19
78
  end
20
79
 
@@ -28,11 +28,9 @@ module Fortitude
28
28
  @_fortitude_output_buffer_holder = rendering_context.output_buffer_holder
29
29
  @_fortitude_block_for_content_method = block_for_content_method
30
30
 
31
- block = lambda { |*args| yield_from_widget(*args) }
32
-
33
31
  rendering_context.record_widget(self) do
34
32
  begin
35
- run_content(&block)
33
+ run_content(&_fortitude_run_content_block)
36
34
  ensure
37
35
  @_fortitude_rendering_context = nil
38
36
  @_fortitude_block_for_content_method = nil
@@ -41,7 +39,8 @@ module Fortitude
41
39
  end
42
40
 
43
41
  # PUBLIC API
44
- def to_html(rendering_context = ::Fortitude::RenderingContext.new({ }))
42
+ def to_html(rendering_context = nil)
43
+ rendering_context ||= ::Fortitude::RenderingContext.default_rendering_context
45
44
  render_to(rendering_context)
46
45
  rendering_context.output_buffer_holder.output_buffer
47
46
  end
@@ -111,24 +110,32 @@ module Fortitude
111
110
  end
112
111
  private :_fortitude_class_for_new_buffer
113
112
 
114
- def _fortitude_yield_from_widget(*args)
113
+ # INTERNAL USE ONLY
114
+ def _fortitude_run_content_block
115
115
  if @_fortitude_block_for_content_method
116
- @_fortitude_block_for_content_method.call(*args)
116
+ @_fortitude_block_for_content_method
117
117
  elsif @_fortitude_constructor_block
118
- @_fortitude_constructor_block.call(self, *args)
118
+ lambda { |*args| @_fortitude_constructor_block.call(self, *args) }
119
+ elsif @_fortitude_rendering_context.effective_yield_block
120
+ @_fortitude_rendering_context.effective_yield_block
119
121
  else
120
- @_fortitude_rendering_context.yield_from_widget(self, *args)
122
+ nil
121
123
  end
122
124
  end
123
125
 
124
126
  # PUBLIC API
125
127
  def yield_from_widget(*args)
126
- _fortitude_yield_from_widget(*args)
128
+ block = _fortitude_run_content_block
129
+ if block
130
+ block.call(*args)
131
+ else
132
+ raise Fortitude::Errors::NoBlockToYieldTo.new(self)
133
+ end
127
134
  end
128
135
 
129
136
  # PUBLIC API (Erector compatibility)
130
137
  def call_block
131
- _fortitude_yield_from_widget
138
+ yield_from_widget
132
139
  end
133
140
  end
134
141
  end
Binary file
@@ -5,15 +5,37 @@ module Spec
5
5
  @rails_server_project_root ||= File.expand_path(File.join(File.dirname(__FILE__), '../..'))
6
6
  end
7
7
 
8
- def rails_server_additional_gemfile_lines
9
- [
10
- "gem 'fortitude', :path => '#{rails_server_project_root}'"
11
- ]
8
+ def rails_server_gemfile_modifier
9
+ Proc.new do |gemfile|
10
+ gemfile.set_specs!('fortitude', :path => rails_server_project_root)
11
+ end
12
12
  end
13
13
 
14
14
  def rails_server_default_version
15
15
  ENV['FORTITUDE_SPECS_RAILS_VERSION']
16
16
  end
17
+
18
+ def rails_server_wraps_template_errors?
19
+ !! (rails_server.actual_rails_version =~ /^5\./)
20
+ end
21
+
22
+ def expect_actionview_exception(subpath, class_name, message)
23
+ actual_class_expected = if rails_server_wraps_template_errors?
24
+ 'ActionView::Template::Error'
25
+ else
26
+ class_name
27
+ end
28
+
29
+ hash = expect_exception(subpath, actual_class_expected, message)
30
+
31
+ if rails_server_wraps_template_errors?
32
+ cause = hash['exception']['cause']
33
+ expect(cause).to be
34
+ expect(cause['class']).to eq(class_name.to_s)
35
+ end
36
+
37
+ hash
38
+ end
17
39
  end
18
40
  end
19
41
  end
@@ -23,7 +23,7 @@ describe "Rails capture support", :type => :rails do
23
23
  end
24
24
 
25
25
  it "should be able to provide content in a widget with provide" do
26
- skip "Rails 3.0.x doesn't support :provide" if rails_server.rails_version =~ /^3\.0\./
26
+ skip "Rails 3.0.x doesn't support :provide" if rails_server.actual_rails_version =~ /^3\.0\./
27
27
 
28
28
  expect_match('widget_provide',
29
29
  %r{erb_layout_needing_content}i,
@@ -12,6 +12,9 @@ describe "Rails class-loading support", :type => :rails do
12
12
  it "should not create anonymous modules without the Views:: namespace for directories under app/views/" do
13
13
  expect_exception('some_namespace', 'NameError', /uninitialized constant SomeNamespace/)
14
14
  expect_exception('some_other_namespace', 'NameError', /uninitialized constant SomeNamespace/)
15
+ end
16
+
17
+ it "should create anonymous modules in the Views:: namespace for directories under app/views/" do
15
18
  expect_match('views_some_namespace', /Views::SomeNamespace/, :no_layout => true)
16
19
  expect_match('views_some_other_namespace', /Views::SomeNamespace::SomeOtherNamespace/, :no_layout => true)
17
20
  end
@@ -32,12 +35,23 @@ describe "Rails class-loading support", :type => :rails do
32
35
  expect_match('use_models_widget_from_view_widget', /about to run the models widget.*this is the models widget.*ran the models widget/)
33
36
  end
34
37
 
38
+ def expect_no_template_error(subpath, controller_name, view_name)
39
+ # Rails 5 changed this: see https://github.com/rails/rails/issues/20666, https://github.com/rails/rails/issues/19036.
40
+ if rails_server.actual_rails_version =~ /^5\./
41
+ regexp = /#{(controller_name + "_controller").camelize}##{view_name.underscore}/
42
+ expect_exception(subpath, 'ActionController::UnknownFormat', regexp)
43
+ else
44
+ regexp = /#{controller_name.underscore}\/#{view_name.underscore}/
45
+ expect_exception(subpath, 'ActionView::MissingTemplate', regexp)
46
+ end
47
+ end
48
+
35
49
  it "should not allow me to define widgets outside of app/views/" do
36
- expect_exception('widget_defined_outside_app_views', 'ActionView::MissingTemplate', /class_loading_system_spec\/widget_defined_outside_app_views/)
50
+ expect_no_template_error('widget_defined_outside_app_views', 'class_loading_system_spec', 'widget_defined_outside_app_views')
37
51
  end
38
52
 
39
53
  it "should not let me define a widget in a file starting with an underscore, and use it for a view" do
40
- expect_exception('underscore_view', 'ActionView::MissingTemplate', /class_loading_system_spec\/underscore_view/)
54
+ expect_no_template_error('underscore_view', 'class_loading_system_spec', 'underscore_view')
41
55
  end
42
56
 
43
57
  it "should prefer widgets defined in a file without an underscore to those with" do
@@ -38,6 +38,35 @@ describe "Rails complex helper support", :type => :rails do
38
38
  OUTSIDE_AFTER}mix)
39
39
  end
40
40
 
41
+ it "should render a block passed to a label correctly" do
42
+ # See https://stackoverflow.com/questions/6088348/passing-block-to-label-helper-in-rails3.
43
+ #
44
+ # With a brand-new install of Rails 3.1.12, and *without* Fortitude installed, the following ERb code:
45
+ #
46
+ # <%= form_for :person do |f| %>
47
+ # <%= f.label(:name) do %>
48
+ # Foo
49
+ # <% end %>
50
+ # <% end %>
51
+ #
52
+ # ...results in the following output:
53
+ #
54
+ # Foo
55
+ # <label for="person_name">
56
+ # Foo
57
+ # </label></form>
58
+ #
59
+ # ...which is clearly incorrect. (In other words, the inner 'Foo' gets generated and picked up twice.)
60
+ #
61
+ # In Rails 3.2 and after, this has been fixed, and works perfectly.
62
+ skip "Rails 3.0/3.1 have a bug with blocks passed to form_for->label" if rails_server.actual_rails_version =~ /^3\.[01]\./
63
+
64
+ expect_match("label_block_test",
65
+ %r{<label.*person_name.*>\s*
66
+ Foo\s*
67
+ </label>}mix)
68
+ end
69
+
41
70
  it "should cache based on a name properly" do
42
71
  expect_match("cache_test?a=a1&b=b1",
43
72
  /before_cache\(a1,b1\).*inside_cache\(a1,b1\).*after_cache\(a1,b1\)/mi)
@@ -18,7 +18,7 @@ describe "Rails data-passing support", :type => :rails do
18
18
  end
19
19
 
20
20
  it "should give you a reasonable error if you omit a variable" do
21
- expect_exception('omitted_variable', 'Fortitude::Errors::MissingNeed', /bar/)
21
+ expect_actionview_exception('omitted_variable', 'Fortitude::Errors::MissingNeed', /bar/)
22
22
  end
23
23
 
24
24
  it "should not propagate un-needed variables" do
@@ -34,7 +34,7 @@ describe "Rails data-passing support", :type => :rails do
34
34
  end
35
35
 
36
36
  it "should not propagate a controller variable through a view to a child widget without being explicitly passed" do
37
- expect_exception('parent_to_child_passing', 'Fortitude::Errors::MissingNeed', /foo/)
37
+ expect_actionview_exception('parent_to_child_passing', 'Fortitude::Errors::MissingNeed', /foo/)
38
38
  end
39
39
 
40
40
  it "should propagate a controller variable through a view to a child widget without being explicitly passed, if invoked using render :partial" do
@@ -17,7 +17,7 @@ describe "Rails development-mode support", :type => :rails do
17
17
  expect_match("reload_widget_with_html_extension", /with_html_extension.*helper: yo/)
18
18
  sleep 1
19
19
  splat_new_module_for_reload_widget_failing!
20
- expect_exception("reload_widget_with_html_extension", NameError, "some_helper")
20
+ expect_actionview_exception("reload_widget_with_html_extension", NameError, "some_helper")
21
21
  sleep 1
22
22
  splat_new_module_for_reload_widget!
23
23
  expect_match("reload_widget_with_html_extension", /with_html_extension.*helper: yo/)
@@ -1,5 +1,5 @@
1
1
  describe "Erector coexistence support", :type => :rails do
2
- uses_rails_with_template :erector_coexistence_system_spec, :additional_gemfile_lines => "gem 'erector'"
2
+ uses_rails_with_template :erector_coexistence_system_spec, :additional_gemfile_modifier => Proc.new { |gemfile| gemfile.ensure_gem!("erector") }
3
3
 
4
4
  begin
5
5
  gem 'erector'
@@ -2,12 +2,30 @@ describe "Rails helper support", :type => :rails do
2
2
  uses_rails_with_template :helpers_system_spec
3
3
 
4
4
  it "should support the built-in Rails helpers by default" do
5
+ skip("Rails 3.1 fails on this test with Ruby 2.3 only") if rails_server.actual_rails_version =~ /^3\.1\./ && RUBY_VERSION =~ /^2\.3\./
5
6
  expect_match("basic_helpers",
6
7
  /Three months ago: 3 months/mi,
7
8
  /A million dollars: \$1,000,000\.00/mi,
8
9
  %r{Select datetime:\s*<select.*name="date.*>.*<option.*value="2014".*</option>}mi)
9
10
  end
10
11
 
12
+ it 'should support built-in Rails helpers even when automatic_helper_access is false' do
13
+ expect_match("rails_helpers_without_automatic_helper_access",
14
+ /Excitedly: NoMethodError/mi,
15
+ /Three months ago: 3 months/mi,
16
+ /A million dollars: \$1,000,000\.00/mi,
17
+ /class=["']debug_dump["']/mi)
18
+ end
19
+
20
+ it 'should support url helpers even when automatic_helper_access is false' do
21
+ expect_match('url_helpers_without_automatic_helper_access',
22
+ /Excitedly: NoMethodError/mi,
23
+ /Root Path: \//,
24
+ /Foo Path: \/foo/,
25
+ /Foo Url: http:\/\/example.com(:\d+)?\/foo/,
26
+ /Foo Url with host override: http:\/\/override.com(:\d+)?\/foo/)
27
+ end
28
+
11
29
  it "should refine the built-in Rails helpers by default" do
12
30
  expect_match("helpers_that_output_when_refined",
13
31
  %r{START.*<img.*src="http://example.com/foo".*/><a href="mailto:test@example.com">test@example.com</a><link.*href="http://example.com/bar".*/>END}mi)
@@ -65,11 +83,11 @@ describe "Rails helper support", :type => :rails do
65
83
  end
66
84
 
67
85
  it "should allow turning off automatic helper access" do
68
- expect_match("automatic_helpers_disabled", %r{excitedly: NoMethodError; time_ago_in_words: NoMethodError; number_to_currency: \$1,000,000.00})
86
+ expect_match("automatic_helpers_disabled", %r{excitedly: NoMethodError; time_ago_in_words: 3 months; number_to_currency: \$1,000,000.00})
69
87
  end
70
88
 
71
89
  it "should inherit automatic helper access properly" do
72
- expect_match("automatic_helpers_inheritance", %r{C1: excitedly: NoMethodError; time_ago_in_words: NoMethodError; number_to_currency: \$1,000,000.00.*C2: excitedly: awesome!!!; time_ago_in_words: 3 months; number_to_currency: \$1,000,000.00})
90
+ expect_match("automatic_helpers_inheritance", %r{C1: excitedly: NoMethodError; time_ago_in_words: 3 months; number_to_currency: \$1,000,000.00.*C2: excitedly: awesome!!!; time_ago_in_words: 3 months; number_to_currency: \$1,000,000.00})
73
91
  end
74
92
 
75
93
  it "should allow access to private helpers in exactly the same way as ERb" do
@@ -41,7 +41,7 @@ describe "Rails layout support", :type => :rails do
41
41
  end
42
42
 
43
43
  it "should let you turn off the layout with render :widget" do
44
- unless rails_server.rails_version =~ /^3\.[01]\./
44
+ unless rails_server.actual_rails_version =~ /^3\.[01]\./
45
45
  # Rails 3.0 and 3.1 simply don't pass the ":layout => false" option specified in the controller through to
46
46
  # the renderer we add using ::ActionController.add_renderer. There's really nothing we can do about this,
47
47
  # so we let this one particular case fail; it seems like a bug in Rails, not in our code.
@@ -37,7 +37,7 @@ describe "Rails rendering support", :type => :rails do
37
37
  end
38
38
 
39
39
  it "should let you omit the layout with 'render :widget =>', if you ask for it" do
40
- unless rails_server.rails_version =~ /^3\.[01]\./
40
+ unless rails_server.actual_rails_version =~ /^3\.[01]\./
41
41
  # Rails 3.0 and 3.1 simply don't pass the ":layout => false" option specified in the controller through to
42
42
  # the renderer we add using ::ActionController.add_renderer. There's really nothing we can do about this,
43
43
  # so we let this one particular case fail; it seems like a bug in Rails, not in our code.
@@ -53,12 +53,12 @@ describe "Rails rendering support", :type => :rails do
53
53
  end
54
54
 
55
55
  it "should let you render a widget with 'render \"foo\" and the full path'" do
56
- skip "Rails 4.2 makes this mean something different (render :template, vs. render :file)" unless rails_server.rails_version =~ /^(3\.|4\.[01]\.)/
56
+ skip "Rails 4.1/4.2 makes this mean something different (render :template, vs. render :file)" unless rails_server.actual_rails_version =~ /^(3\.|4\.0\.)/
57
57
  expect_match("render_widget_via_file_path", /hello from a widget named Fred/)
58
58
  end
59
59
 
60
60
  it "should let you render a widget with 'render \"foo\"' and the template path" do
61
- skip "Rails 4.2 enables this" if rails_server.rails_version =~ /^(3\.|4\.[01]\.)/
61
+ skip "Rails 4.2 enables this" if rails_server.actual_rails_version =~ /^(3\.|4\.[01]\.)/
62
62
  expect_match("render_widget_via_template_path", /hello, world/)
63
63
  end
64
64
 
@@ -194,7 +194,7 @@ describe "Rails rendering support", :type => :rails do
194
194
  end
195
195
 
196
196
  it "should let you stream from a widget that's in an ERb layout" do
197
- skip("Fortitude streaming test is not supported under Rails 3.0.x") if rails_server.rails_version =~ /^3\.0\./
197
+ skip("Fortitude streaming test is not supported under Rails 3.0.x") if rails_server.actual_rails_version =~ /^3\.0\./
198
198
  skip("Fortitude streaming test is not supported under Ruby 1.8") if RUBY_VERSION =~ /^1\.8\./
199
199
 
200
200
  chunks = collect_chunks("stream_widget_with_layout")
@@ -2,11 +2,11 @@ describe "Rails rules support", :type => :rails do
2
2
  uses_rails_with_template :rules_system_spec
3
3
 
4
4
  it "should be able to enforce tag-nesting rules in Rails" do
5
- expect_exception('invalidly_nested_tag', Fortitude::Errors::InvalidElementNesting, /div/)
5
+ expect_actionview_exception('invalidly_nested_tag', Fortitude::Errors::InvalidElementNesting, /div/)
6
6
  end
7
7
 
8
8
  it "should still enforce tag-nesting rules inside a partial" do
9
- expect_exception('invalidly_nested_tag_in_partial', Fortitude::Errors::InvalidElementNesting, /div/)
9
+ expect_actionview_exception('invalidly_nested_tag_in_partial', Fortitude::Errors::InvalidElementNesting, /div/)
10
10
  end
11
11
 
12
12
  it "should not enforce tag-nesting rules at the start of a partial rendered from ERb" do
@@ -0,0 +1,5 @@
1
+ class Views::SomeNamespace::SomeOtherNamespace::Placeholder < Fortitude::Widgets::Html5
2
+ def content
3
+ raise "this should never be called"
4
+ end
5
+ end