multipart_body 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/multipart_body.rb +1 -0
  2. data/test/test.rb +12 -0
  3. metadata +3 -6
@@ -1,2 +1,3 @@
1
+ require 'tempfile'
1
2
  require 'multipart_body/multipart_body'
2
3
  require 'multipart_body/part'
@@ -7,6 +7,10 @@ class MultipartBodyTest < Test::Unit::TestCase
7
7
  @hash = {:test => 'test', :two => 'two'}
8
8
  @parts = [Part.new('name', 'value'), Part.new('name2', 'value2')]
9
9
  @example_text = "------multipart-boundary-307380\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\nvalue\r\n------multipart-boundary-307380\r\nContent-Disposition: form-data; name=\"name2\"\r\n\r\nvalue2\r\n------multipart-boundary-307380--"
10
+ @file = Tempfile.new('file')
11
+ @file.write('hello')
12
+ @file.flush
13
+ @file.open
10
14
  end
11
15
 
12
16
  should "return a new multipart when sent #from_hash" do
@@ -59,6 +63,14 @@ class MultipartBodyTest < Test::Unit::TestCase
59
63
  multipart.boundary = '----multipart-boundary-307380'
60
64
  assert_equal @example_text, multipart.to_s
61
65
  end
66
+
67
+ should "construct a file part when create from hash" do
68
+ multipart = MultipartBody.new(:test => @file)
69
+ multipart.boundary = '----multipart-boundary-672923'
70
+ assert_equal 'hello', multipart.parts.first.body
71
+ assert_not_nil multipart.parts.first.filename
72
+ assert_match /------multipart-boundary-672923\r\nContent-Disposition: form-data; name=\"test\"; filename=\".*"\r\n\r\nhello\r\n------multipart-boundary-672923--/, multipart.to_s
73
+ end
62
74
  end
63
75
 
64
76
  context "a Part" do
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multipart_body
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 2
9
- - 0
10
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
11
10
  platform: ruby
12
11
  authors:
13
12
  - Steve Smith
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-09-19 00:00:00 +01:00
17
+ date: 2011-01-23 00:00:00 +00:00
19
18
  default_executable:
20
19
  dependencies: []
21
20
 
@@ -50,7 +49,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
49
  requirements:
51
50
  - - ">="
52
51
  - !ruby/object:Gem::Version
53
- hash: 3
54
52
  segments:
55
53
  - 0
56
54
  version: "0"
@@ -59,7 +57,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
57
  requirements:
60
58
  - - ">="
61
59
  - !ruby/object:Gem::Version
62
- hash: 3
63
60
  segments:
64
61
  - 0
65
62
  version: "0"