Skip to content

Commit 0fe072c

Browse files
committed
fix: file upload spec
1 parent fdb43fd commit 0fe072c

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

spec/features/consumer_with_file_upload_spec.rb

+6-14
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@
3232

3333
let(:do_request) { connection.post { |req| req.body = payload } }
3434

35-
describe "when the content matches" do
36-
37-
let(:body) do
38-
"-------------RubyMultipartPost-05e76cbc2adb42ac40344eb9b35e98bc\r\nContent-Disposition: form-data; name=\"file\"; filename=\"text.txt\"\r\nContent-Length: 14\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: binary\r\n\r\nThis is a file\r\n-------------RubyMultipartPost-05e76cbc2adb42ac40344eb9b35e98bc--\r\n\r\n"
39-
end
35+
let(:body) do
36+
"-------------RubyMultipartPost-05e76cbc2adb42ac40344eb9b35e98bc\r\nContent-Disposition: form-data; name=\"file\"; filename=\"text.txt\"\r\nContent-Length: 14\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: binary\r\n\r\n#{File.read(file_to_upload)}\r\n-------------RubyMultipartPost-05e76cbc2adb42ac40344eb9b35e98bc--\r\n"
37+
end
4038

39+
describe "when the content matches" do
4140
it "returns the mocked response and verification passes" do
4241
file_upload_service.
4342
upon_receiving("a request to upload a file").with({
@@ -60,22 +59,15 @@
6059
end
6160

6261
describe "when the content does not match" do
63-
64-
let(:body) do
65-
"-------------RubyMultipartPost-05e76cbc2adb42ac40344eb9b35e98bc\r\nContent-Disposition: form-data; name=\"file\"; filename=\"TEXT.txt\"\r\nContent-Length: 14\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: binary\r\n\r\nThis is a file\r\n-------------RubyMultipartPost-05e76cbc2adb42ac40344eb9b35e98bc--\r\n\r\n"
66-
end
67-
6862
it "the verification fails" do
6963
file_upload_service.
7064
upon_receiving("a request to upload another file").with({
7165
method: :post,
7266
path: '/files',
73-
query: "foo=bar",
74-
body: body,
67+
body: body.gsub('text.txt', 'wrong.txt'),
7568
headers: {
7669
"Content-Type" => Pact.term(/multipart\/form\-data/, "multipart/form-data; boundary=-----------RubyMultipartPost-05e76cbc2adb42ac40344eb9b35e98bc"),
77-
"Content-Length" => Pact.like("299"),
78-
"Missing" => "header"
70+
"Content-Length" => Pact.like("299")
7971
}
8072
}).
8173
will_respond_with({

0 commit comments

Comments
 (0)