File: url_helpers.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 (41 lines) | stat: -rw-r--r-- 1,403 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
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/mailers`.

  Scenario: Using URL helpers with default options
    Given a file named "config/initializers/mailer_defaults.rb" with:
      """ruby
      Rails.configuration.action_mailer.default_url_options = { :host => 'example.com' }
      """
    And a file named "spec/mailers/notifications_spec.rb" with:
      """ruby
      require 'rails_helper'

      RSpec.describe NotificationsMailer, type: :mailer do
        it 'should have access to URL helpers' do
          expect { gadgets_url }.not_to raise_error
        end
      end
      """
    When I run `rspec spec`
    Then the examples should all pass

  Scenario: Using URL helpers without default options
    Given a file named "config/initializers/mailer_defaults.rb" with:
      """ruby
      # no default options
      """
    And a file named "spec/mailers/notifications_spec.rb" with:
      """ruby
      require 'rails_helper'

      RSpec.describe NotificationsMailer, 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
        end
      end
      """
    When I run `rspec spec`
    Then the examples should all pass