|
213 | 213 | end |
214 | 214 | end |
215 | 215 |
|
| 216 | + describe "with multiple hash steps" do |
| 217 | + it "must wrap its steps into one hash" do |
| 218 | + hash_1 = {encode: {robot: "/video/encode"}, resize: {robot: "/image/resize"}} |
| 219 | + hash_2 = {thumbs: {robot: "/video/thumbs"}} |
| 220 | + |
| 221 | + assembly = Transloadit::Assembly.new @transloadit, |
| 222 | + steps: [hash_1, hash_2] |
| 223 | + (hash_1.keys + hash_2.keys).each do |key| |
| 224 | + _(assembly.to_hash[:steps].keys).must_include key |
| 225 | + end |
| 226 | + end |
| 227 | + |
| 228 | + it "must not allow duplicate steps" do |
| 229 | + thumbs = {thumbs: {robot: "/video/thumbs"}} |
| 230 | + thumbs_duplicate = {thumbs: {robot: "/video/encode"}} |
| 231 | + assembly = Transloadit::Assembly.new @transloadit, |
| 232 | + steps: [thumbs, thumbs_duplicate] |
| 233 | + assert_raises ArgumentError do |
| 234 | + assembly.create! open("lib/transloadit/version.rb") |
| 235 | + end |
| 236 | + end |
| 237 | + end |
| 238 | + |
| 239 | + describe "with mixture of hashes and steps" do |
| 240 | + it "must wrap its steps into one hash" do |
| 241 | + hash = {encode: {robot: "/video/encode"}, resize: {robot: "/image/resize"}} |
| 242 | + step = @transloadit.step "thumbs", "/video/thumbs" |
| 243 | + |
| 244 | + assembly = Transloadit::Assembly.new @transloadit, |
| 245 | + steps: [hash, step] |
| 246 | + |
| 247 | + hash.keys.each do |key| |
| 248 | + _(assembly.to_hash[:steps].keys).must_include key |
| 249 | + end |
| 250 | + |
| 251 | + _(assembly.to_hash[:steps].keys).must_include step.name |
| 252 | + end |
| 253 | + |
| 254 | + it "must not allow duplicate steps" do |
| 255 | + hash = {thumbs: {robot: "/video/thumbs"}} |
| 256 | + step = @transloadit.step "thumbs", "/video/thumbs" |
| 257 | + |
| 258 | + assembly = Transloadit::Assembly.new @transloadit, |
| 259 | + steps: [hash, step] |
| 260 | + |
| 261 | + assert_raises ArgumentError do |
| 262 | + assembly.create! open("lib/transloadit/version.rb") |
| 263 | + end |
| 264 | + end |
| 265 | + end |
| 266 | + |
| 267 | + describe "with unsupported step class" do |
| 268 | + it "raises error" do |
| 269 | + assembly = Transloadit::Assembly.new @transloadit, |
| 270 | + steps: Class.new |
| 271 | + |
| 272 | + assert_raises ArgumentError do |
| 273 | + assembly.create! open("lib/transloadit/version.rb") |
| 274 | + end |
| 275 | + end |
| 276 | + end |
| 277 | + |
| 278 | + describe "with unsupported array element" do |
| 279 | + it "raises error" do |
| 280 | + assembly = Transloadit::Assembly.new @transloadit, |
| 281 | + steps: [Class.new] |
| 282 | + |
| 283 | + assert_raises ArgumentError do |
| 284 | + assembly.create! open("lib/transloadit/version.rb") |
| 285 | + end |
| 286 | + end |
| 287 | + end |
| 288 | + |
216 | 289 | describe "using assembly API methods" do |
217 | 290 | include WebMock::API |
218 | 291 |
|
|
0 commit comments