Skip to content

manually tag request specs to aid users #1190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions features/controller_specs/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Controller specs live in `spec/controllers` or any example group with
`:type => :controller`.
Controller specs are marked by `:type => :controller` or if you have set
`config.infer_spec_type_from_file_location!` by placing them in `spec/controllers`.

A controller spec is an RSpec wrapper for a Rails functional test
([ActionController::TestCase::Behavior](https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/test_case.rb)).
Expand Down
22 changes: 11 additions & 11 deletions features/controller_specs/anonymous_controller.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Feature: anonymous controller
c.infer_base_class_for_anonymous_controllers = false
end

RSpec.describe BaseController do
RSpec.describe BaseController, :type => :controller do
controller do
def index; end

Expand Down Expand Up @@ -48,7 +48,7 @@ Feature: anonymous controller
end
end

RSpec.describe ApplicationController do
RSpec.describe ApplicationController, :type => :controller do
controller do
def index
raise ApplicationController::AccessDenied
Expand Down Expand Up @@ -86,7 +86,7 @@ Feature: anonymous controller
end
end

RSpec.describe ApplicationControllerSubclass do
RSpec.describe ApplicationControllerSubclass, :type => :controller do
controller(ApplicationControllerSubclass) do
def index
raise ApplicationController::AccessDenied
Expand All @@ -113,7 +113,7 @@ Feature: anonymous controller

class ApplicationControllerSubclass < ApplicationController; end

RSpec.describe ApplicationControllerSubclass do
RSpec.describe ApplicationControllerSubclass, :type => :controller do
controller do
def index
render :text => "Hello World"
Expand All @@ -136,7 +136,7 @@ Feature: anonymous controller
class ApplicationController < ActionController::Base; end
class FoosController < ApplicationController; end

RSpec.describe "FoosController controller_name" do
RSpec.describe "FoosController controller_name", :type => :controller do
controller FoosController do
def index
@name = self.class.name
Expand Down Expand Up @@ -175,7 +175,7 @@ Feature: anonymous controller
end
end

RSpec.describe ApplicationController do
RSpec.describe ApplicationController, :type => :controller do
controller do
def index
render :nothing => true
Expand All @@ -197,7 +197,7 @@ Feature: anonymous controller
"""ruby
require "rails_helper"

RSpec.describe ApplicationController do
RSpec.describe ApplicationController, :type => :controller do
controller do
def index
render :text => "index called"
Expand Down Expand Up @@ -375,7 +375,7 @@ Feature: anonymous controller
"""ruby
require "rails_helper"

RSpec.describe ApplicationController do
RSpec.describe ApplicationController, :type => :controller do
controller do
def custom
render :text => "custom called"
Expand All @@ -400,7 +400,7 @@ Feature: anonymous controller

class FoosController < ApplicationController; end

RSpec.describe ApplicationController do
RSpec.describe ApplicationController, :type => :controller do
controller FoosController do
def custom
render :text => "custom called"
Expand Down Expand Up @@ -430,7 +430,7 @@ Feature: anonymous controller
end
end

RSpec.describe TopLevel::InnerSpace::FoosController do
RSpec.describe TopLevel::InnerSpace::FoosController, :type => :controller do
controller do
def index
@name = self.class.name
Expand Down Expand Up @@ -466,7 +466,7 @@ Feature: anonymous controller
match "/login" => "sessions#new", :as => "login", :via => "get"
end

RSpec.describe ApplicationController do
RSpec.describe ApplicationController, :type => :controller do
controller do
def index
redirect_to login_url
Expand Down
4 changes: 2 additions & 2 deletions features/controller_specs/bypass_rescue.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Feature: bypass rescue
require 'controllers/gadgets_controller_spec_context'
RSpec.describe GadgetsController do
RSpec.describe GadgetsController, :type => :controller do
before do
def controller.index
raise AccessDenied
Expand All @@ -55,7 +55,7 @@ Feature: bypass rescue
require 'controllers/gadgets_controller_spec_context'
RSpec.describe GadgetsController do
RSpec.describe GadgetsController, :type => :controller do
before do
def controller.index
raise AccessDenied
Expand Down
6 changes: 3 additions & 3 deletions features/controller_specs/controller_spec.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Feature: controller spec
"""ruby
require "rails_helper"

RSpec.describe WidgetsController do
RSpec.describe WidgetsController, :type => :controller do
describe "GET index" do
it "has a 200 status code" do
get :index
Expand All @@ -24,7 +24,7 @@ Feature: controller spec

RSpec.configure {|c| c.before { expect(controller).not_to be_nil }}

RSpec.describe WidgetsController do
RSpec.describe WidgetsController, :type => :controller do
describe "GET index" do
it "doesn't matter" do
end
Expand All @@ -46,7 +46,7 @@ Feature: controller spec

RSpec.configure {|c| c.include MyHelper }

RSpec.describe WidgetsController do
RSpec.describe WidgetsController, :type => :controller do
let(:my_variable) { 'is a value' }

describe 'something' do
Expand Down
2 changes: 1 addition & 1 deletion features/controller_specs/engine_routes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Feature: engine routes for controllers
end
end

RSpec.describe MyEngine::WidgetsController do
RSpec.describe MyEngine::WidgetsController, :type => :controller do
routes { MyEngine::Engine.routes }

it "redirects to a random widget" do
Expand Down
8 changes: 4 additions & 4 deletions features/controller_specs/isolation_from_views.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: views are stubbed by default
"""ruby
require "rails_helper"

RSpec.describe WidgetsController do
RSpec.describe WidgetsController, :type => :controller do
describe "index" do
it "renders the index template" do
get :index
Expand All @@ -35,7 +35,7 @@ Feature: views are stubbed by default
"""ruby
require "rails_helper"

RSpec.describe WidgetsController do
RSpec.describe WidgetsController, :type => :controller do
describe "index" do
it "renders the 'new' template" do
get :index
Expand All @@ -52,7 +52,7 @@ Feature: views are stubbed by default
"""ruby
require "rails_helper"

RSpec.describe ThingsController do
RSpec.describe ThingsController, :type => :controller do
describe "custom_action" do
it "renders an empty custom_action template" do
controller.prepend_view_path 'app/views'
Expand All @@ -72,7 +72,7 @@ Feature: views are stubbed by default
"""ruby
require "rails_helper"

RSpec.describe ThingsController do
RSpec.describe ThingsController, :type => :controller do
render_views

it "renders the real custom_action template" do
Expand Down
6 changes: 3 additions & 3 deletions features/controller_specs/render_views.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Feature: render_views
"""ruby
require "rails_helper"

RSpec.describe WidgetsController do
RSpec.describe WidgetsController, :type => :controller do
render_views

describe "GET index" do
Expand All @@ -27,7 +27,7 @@ Feature: render_views
"""ruby
require "rails_helper"

RSpec.describe WidgetsController do
RSpec.describe WidgetsController, :type => :controller do
context "with render_views" do
render_views

Expand Down Expand Up @@ -101,7 +101,7 @@ Feature: render_views
require "rails_helper"
require "support/render_views"

RSpec.describe WidgetsController do
RSpec.describe WidgetsController, :type => :controller do
describe "GET index" do
it "renders the index template" do
get :index
Expand Down
6 changes: 5 additions & 1 deletion features/feature_specs/feature_spec.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Feature: feature spec
through an application. They should drive the application only via its
external interface, usually web pages.

Feature specs are marked by `:type => :feature` or if you have set
`config.infer_spec_type_from_file_location!` by placing them in `spec/features`.

Feature specs require the [capybara](http://github.com/jnicklas/capybara)
gem, version 2.2.0 or later (we recommend 2.3.0 or later to avoid some
deprecation warnings). Refer to the [capybara API
Expand All @@ -14,7 +17,8 @@ Feature: feature spec
The `feature` and `scenario` DSL correspond to `describe` and `it`,
respectively. These methods are simply aliases that allow feature specs to
read more as [customer tests](http://c2.com/cgi/wiki?CustomerTest) and
[acceptance tests](http://c2.com/cgi/wiki?AcceptanceTest).
[acceptance tests](http://c2.com/cgi/wiki?AcceptanceTest). They set
`:type => :feature` automatically for you.

Scenario: specify creating a Widget by driving the application with capybara
Given a file named "spec/features/widget_management_spec.rb" with:
Expand Down
12 changes: 6 additions & 6 deletions features/helper_specs/helper_spec.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: helper spec

Helper specs live in `spec/helpers`, or any example group with `:type =>
:helper`.
Helper specs are marked by `:type => :helper` or if you have set
`config.infer_spec_type_from_file_location!` by placing them in `spec/helpers`.

Helper specs expose a `helper` object, which includes the helper module being
specified, the `ApplicationHelper` module (if there is one) and all of the
Expand All @@ -18,7 +18,7 @@ Feature: helper spec
"""ruby
require "rails_helper"

RSpec.describe ApplicationHelper do
RSpec.describe ApplicationHelper, :type => :helper do
describe "#page_title" do
it "returns the default title" do
expect(helper.page_title).to eq("RSpec is your friend")
Expand All @@ -42,7 +42,7 @@ Feature: helper spec
"""ruby
require "rails_helper"

RSpec.describe ApplicationHelper do
RSpec.describe ApplicationHelper, :type => :helper do
describe "#page_title" do
it "returns the instance variable" do
assign(:title, "My Title")
Expand All @@ -67,7 +67,7 @@ Feature: helper spec
"""ruby
require "rails_helper"

RSpec.describe WidgetsHelper do
RSpec.describe WidgetsHelper, :type => :helper do
describe "#widget_title" do
it "includes the app name" do
assign(:title, "This Widget")
Expand Down Expand Up @@ -100,7 +100,7 @@ Feature: helper spec
"""ruby
require "rails_helper"

RSpec.describe WidgetsHelper do
RSpec.describe WidgetsHelper, :type => :helper do
describe "#link_to_widget" do
it "links to a widget using its name" do
widget = Widget.create!(:name => "This Widget")
Expand Down
7 changes: 5 additions & 2 deletions features/mailer_specs/url_helpers.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Feature: URL helpers in mailer examples

Mailer specs are marked by `:type => :mailer` or if you have set
`config.infer_spec_type_from_file_location!` by placing them in `spec/mailer`.

Scenario: using URL helpers with default options
Given a file named "config/initializers/mailer_defaults.rb" with:
"""ruby
Expand All @@ -9,7 +12,7 @@ Feature: URL helpers in mailer examples
"""ruby
require 'rails_helper'

RSpec.describe Notifications do
RSpec.describe Notifications, :type => :mailer do
it 'should have access to URL helpers' do
expect { gadgets_url }.not_to raise_error
end
Expand All @@ -27,7 +30,7 @@ Feature: URL helpers in mailer examples
"""ruby
require 'rails_helper'

RSpec.describe Notifications do
RSpec.describe Notifications, :type => :mailer do
it 'should have access to URL helpers' do
expect { gadgets_url :host => 'example.com' }.not_to raise_error
expect { gadgets_url }.to raise_error
Expand Down
6 changes: 3 additions & 3 deletions features/model_specs/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Model specs live in `spec/models` or any example group with
`:type => :model`.
Model specs are marked by `:type => :model` or if you have set
`config.infer_spec_type_from_file_location!` by placing them in `spec/models`.

A model spec is a thin wrapper for an ActiveSupport::TestCase, and includes all
of the behavior and assertions that it provides, in addition to RSpec's own
Expand All @@ -9,7 +9,7 @@ behavior and expectations.

require "rails_helper"

RSpec.describe Post do
RSpec.describe Post, :type => :model do
context "with 2 or more comments" do
it "orders them in reverse chronologically" do
post = Post.create!
Expand Down
8 changes: 4 additions & 4 deletions features/model_specs/transactional_examples.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Feature: transactional examples
"""ruby
require "rails_helper"

RSpec.describe Widget do
RSpec.describe Widget, :type => :model do
it "has none to begin with" do
expect(Widget.count).to eq 0
end
Expand All @@ -37,7 +37,7 @@ Feature: transactional examples
c.use_transactional_examples = true
end

RSpec.describe Widget do
RSpec.describe Widget, :type => :model do
it "has none to begin with" do
expect(Widget.count).to eq 0
end
Expand Down Expand Up @@ -65,7 +65,7 @@ Feature: transactional examples
c.order = "defined"
end

RSpec.describe Widget do
RSpec.describe Widget, :type => :model do
it "has none to begin with" do
expect(Widget.count).to eq 0
end
Expand All @@ -90,7 +90,7 @@ Feature: transactional examples
"""ruby
require "rails_helper"

RSpec.describe Thing do
RSpec.describe Thing, :type => :model do
fixtures :things
it "fixture method defined" do
things(:one)
Expand Down
5 changes: 4 additions & 1 deletion features/request_specs/request_spec.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Feature: request spec
designed to drive behavior through the full stack, including routing
(provided by Rails) and without stubbing (that's up to you).

Request specs are marked by `:type => :request` or if you have set
`config.infer_spec_type_from_file_location!` by placing them in `spec/requests`.

With request specs, you can:

* specify a single request
Expand All @@ -28,7 +31,7 @@ Feature: request spec
"""ruby
require "rails_helper"

RSpec.describe "Widget management" do
RSpec.describe "Widget management", :type => :request do

it "creates a Widget and redirects to the Widget's page" do
get "/widgets/new"
Expand Down
4 changes: 2 additions & 2 deletions features/routing_specs/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Routing specs live in the `spec/routing` directory, or any example group with
`:type => :routing`.
Routing specs are marked by `:type => :routing` or if you have set
`config.infer_spec_type_from_file_location!` by placing them in `spec/routing`.

Simple apps with nothing but standard RESTful routes won't get much value from
routing specs, but they can provide significant value when used to specify
Expand Down
Loading