Skip to content

Commit b4c00c4

Browse files
author
Sam Phippen
committed
Merge pull request #1485 from rspec/attempt_to_run_rails_5
Setup to run Rails 5 builds, and fix a few issues.
2 parents 6c75c64 + 8581933 commit b4c00c4

File tree

9 files changed

+32
-12
lines changed

9 files changed

+32
-12
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ env:
5252
- RAILS_VERSION='~> 3.0.20'
5353

5454
matrix:
55+
include:
56+
# Rails 5.x only supports 2.2
57+
- rvm: 2.2.2
58+
env: RAILS_VERSION=master
5559
exclude:
5660
# 3.0.x is not supported on MRI 2.0+
5761
- rvm: 2.0.0
@@ -88,6 +92,9 @@ matrix:
8892
# MRI 2.2 is not supported on a few versions
8993
- rvm: 2.2
9094
env: RAILS_VERSION='~> 3.1.12'
95+
allow_failures:
96+
- rvm: 2.2.2
97+
env: RAILS_VERSION=master
9198
fast_finish: true
9299

93100
branches:

Gemfile-rails-dependencies

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ when /master/
1010
gem 'coffee-rails', :git => "git://github.com/rails/coffee-rails.git"
1111
gem 'rack', :git => 'git://github.com/rack/rack.git'
1212
gem 'i18n', :git => 'git://github.com/svenfuchs/i18n.git', :branch => 'master'
13+
gem 'sprockets', :git => 'git://github.com/rails/sprockets.git', :branch => 'master'
14+
gem 'sprockets-rails', :git => 'git://github.com/rails/sprockets-rails.git', :branch => 'master'
1315
when /stable$/
1416
gem "rails", :git => "git://github.com/rails/rails.git", :branch => version
1517
when nil, false, ""

lib/rspec/rails/fixture_support.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ module FixtureSupport
2222
# /TODO
2323

2424
self.fixture_path = RSpec.configuration.fixture_path
25-
self.use_transactional_fixtures = RSpec.configuration.use_transactional_fixtures
25+
if ::Rails::VERSION::STRING > '5'
26+
self.use_transactional_tests = RSpec.configuration.use_transactional_fixtures
27+
else
28+
self.use_transactional_fixtures = RSpec.configuration.use_transactional_fixtures
29+
end
2630
self.use_instantiated_fixtures = RSpec.configuration.use_instantiated_fixtures
2731
fixtures RSpec.configuration.global_fixtures if RSpec.configuration.global_fixtures
2832
end

lib/rspec/rails/matchers/have_http_status.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ def as_test_response(obj)
4141
# Acts As Capybara Session
4242
# Hack to support `Capybara::Session` without having to load
4343
# Capybara or catch `NameError`s for the undefined constants
44-
::ActionDispatch::TestResponse.new.tap do |resp|
44+
obj = ActionDispatch::Response.new.tap do |resp|
4545
resp.status = obj.status_code
4646
resp.headers = obj.response_headers
4747
resp.body = obj.body
4848
end
49+
::ActionDispatch::TestResponse.from_response(obj)
4950
else
5051
raise TypeError, "Invalid response type: #{obj}"
5152
end

rspec-rails.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ Gem::Specification.new do |s|
2525
s.cert_chain = [File.expand_path('~/.gem/rspec-gem-public_cert.pem')]
2626
end
2727

28-
s.add_runtime_dependency(%q<activesupport>, [">= 3.0", "< 4.3"])
29-
s.add_runtime_dependency(%q<actionpack>, [">= 3.0", "< 4.3"])
30-
s.add_runtime_dependency(%q<railties>, [">= 3.0", "< 4.3"])
28+
s.add_runtime_dependency %q<activesupport>, ">= 3.0"
29+
s.add_runtime_dependency %q<actionpack>, ">= 3.0"
30+
s.add_runtime_dependency %q<railties>, ">= 3.0"
3131
%w[core expectations mocks support].each do |name|
3232
if RSpec::Rails::Version::STRING =~ /[a-zA-Z]+/ # prerelease builds
3333
s.add_runtime_dependency "rspec-#{name}", "= #{RSpec::Rails::Version::STRING}"

spec/rspec/rails/configuration_spec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,11 @@ def in_inferring_type_from_location_environment
196196

197197
it "metadata `:type => :request` sets up request example groups" do
198198
a_rails_app = double("Rails application")
199-
the_rails_module = double("Rails module", :application => a_rails_app)
199+
the_rails_module = Module.new
200+
allow(the_rails_module).to receive(:application) { a_rails_app }
201+
version = ::Rails::VERSION
200202
stub_const "Rails", the_rails_module
203+
stub_const 'Rails::VERSION', version
201204

202205
group = RSpec.describe("Some Request API", :type => :request)
203206

@@ -227,8 +230,11 @@ def in_inferring_type_from_location_environment
227230

228231
it "metadata `:type => :feature` sets up feature example groups" do
229232
a_rails_app = double("Rails application")
230-
the_rails_module = double("Rails module", :application => a_rails_app)
233+
the_rails_module = Module.new
234+
allow(the_rails_module).to receive(:application) { a_rails_app }
235+
version = ::Rails::VERSION
231236
stub_const "Rails", the_rails_module
237+
stub_const 'Rails::VERSION', version
232238

233239
group = RSpec.describe("Some feature description", :type => :feature)
234240
example = group.new

spec/rspec/rails/matchers/have_http_status_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
include RSpec::Rails::Matchers
55

66
def create_response(opts = {})
7-
ActionController::TestResponse.new(opts.fetch(:status))
7+
ActionDispatch::TestResponse.new(opts.fetch(:status))
88
end
99

1010
shared_examples_for "supports different response instances" do

spec/rspec/rails/matchers/have_rendered_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
%w[have_rendered render_template].each do |template_expectation|
44
describe template_expectation do
55
include RSpec::Rails::Matchers::RenderTemplate
6-
let(:response) { ActionController::TestResponse.new }
6+
let(:response) { ActionDispatch::TestResponse.new }
77

88
context "given a hash" do
99
it "delegates to assert_template" do
@@ -90,7 +90,7 @@ def assert_template(*); raise "oops"; end
9090
end
9191

9292
context "when fails with a redirect" do
93-
let(:response) { ActionController::TestResponse.new(302) }
93+
let(:response) { ActionDispatch::TestResponse.new(303) }
9494

9595
def assert_template(*)
9696
message = "expecting <'template_name'> but rendering with <[]>"
@@ -102,7 +102,7 @@ def normalize_argument_to_redirection(response_redirect_location)
102102
end
103103

104104
it "gives informative error message" do
105-
response = ActionController::TestResponse.new(302)
105+
response = ActionDispatch::TestResponse.new(302)
106106
response.location = "http://test.host/widgets/1"
107107
expect do
108108
expect(response).to send(template_expectation, "template_name")

spec/rspec/rails/matchers/redirect_to_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
describe "redirect_to" do
66
include RSpec::Rails::Matchers::RedirectTo
77

8-
let(:response) { ActionController::TestResponse.new }
8+
let(:response) { ActionDispatch::TestResponse.new }
99

1010
context "with should" do
1111
context "when assert_redirected_to passes" do

0 commit comments

Comments
 (0)