Skip to content

Commit 113879b

Browse files
author
Sam Phippen
committed
Add rails 5 and rails 5 support cukes.
1 parent 024cf44 commit 113879b

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

Rakefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ RSpec::Core::RakeTask.new(:spec) do |t|
1717
t.rspec_opts = %w[--color]
1818
end
1919

20-
Cucumber::Rake::Task.new(:cucumber)
20+
Cucumber::Rake::Task.new(:cucumber) do |t|
21+
version = ENV.fetch("RAILS_VERSION", "~> 4.2.0")
22+
cucumber_flag = "--tags ~@rails_post_5"
23+
if / 5(\.|-)0/ === version || version == "master"
24+
cucumber_flag = "--tags ~@rails_pre_5"
25+
end
26+
27+
t.cucumber_opts = cucumber_flag
28+
end
2129

2230
namespace :generate do
2331
desc "generate a fresh app with rspec installed"

features/mailer_specs/url_helpers.feature

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Feature: URL helpers in mailer examples
33
Mailer specs are marked by `:type => :mailer` or if you have set
44
`config.infer_spec_type_from_file_location!` by placing them in `spec/mailer`.
55

6+
@rails_post_5
67
Scenario: using URL helpers with default options
78
Given a file named "config/initializers/mailer_defaults.rb" with:
89
"""ruby
@@ -21,6 +22,7 @@ Feature: URL helpers in mailer examples
2122
When I run `rspec spec`
2223
Then the examples should all pass
2324

25+
@rails_post_5
2426
Scenario: using URL helpers without default options
2527
Given a file named "config/initializers/mailer_defaults.rb" with:
2628
"""ruby
@@ -39,3 +41,42 @@ Feature: URL helpers in mailer examples
3941
"""
4042
When I run `rspec spec`
4143
Then the examples should all pass
44+
45+
@rails_pre_5
46+
Scenario: using URL helpers with default options
47+
Given a file named "config/initializers/mailer_defaults.rb" with:
48+
"""ruby
49+
Rails.configuration.action_mailer.default_url_options = { :host => 'example.com' }
50+
"""
51+
And a file named "spec/mailers/notifications_spec.rb" with:
52+
"""ruby
53+
require 'rails_helper'
54+
55+
RSpec.describe Notifications, :type => :mailer do
56+
it 'should have access to URL helpers' do
57+
expect { gadgets_url }.not_to raise_error
58+
end
59+
end
60+
"""
61+
When I run `rspec spec`
62+
Then the examples should all pass
63+
64+
@rails_pre_5
65+
Scenario: using URL helpers without default options
66+
Given a file named "config/initializers/mailer_defaults.rb" with:
67+
"""ruby
68+
# no default options
69+
"""
70+
And a file named "spec/mailers/notifications_spec.rb" with:
71+
"""ruby
72+
require 'rails_helper'
73+
74+
RSpec.describe Notifications, :type => :mailer do
75+
it 'should have access to URL helpers' do
76+
expect { gadgets_url :host => 'example.com' }.not_to raise_error
77+
expect { gadgets_url }.to raise_error
78+
end
79+
end
80+
"""
81+
When I run `rspec spec`
82+
Then the examples should all pass

0 commit comments

Comments
 (0)