binary_fixtures 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 70d14c48f840ea9db58d097de0f63336440bbd61
4
+ data.tar.gz: f537cbe856b65d2d11b4c105e6cf2252b1738410
5
+ SHA512:
6
+ metadata.gz: 90a45687e54e96ea34eb1b3919b023eca910bce83ab095ae8c5b02f4c1f15de2af811224017996383590217c761be62aac81f89e64e94b5036c085aaf481c03d
7
+ data.tar.gz: b6ba668dd1a912e78c4e9c5eeed9199cd70d4335ae04e3e43718fe804081ad5d0a730c4f0e2f2405707c07e2b4769c887c2984eca0332a344d1d8a9539aa9e84
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '>= 4.0.0'
4
+
5
+ group :development do
6
+ gem 'bundler', '>= 1.3.5'
7
+ gem 'jeweler', '>= 1.8.7'
8
+ gem 'mysql2', '>= 0.3.14'
9
+ gem 'pg', '>= 0.17.0'
10
+ gem 'sqlite3', '>= 1.3.8'
11
+ gem 'yard', '>= 0.7'
12
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,128 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ actionmailer (4.0.1)
5
+ actionpack (= 4.0.1)
6
+ mail (~> 2.5.4)
7
+ actionpack (4.0.1)
8
+ activesupport (= 4.0.1)
9
+ builder (~> 3.1.0)
10
+ erubis (~> 2.7.0)
11
+ rack (~> 1.5.2)
12
+ rack-test (~> 0.6.2)
13
+ activemodel (4.0.1)
14
+ activesupport (= 4.0.1)
15
+ builder (~> 3.1.0)
16
+ activerecord (4.0.1)
17
+ activemodel (= 4.0.1)
18
+ activerecord-deprecated_finders (~> 1.0.2)
19
+ activesupport (= 4.0.1)
20
+ arel (~> 4.0.0)
21
+ activerecord-deprecated_finders (1.0.3)
22
+ activesupport (4.0.1)
23
+ i18n (~> 0.6, >= 0.6.4)
24
+ minitest (~> 4.2)
25
+ multi_json (~> 1.3)
26
+ thread_safe (~> 0.1)
27
+ tzinfo (~> 0.3.37)
28
+ addressable (2.3.5)
29
+ arel (4.0.1)
30
+ atomic (1.1.14)
31
+ builder (3.1.4)
32
+ erubis (2.7.0)
33
+ faraday (0.8.8)
34
+ multipart-post (~> 1.2.0)
35
+ git (1.2.6)
36
+ github_api (0.10.1)
37
+ addressable
38
+ faraday (~> 0.8.1)
39
+ hashie (>= 1.2)
40
+ multi_json (~> 1.4)
41
+ nokogiri (~> 1.5.2)
42
+ oauth2
43
+ hashie (2.0.5)
44
+ highline (1.6.20)
45
+ hike (1.2.3)
46
+ httpauth (0.2.0)
47
+ i18n (0.6.5)
48
+ jeweler (1.8.8)
49
+ builder
50
+ bundler (~> 1.0)
51
+ git (>= 1.2.5)
52
+ github_api (= 0.10.1)
53
+ highline (>= 1.6.15)
54
+ nokogiri (= 1.5.10)
55
+ rake
56
+ rdoc
57
+ json (1.8.1)
58
+ jwt (0.1.8)
59
+ multi_json (>= 1.5)
60
+ mail (2.5.4)
61
+ mime-types (~> 1.16)
62
+ treetop (~> 1.4.8)
63
+ mime-types (1.25)
64
+ minitest (4.7.5)
65
+ multi_json (1.8.2)
66
+ multi_xml (0.5.5)
67
+ multipart-post (1.2.0)
68
+ mysql2 (0.3.14)
69
+ nokogiri (1.5.10)
70
+ oauth2 (0.9.2)
71
+ faraday (~> 0.8)
72
+ httpauth (~> 0.2)
73
+ jwt (~> 0.1.4)
74
+ multi_json (~> 1.0)
75
+ multi_xml (~> 0.5)
76
+ rack (~> 1.2)
77
+ pg (0.17.0)
78
+ polyglot (0.3.3)
79
+ rack (1.5.2)
80
+ rack-test (0.6.2)
81
+ rack (>= 1.0)
82
+ rails (4.0.1)
83
+ actionmailer (= 4.0.1)
84
+ actionpack (= 4.0.1)
85
+ activerecord (= 4.0.1)
86
+ activesupport (= 4.0.1)
87
+ bundler (>= 1.3.0, < 2.0)
88
+ railties (= 4.0.1)
89
+ sprockets-rails (~> 2.0.0)
90
+ railties (4.0.1)
91
+ actionpack (= 4.0.1)
92
+ activesupport (= 4.0.1)
93
+ rake (>= 0.8.7)
94
+ thor (>= 0.18.1, < 2.0)
95
+ rake (10.1.0)
96
+ rdoc (4.0.1)
97
+ json (~> 1.4)
98
+ sprockets (2.10.1)
99
+ hike (~> 1.2)
100
+ multi_json (~> 1.0)
101
+ rack (~> 1.0)
102
+ tilt (~> 1.1, != 1.3.0)
103
+ sprockets-rails (2.0.1)
104
+ actionpack (>= 3.0)
105
+ activesupport (>= 3.0)
106
+ sprockets (~> 2.8)
107
+ sqlite3 (1.3.8)
108
+ thor (0.18.1)
109
+ thread_safe (0.1.3)
110
+ atomic
111
+ tilt (1.4.1)
112
+ treetop (1.4.15)
113
+ polyglot
114
+ polyglot (>= 0.3.1)
115
+ tzinfo (0.3.38)
116
+ yard (0.8.7.3)
117
+
118
+ PLATFORMS
119
+ ruby
120
+
121
+ DEPENDENCIES
122
+ bundler (>= 1.3.5)
123
+ jeweler (>= 1.8.7)
124
+ mysql2 (>= 0.3.14)
125
+ pg (>= 0.17.0)
126
+ rails (>= 4.0.0)
127
+ sqlite3 (>= 1.3.8)
128
+ yard (>= 0.7)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Victor Costan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,33 @@
1
+ = binary_fixtures
2
+
3
+ Helper for using binary data in Rails fixtures.
4
+
5
+ == Usage
6
+
7
+ Add the gem to test group in the Gemfile.
8
+
9
+ group :test do
10
+ gem 'binary_fixtures'
11
+ end
12
+
13
+ Import a binary file in your fixtures.
14
+
15
+ attachment:
16
+ file_contents: !binary |-
17
+ <%= binary_file('binaries/kitten.png') %>
18
+
19
+ == Contributing to binary_fixtures
20
+
21
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
22
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
23
+ * Fork the project.
24
+ * Start a feature/bugfix branch.
25
+ * Commit and push until you are happy with your contribution.
26
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
27
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
28
+
29
+ == Copyright
30
+
31
+ Copyright (c) 2013 Victor Costan. See LICENSE.txt for
32
+ further details.
33
+
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "binary_fixtures"
18
+ gem.homepage = "http://github.com/pwnall/binary_fixtures"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Use binary files in Rails fixtures}
21
+ gem.description = %Q{Convenience method for inlining binary data in Rails fixtures}
22
+ gem.email = "victor@costan.us"
23
+ gem.authors = ["Victor Costan"]
24
+ # Dependencies in Gemfile.
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ task :default => :test
36
+
37
+ require 'yard'
38
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,6 @@
1
+ module BinaryFixtures
2
+ end # namespace BinaryFixtures
3
+
4
+ require 'binary_fixtures/fixture_helpers.rb'
5
+ require 'binary_fixtures/rails_13022.rb'
6
+ require 'binary_fixtures/patch_rails.rb'
@@ -0,0 +1,26 @@
1
+ require 'base64'
2
+
3
+ require 'rails'
4
+
5
+ module BinaryFixtures::FixtureHelpers
6
+ # The contents of a binary file, in a YAML-friendly format.
7
+ #
8
+ # @param [String] path the path of the binary file to be included, relative
9
+ # to the Rails application's test/fixtures directory
10
+ # @param [Hash] options optionally specify the current indent level
11
+ # @option options [Integer] indent the number of spaces that the current line
12
+ # in the YAML fixture file is indented by
13
+ # @return [String] base64-encoded binary file contents
14
+ def binary_file(path, options = {})
15
+ # The line with base64 data must be indented further than the current line.
16
+ indent = ' ' * ((options[:indent] || 2) + 2)
17
+
18
+ file_path = Rails.root.join('test/fixtures').join(path)
19
+ binary_data = File.binread file_path
20
+ base64_data = Base64.encode64 binary_data
21
+ base64_data.gsub! "\n", "\n#{indent}"
22
+ base64_data.strip!
23
+
24
+ "!!binary |\n#{indent}#{base64_data}"
25
+ end
26
+ end # module BinaryFixtures::FixtureHelpers
@@ -0,0 +1,6 @@
1
+ require 'active_record'
2
+ require 'active_record/fixtures'
3
+
4
+ class ActiveRecord::FixtureSet::RenderContext
5
+ include BinaryFixtures::FixtureHelpers
6
+ end
@@ -0,0 +1,41 @@
1
+ require 'active_record'
2
+ require 'active_record/fixtures'
3
+
4
+ # Packaged version of https://github.com/rails/rails/pull/13022
5
+ unless defined?(ActiveRecord::FixtureSet::RenderContext)
6
+ module ActiveRecord
7
+ class FixtureSet
8
+ # The context used by the ERB fixture renderer.
9
+ #
10
+ # Make helper functions available in your fixtures by defining them in a
11
+ # module and including it in ActiveRecord::FixtureSet::RenderContext.
12
+ #
13
+ # A new subclass of this class is created each time the ERB renderer is
14
+ # called so that methods defined in ERB templates do not leak into other
15
+ # templates' context.
16
+ class RenderContext
17
+ # An instance of a new RenderContext subclass.
18
+ def self.create
19
+ klass = ::Class.new(ActiveRecord::FixtureSet::RenderContext) do
20
+ def get_binding
21
+ binding()
22
+ end
23
+ end
24
+
25
+ klass.new
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ module ActiveRecord
32
+ class FixtureSet
33
+ class File
34
+ def render(content)
35
+ context = ActiveRecord::FixtureSet::RenderContext.create
36
+ ERB.new(content).result(context.get_binding)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end # !defined?(ActiveRecord::FixtureSet::RenderContext)
@@ -0,0 +1,9 @@
1
+ ruby:
2
+ name: ruby.png
3
+ mime_type: image/png
4
+ data: <%= binary_file('files/ruby.png') %>
5
+
6
+ invoice:
7
+ name: invoice.pdf
8
+ data: <%= binary_file('files/invoice.pdf', indent: 4) %>
9
+ mime_type: application/pdf
@@ -0,0 +1,137 @@
1
+ %PDF-1.4
2
+ %����
3
+ 5 0 obj
4
+ <<
5
+ /Type /Font
6
+ /Subtype /TrueType
7
+ /BaseFont /Arial
8
+ /Encoding /WinAnsiEncoding
9
+ >>
10
+ endobj
11
+ 7 0 obj
12
+ <<
13
+ /Type /FontDescriptor
14
+ /FontName /BookAntiqua,Bold
15
+ /Flags 16418
16
+ /FontBBox [-250 -260 1236 930]
17
+ /MissingWidth 750
18
+ /StemV 146
19
+ /StemH 146
20
+ /ItalicAngle 0
21
+ /CapHeight 930
22
+ /XHeight 651
23
+ /Ascent 930
24
+ /Descent 260
25
+ /Leading 210
26
+ /MaxWidth 1030
27
+ /AvgWidth 460
28
+ >>
29
+ endobj
30
+ 6 0 obj
31
+ <<
32
+ /Type /Font
33
+ /Subtype /TrueType
34
+ /BaseFont /BookAntiqua,Bold
35
+ /FirstChar 31
36
+ /LastChar 255
37
+ /Widths [750 250 278 402 606 500 889 833 227 333 333 444 606 250 333 250 296 500 500 500 500 500 500 500 500 500 500 250 250 606 606 606 444 747 778 667 722 833 611 556 833 833 389 389 778 611 1000 833 833 611 833 722 611 667 778 778 1000 667 667 667 333 606 333 606 500 333 500 611 444 611 500 389 556 611 333 333 611 333 889 611 556 611 611 389 444 333 611 556 833 500 556 500 310 606 310 606 750 500 750 333 500 500 1000 500 500 333 1000 611 389 1000 750 750 750 750 278 278 500 500 606 500 1000 333 998 444 389 833 750 750 667 250 278 500 500 606 500 606 500 333 747 438 500 606 333 747 500 400 549 361 361 333 576 641 250 333 361 488 500 889 890 889 444 778 778 778 778 778 778 1000 722 611 611 611 611 389 389 389 389 833 833 833 833 833 833 833 606 833 778 778 778 778 667 611 611 500 500 500 500 500 500 778 444 500 500 500 500 333 333 333 333 556 611 556 556 556 556 556 549 556 611 611 611 611 556 611 556]
38
+ /Encoding /WinAnsiEncoding
39
+ /FontDescriptor 7 0 R
40
+ >>
41
+ endobj
42
+ 8 0 obj
43
+ [/PDF /Text]
44
+ endobj
45
+ 10 0 obj
46
+ 246
47
+ endobj
48
+ 9 0 obj
49
+ <<
50
+ /Length 246
51
+ /Filter /FlateDecode
52
+ >>
53
+ stream
54
+ H�͐�J�0�� ��{��f�$M��n�-���[&je���ۤ �~�$���}�Ʌ�Ij���s����~�X�-],��$Y���)�'N�u�1!���V�?��?
55
+ �b1Rbb�҉�H�[��TD:#�&ح��X���i�$qnf�����]������a��{��أ���q|J�Ls]�Q�I��j�%��9��`�঺��U�ite�z�$����OeB�Ēү�R��@zܗ���g���<���
56
+ endstream
57
+ endobj
58
+ 4 0 obj
59
+ <<
60
+ /Type /Page
61
+ /MediaBox [0 0 612 792]
62
+ /Resources <<
63
+ /Font <<
64
+ /F0 5 0 R
65
+ /F1 6 0 R
66
+ >>
67
+ /ProcSet 8 0 R
68
+ >>
69
+ /Contents 9 0 R
70
+ /Parent 2 0 R
71
+ >>
72
+ endobj
73
+ 11 0 obj
74
+ [/CalGray <<
75
+ /WhitePoint [0.9505 1 1.0891]
76
+ /Gamma 0.2468
77
+ >>]
78
+ endobj
79
+ 12 0 obj
80
+ [/CalRGB <<
81
+ /WhitePoint [0.9505 1 1.0891]
82
+ /Gamma [0.2468 0.2468 0.2468]
83
+ /Matrix [0.4361 0.2225 0.0139 0.3851 0.7169 0.0971 0.1431 0.0606 0.7141]
84
+ >>]
85
+ endobj
86
+ 2 0 obj
87
+ <<
88
+ /Type /Pages
89
+ /Kids [4 0 R]
90
+ /Count 1
91
+ >>
92
+ endobj
93
+ 1 0 obj
94
+ <<
95
+ /Type /Catalog
96
+ /Pages 2 0 R
97
+ /DefaultGray 11 0 R
98
+ /DefaultRGB 12 0 R
99
+ >>
100
+ endobj
101
+ 3 0 obj
102
+ <<
103
+ /Creator (1725.fm)
104
+ /CreationDate (1-Jan-3 18:15PM)
105
+ /Title (1725.PDF)
106
+ /Author (Unknown)
107
+ /Keywords <>
108
+ /Subject <>
109
+ /ModDate (D:20131124155828Z)
110
+ /Producer (3-Heights\(TM\) PDF Producer 4.2.26.0 \(http://www.pdf-tools.com\))
111
+ >>
112
+ endobj
113
+ xref
114
+ 0 13
115
+ 0000000000 65535 f
116
+ 0000002266 00000 n
117
+ 0000002209 00000 n
118
+ 0000002354 00000 n
119
+ 0000001816 00000 n
120
+ 0000000015 00000 n
121
+ 0000000376 00000 n
122
+ 0000000111 00000 n
123
+ 0000001450 00000 n
124
+ 0000001498 00000 n
125
+ 0000001478 00000 n
126
+ 0000001967 00000 n
127
+ 0000002044 00000 n
128
+ trailer
129
+ <<
130
+ /Size 13
131
+ /Root 1 0 R
132
+ /Info 3 0 R
133
+ /ID [<F2B22CD0880D25E8E743A676B47199CD> <5B1A04D8F6660EB95B25A6F7A746258B>]
134
+ >>
135
+ startxref
136
+ 2595
137
+ %%EOF
Binary file
data/test/helper.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+
12
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ require 'binary_fixtures'
15
+
16
+ require 'helpers/db_setup.rb'
17
+ require 'helpers/rails.rb'
@@ -0,0 +1,47 @@
1
+ case ENV['DB']
2
+ when /mysql/i
3
+ create_sql = 'CREATE DATABASE plugin_dev DEFAULT CHARACTER SET utf8;'
4
+ if /:(.*)$/ =~ ENV['DB']
5
+ create_sql.sub! ';', " DEFAULT COLLATE #{$1};"
6
+ end
7
+
8
+ `mysql -u root -e "DROP DATABASE IF EXISTS plugin_dev; #{create_sql}"`
9
+ ActiveRecord::Base.establish_connection adapter: 'mysql2',
10
+ database: 'plugin_dev', username: 'root', password: ''
11
+ when /pg/i
12
+ pg_user = ENV['DB_USER'] || ENV['USER']
13
+ `psql -U #{pg_user} -d postgres -c "DROP DATABASE IF EXISTS plugin_dev;"`
14
+ `psql -U #{pg_user} -d postgres -c "CREATE DATABASE plugin_dev;"`
15
+ ActiveRecord::Base.establish_connection adapter: 'postgresql',
16
+ database: 'plugin_dev', username: pg_user, password: ''
17
+ else
18
+ ActiveRecord::Base.establish_connection adapter: 'sqlite3',
19
+ database: ':memory:'
20
+ end
21
+
22
+ class ActiveRecord::Base
23
+ self.configurations = true
24
+ if ActiveRecord::Base.respond_to? :mass_assignment_sanitizer=
25
+ self.mass_assignment_sanitizer = :strict
26
+
27
+ # Hacky equivalent to config.active_record.whitelist_attributes = true
28
+ attr_accessible
29
+ end
30
+ end
31
+
32
+ ActiveRecord::Migration.verbose = false
33
+ require File.expand_path('../../../test/migrations/001_create_attachments.rb',
34
+ __FILE__)
35
+ CreateAttachments.migrate :up
36
+ class Attachment < ActiveRecord::Base
37
+ end
38
+
39
+ class ActiveSupport::TestCase
40
+ include ActiveRecord::TestFixtures
41
+
42
+ self.fixture_path = File.expand_path '../../../test/fixtures', __FILE__
43
+ self.use_transactional_fixtures = false
44
+ self.use_instantiated_fixtures = false
45
+ self.pre_loaded_fixtures = false
46
+ fixtures :all
47
+ end
@@ -0,0 +1,8 @@
1
+ # Mock Rails.root.
2
+ module Rails
3
+ class <<self
4
+ def root
5
+ Pathname.new File.expand_path('../..', File.dirname(__FILE__))
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ class CreateAttachments < ActiveRecord::Migration
2
+ def change
3
+ create_table :attachments do |t|
4
+ t.string :name, length: 64, null: false
5
+ t.string :mime_type, length: 64, null: false
6
+ t.binary :data, null: false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,33 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ class BinaryFixturesTest < ActiveSupport::TestCase
4
+ def setup
5
+ @ruby = attachments(:ruby)
6
+ @ruby_path = 'test/fixtures/files/ruby.png'
7
+
8
+ @invoice = attachments(:invoice)
9
+ @invoice_path = 'test/fixtures/files/invoice.pdf'
10
+ end
11
+
12
+ test 'ruby metadata was set up correctly' do
13
+ assert_equal 'ruby.png', @ruby.name
14
+ assert_equal 'image/png', @ruby.mime_type
15
+ end
16
+
17
+ test 'ruby binary data was set up correctly' do
18
+ assert_equal Encoding::BINARY, @ruby.data.encoding
19
+ assert_equal File.stat(@ruby_path).size, @ruby.data.length
20
+ assert_equal File.binread(@ruby_path), @ruby.data
21
+ end
22
+
23
+ test 'invoice metadata was set up correctly' do
24
+ assert_equal 'invoice.pdf', @invoice.name
25
+ assert_equal 'application/pdf', @invoice.mime_type
26
+ end
27
+
28
+ test 'invoice binary data was set up correctly' do
29
+ assert_equal Encoding::BINARY, @invoice.data.encoding
30
+ assert_equal File.stat(@invoice_path).size, @invoice.data.length
31
+ assert_equal File.binread(@invoice_path), @invoice.data
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: binary_fixtures
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Victor Costan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.5
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: jeweler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.7
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.7
55
+ - !ruby/object:Gem::Dependency
56
+ name: mysql2
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.14
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.3.14
69
+ - !ruby/object:Gem::Dependency
70
+ name: pg
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.17.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.17.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: 1.3.8
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: 1.3.8
97
+ - !ruby/object:Gem::Dependency
98
+ name: yard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0.7'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0.7'
111
+ description: Convenience method for inlining binary data in Rails fixtures
112
+ email: victor@costan.us
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files:
116
+ - LICENSE
117
+ - README.rdoc
118
+ files:
119
+ - .document
120
+ - Gemfile
121
+ - Gemfile.lock
122
+ - LICENSE
123
+ - README.rdoc
124
+ - Rakefile
125
+ - VERSION
126
+ - lib/binary_fixtures.rb
127
+ - lib/binary_fixtures/fixture_helpers.rb
128
+ - lib/binary_fixtures/patch_rails.rb
129
+ - lib/binary_fixtures/rails_13022.rb
130
+ - test/fixtures/attachments.yml
131
+ - test/fixtures/files/invoice.pdf
132
+ - test/fixtures/files/ruby.png
133
+ - test/helper.rb
134
+ - test/helpers/db_setup.rb
135
+ - test/helpers/rails.rb
136
+ - test/migrations/001_create_attachments.rb
137
+ - test/test_binary_fixtures.rb
138
+ homepage: http://github.com/pwnall/binary_fixtures
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.1.11
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: Use binary files in Rails fixtures
162
+ test_files: []