Skip to content

Commit 42daf20

Browse files
author
Sam Phippen
committed
Further rails 5 compat
1 parent 0918a0a commit 42daf20

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

Gemfile-rails-dependencies

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
version_file = File.expand_path("../.rails-version", __FILE__)
22
case version = ENV['RAILS_VERSION'] || (File.exist?(version_file) && File.read(version_file).chomp)
33
when /master/
4-
gem "rails", :git => "git://github.com/rails/rails.git"
4+
gem "rails", :path => "/Users/sam/dev/rails"
55
gem "arel", :git => "git://github.com/rails/arel.git"
66
gem "journey", :git => "git://github.com/rails/journey.git"
77
gem "activerecord-deprecated_finders", :git => "git://github.com/rails/activerecord-deprecated_finders.git"
88
gem "rails-observers", :git => "git://github.com/rails/rails-observers"
9-
gem "web-console", :git => "git://github.com/rails/web-console"
9+
gem "web-console", :git => "git://github.com/rails/web-console", :group => :development
1010
gem 'sass-rails', :git => "git://github.com/rails/sass-rails.git"
1111
gem 'coffee-rails', :git => "git://github.com/rails/coffee-rails.git"
1212
gem 'rack', :git => 'git://github.com/rack/rack.git'

lib/rspec/rails/example/view_example_group.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,14 @@ def _include_controller_helpers
157157
end
158158

159159
controller.controller_path = _controller_path
160-
controller.request.path_parameters[:controller] = _controller_path
161-
controller.request.path_parameters[:action] = _inferred_action unless _inferred_action =~ /^_/
160+
161+
path_params_to_merge = {}
162+
path_params_to_merge[:controller] = _controller_path
163+
path_params_to_merge[:action ] = _inferred_action unless _inferred_action =~ /^_/
164+
165+
path_params = controller.request.path_parameters
166+
167+
controller.request.path_parameters = path_params.reverse_merge(path_params_to_merge)
162168
end
163169

164170
let(:_default_file_to_render) do |example|

lib/rspec/rails/matchers/have_http_status.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def as_test_response(obj)
4646
resp.headers.clear
4747
resp.headers.merge!(obj.response_headers)
4848
resp.body = obj.body
49+
resp.request = ActionDispatch::Request.new({})
4950
end
5051
::ActionDispatch::TestResponse.from_response(obj)
5152
else

spec/rspec/rails/matchers/have_http_status_spec.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,27 @@
44
include RSpec::Rails::Matchers
55

66
def create_response(opts = {})
7-
ActionDispatch::TestResponse.new(opts.fetch(:status))
7+
ActionDispatch::TestResponse.new(opts.fetch(:status)).tap {|x|
8+
x.request = ActionDispatch::Request.new({})
9+
}
810
end
911

1012
shared_examples_for "supports different response instances" do
1113
context "given an ActionDispatch::Response" do
1214
it "returns true for a response with the same code" do
13-
response = ::ActionDispatch::Response.new(code)
15+
response = ::ActionDispatch::Response.new(code).tap {|x|
16+
x.request = ActionDispatch::Request.new({})
17+
}
1418

1519
expect( matcher.matches?(response) ).to be(true)
1620
end
1721
end
1822

1923
context "given an ActionDispatch::TestResponse" do
2024
it "returns true for a response with the same code" do
21-
response = ::ActionDispatch::TestResponse.new(code)
25+
response = ::ActionDispatch::TestResponse.new(code).tap {|x|
26+
x.request = ActionDispatch::Request.new({})
27+
}
2228

2329
expect( matcher.matches?(response) ).to be(true)
2430
end
@@ -430,5 +436,4 @@ def create_response(opts = {})
430436
expect{ have_http_status(nil) }.to raise_error ArgumentError
431437
end
432438
end
433-
434439
end

0 commit comments

Comments
 (0)