Logo: Relish

  1. Sign in

Project: RSpec Rails 3.0

URL helpers in mailer examples

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

describe Notifications 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
using URL helpers without default options
Given
a file named "config/initializers/mailer_defaults.rb" with:
# no default options
And
a file named "spec/mailers/notifications_spec.rb" with:
require 'rails_helper'

describe Notifications 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

Last published about 5 years ago by myronmarston.