Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Small cleanups for #911

  • Loading branch information...
commit 910993e8aebda3eeeb5996ae5ccb457a69b54480 1 parent 6be42c4
@alindeman alindeman authored
View
4 Changelog.md
@@ -5,12 +5,12 @@ Bug fixes
* Use `__send__` rather than `send` to prevent naming collisions (Bradley Schaefer)
* Supports Rails 4.1. (Andy Lindeman)
+* Routes are drawn correctly for anonymous controllers with abstract
+ parents. (Billy Chan)
Enhancements
* Improve be_valid matcher for non-ActiveModel::Errors implementations (Ben Hamill)
-* Named "anonymous" controllers now expose the derivied `controller_name`
- and draw routes accordingly. (Billy Chan)
Breaking Changes for 3.0.0:
View
12 lib/rspec/rails/example/controller_example_group.rb
@@ -60,15 +60,15 @@ def controller(base_class = nil, &body)
end
base_class ||= ApplicationController
- metadata[:example_group][:described_class] = Class.new(base_class)
-
- metadata[:example_group][:described_class].class_eval do
+ metadata[:example_group][:described_class] = Class.new(base_class) do
def self.name
- superclass == ApplicationController || superclass.abstract? ?
- "AnonymousController" : superclass.to_s
+ if superclass == ApplicationController || superclass.abstract?
+ "AnonymousController"
+ else
+ superclass.to_s
+ end
end
end
-
metadata[:example_group][:described_class].class_eval(&body)
before do
View
6 spec/rspec/rails/example/controller_example_group_spec.rb
@@ -122,8 +122,10 @@ module RSpec::Rails
end
it "sets name as AnonymousController the controller is abstract" do
- stub_const "BarsController", Class.new(::ApplicationController) { def self.abstract?; true; end }
- group.controller(BarsController) { }
+ abstract_controller = Class.new(::ApplicationController)
+ def abstract_controller.abstract?; true; end
+
+ group.controller(abstract_controller) { }
expect(controller_class.name).to eq "AnonymousController"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.