binary_fixtures 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +4 -5
- data/VERSION +1 -1
- data/binary_fixtures.gemspec +2 -2
- data/lib/binary_fixtures/fixture_helpers.rb +10 -0
- data/test/fixtures/attachments.yml +2 -0
- data/test/migrations/001_create_attachments.rb +1 -0
- data/test/test_binary_fixtures.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e81423301f54fbcf59eb359af085b0d0039dde30
|
4
|
+
data.tar.gz: 4a7369d9248c09cfb076142abd4735e391eedd61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1703a62240f2bad679e15285ee744a1fe0a6069ffeac629fba7dc831b16c1bbf99d94571e38329c6725af8b3ccbdfd8820110f7aad38b91a511d08f478173b7
|
7
|
+
data.tar.gz: 09e8779ef1053b5fe735701a5e2655fc70a22f72c364c69a64a52edbd3eb2dbc0926f3f7c3c566b3781b4680a423eebd0c8f40433398a977918c1080e33cb6c8
|
data/README.rdoc
CHANGED
@@ -10,11 +10,11 @@ Add the gem to test group in the Gemfile.
|
|
10
10
|
gem 'binary_fixtures'
|
11
11
|
end
|
12
12
|
|
13
|
-
Import a binary file in your fixtures.
|
13
|
+
Import a binary file in your fixtures. Paths are relative to test/fixtures.
|
14
14
|
|
15
15
|
attachment:
|
16
|
-
file_contents:
|
17
|
-
|
16
|
+
file_contents: <%= binary_file('files/kitten.png') %>
|
17
|
+
file_size: <%= binary_file_size('files/kitten.png') %>
|
18
18
|
|
19
19
|
== Contributing to binary_fixtures
|
20
20
|
|
@@ -28,6 +28,5 @@ Import a binary file in your fixtures.
|
|
28
28
|
|
29
29
|
== Copyright
|
30
30
|
|
31
|
-
Copyright (c) 2013 Victor Costan
|
32
|
-
further details.
|
31
|
+
Copyright (c) 2013 Victor Costan, released under the MIT license.
|
33
32
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/binary_fixtures.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: binary_fixtures 0.1.
|
5
|
+
# stub: binary_fixtures 0.1.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "binary_fixtures"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["Victor Costan"]
|
@@ -23,4 +23,14 @@ module BinaryFixtures::FixtureHelpers
|
|
23
23
|
|
24
24
|
"!!binary |\n#{indent}#{base64_data}"
|
25
25
|
end
|
26
|
+
|
27
|
+
# The number of bytes in a binary file.
|
28
|
+
#
|
29
|
+
# @param [String] path the path of the binary file to be included, relative
|
30
|
+
# to the Rails application's test/fixtures directory
|
31
|
+
# @return [Integer] the nubmer of bytes in the file
|
32
|
+
def binary_file_size(path)
|
33
|
+
file_path = Rails.root.join('test/fixtures').join(path)
|
34
|
+
File.stat(file_path).size
|
35
|
+
end
|
26
36
|
end # module BinaryFixtures::FixtureHelpers
|
@@ -1,9 +1,11 @@
|
|
1
1
|
ruby:
|
2
2
|
name: ruby.png
|
3
3
|
mime_type: image/png
|
4
|
+
size: <%= binary_file_size('files/ruby.png') %>
|
4
5
|
data: <%= binary_file('files/ruby.png') %>
|
5
6
|
|
6
7
|
invoice:
|
7
8
|
name: invoice.pdf
|
8
9
|
data: <%= binary_file('files/invoice.pdf', indent: 4) %>
|
10
|
+
size: <%= binary_file_size('files/invoice.pdf') %>
|
9
11
|
mime_type: application/pdf
|
@@ -12,6 +12,7 @@ class BinaryFixturesTest < ActiveSupport::TestCase
|
|
12
12
|
test 'ruby metadata was set up correctly' do
|
13
13
|
assert_equal 'ruby.png', @ruby.name
|
14
14
|
assert_equal 'image/png', @ruby.mime_type
|
15
|
+
assert_equal File.stat(@ruby_path).size, @ruby.size
|
15
16
|
end
|
16
17
|
|
17
18
|
test 'ruby binary data was set up correctly' do
|
@@ -23,6 +24,7 @@ class BinaryFixturesTest < ActiveSupport::TestCase
|
|
23
24
|
test 'invoice metadata was set up correctly' do
|
24
25
|
assert_equal 'invoice.pdf', @invoice.name
|
25
26
|
assert_equal 'application/pdf', @invoice.mime_type
|
27
|
+
assert_equal File.stat(@ruby_path).size, @invoice.size
|
26
28
|
end
|
27
29
|
|
28
30
|
test 'invoice binary data was set up correctly' do
|