File: inferred_controller_path.feature

package info (click to toggle)
ruby-rspec-rails 7.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,796 kB
  • sloc: ruby: 11,068; sh: 198; makefile: 6
file content (44 lines) | stat: -rw-r--r-- 1,398 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Feature: View specs infer controller's path and action

  Scenario: Infer controller path
    Given a file named "spec/views/widgets/new.html.erb_spec.rb" with:
      """ruby
      require "rails_helper"

      RSpec.describe "widgets/new" , type: :view do
        it "infers the controller path" do
          expect(controller.request.path_parameters[:controller]).to eq("widgets")
          expect(controller.controller_path).to eq("widgets")
        end
      end
      """
    When I run `rspec spec/views`
    Then the examples should all pass

  Scenario: Infer action
    Given a file named "spec/views/widgets/new.html.erb_spec.rb" with:
      """ruby
      require "rails_helper"

      RSpec.describe "widgets/new" , type: :view do
        it "infers the controller action" do
          expect(controller.request.path_parameters[:action]).to eq("new")
        end
      end
      """
    When I run `rspec spec/views`
    Then the examples should all pass

  Scenario: Do not infer action in a partial
    Given a file named "spec/views/widgets/_form.html.erb_spec.rb" with:
      """ruby
      require "rails_helper"

      RSpec.describe "widgets/_form" , type: :view do
        it "includes a link to new" do
          expect(controller.request.path_parameters[:action]).to be_nil
        end
      end
      """
    When I run `rspec spec/views`
    Then the examples should all pass