Permalink
Browse files

Add config.render_views for global setting to render views.

- Closes #291.
  • Loading branch information...
1 parent 44c81aa commit da1c0cb2fb3351fc0483022bf19d88bc9280bbd1 @dchelimsky dchelimsky committed Dec 17, 2010
View
@@ -1,5 +1,12 @@
## rspec-rails-2 release history
+### 2.4.0 / in development
+
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.1...master)
+
+* Bug fixes
+ * restore global config.render_views so you only need to say it once
+
### 2.3.1 / 2010-12-16
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.0...v2.3.1)
@@ -102,7 +102,6 @@ Feature: render_views
When I run "rspec spec"
Then the output should contain "4 examples, 0 failures"
- @wip
Scenario: render_views globally
Given a file named "spec/support/render_views.rb" with:
"""
@@ -1,5 +1,19 @@
require 'action_view/testing/resolvers'
+RSpec.configure do |config|
+ config.add_setting :render_views, :default => false
+
+ # TODO - rspec-core needs a way to define a setting that works like this in
+ # one go
+ def config.render_views
+ settings[:render_views] = true
+ end
+
+ def config.render_views?
+ settings[:render_views]
+ end
+end
+
module RSpec
module Rails
module ViewRendering
@@ -21,7 +35,7 @@ def integrate_views
end
def render_views?
- !!metadata_for_rspec_rails[:render_views]
+ metadata_for_rspec_rails[:render_views] || RSpec.configuration.render_views?
end
end
@@ -0,0 +1,26 @@
+require "spec_helper"
+
+describe "configuration" do
+ before do
+ @orig_render_views = RSpec.configuration.render_views?
+ end
+
+ after do
+ RSpec.configuration.render_views = @orig_render_views
+ end
+
+ describe "#render_views?" do
+ it "is false by default" do
+ RSpec.configuration.render_views?.should be_false
+ end
+ end
+
+ describe "#render_views" do
+ it "sets render_views? to return true" do
+ RSpec.configuration.render_views = false
+ RSpec.configuration.render_views
+
+ RSpec.configuration.render_views?.should be_true
+ end
+ end
+end

2 comments on commit da1c0cb

jamiew commented on da1c0cb Dec 20, 2010

Awesome. This will trim many repetitive lines from my specs :)

Nice

Please sign in to comment.