Permalink
Browse files

Add controller attr_reader to controller specs

Closes #39
  • Loading branch information...
1 parent 8868bb8 commit 10c66e28e9381851d8e8c6a8ad2386978aefa8c5 @dchelimsky dchelimsky committed Apr 28, 2010
Showing with 26 additions and 2 deletions.
  1. +1 −0 cucumber.yml
  2. +18 −0 features/controller_specs/readers.feature
  3. +7 −2 lib/rspec/rails/example/controller_example_group.rb
View
1 cucumber.yml
@@ -0,0 +1 @@
+default: --require features
View
18 features/controller_specs/readers.feature
@@ -0,0 +1,18 @@
+Feature: controller spec readers
+
+ Controller specs expose a number of different
+ attribute readers.
+
+ Scenario: access controller
+ Given a file named "spec/controllers/widgets_controller_spec.rb" with:
+ """
+ require "spec_helper.rb"
+
+ describe WidgetsController do
+ it "is available before an action" do
+ controller.should be_an_instance_of(WidgetsController)
+ end
+ end
+ """
+ When I run "rspec ./spec"
+ Then I should see "1 example, 0 failures"
View
9 lib/rspec/rails/example/controller_example_group.rb
@@ -4,17 +4,22 @@
module ControllerExampleGroupBehaviour
extend ActiveSupport::Concern
- module ControllerClassReader
+ module ClassAttributeReaders
def controller_class
describes
end
end
+ module AttributeReaders
+ attr_reader :controller
+ end
+
included do
extend Rspec::Rails::SetupAndTeardownAdapter
include Rspec::Rails::TestUnitAssertionAdapter
include ActionController::TestCase::Behavior
- extend ControllerClassReader
+ extend ClassAttributeReaders
+ include AttributeReaders
include Webrat::Matchers
include Webrat::Methods
include Rspec::Matchers

0 comments on commit 10c66e2

Please sign in to comment.