SPEC: Add bucket folder path only if not exists

SPEC: Add bucket folder path only if not exists

be0555cc17ce59918a1374c78af64d722f2c1836

diff --git a/spec/components/s3_helper_spec.rb b/spec/components/s3_helper_spec.rb
index a903c61..d4176ff 100644
--- a/spec/components/s3_helper_spec.rb
+++ b/spec/components/s3_helper_spec.rb
@@ -78,4 +78,15 @@ describe "S3Helper" do
       end
     end
   end
+
+  it "should prefix bucket folder path only if not exists" do
+    s3_helper = S3Helper.new('bucket/folder_path')
+    bucket = stub('s3_bucket')
+
+    s3_helper.expects(:s3_bucket).returns(bucket).twice
+    bucket.expects(:object).with("folder_path/original/1X/def.xyz").twice
+
+    s3_helper.object("original/1X/def.xyz")
+    s3_helper.object("folder_path/original/1X/def.xyz")
+  end
 end

GitHub sha: 4d1204b5

1 Like

Is there a way to test this differently? Using expects(...).twice and then calling some methods doesn’t feel right.

2 Likes

SPEC: improve the spec using stubbed S3 client.