blob: db4d90e4fd0d794c9e16541f1e50bdee52a4f1cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
RSpec::Matchers.define :disallow_request do
match do |middleware|
alert = middleware.env['rack.session'].to_hash
.dig('flash', 'flashes', 'alert')
alert&.include?('You cannot perform write operations')
end
end
RSpec::Matchers.define :disallow_request_in_json do
match do |response|
json_response = JSON.parse(response.body)
response.body.include?('You cannot perform write operations') && json_response.key?('message')
end
end
|