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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa9ab41c031647b7cd0d36211fdd359a9508a7ac
4
- data.tar.gz: 15cb0c7f055cda15d3cf981a1aea19ea1e3bf429
3
+ metadata.gz: e81423301f54fbcf59eb359af085b0d0039dde30
4
+ data.tar.gz: 4a7369d9248c09cfb076142abd4735e391eedd61
5
5
  SHA512:
6
- metadata.gz: 75fcd05c3d0f0a24c6882d62b0229e4ffd1939ce53d6ea6394f5abd0fc6c610e3d9750810ea65e305476777fbf2bf2ac154302fce54ced796536d2bce0bc638d
7
- data.tar.gz: 3d8a85141f2f550fb9824a2b71750e6790b2a0d2cd0c34f4a8cf2b880763f760236af0effaaf9297d5293df6210de26c08815a5ffc961c16f3b0ce4bf86e84f7
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: !binary |-
17
- <%= binary_file('binaries/kitten.png') %>
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. See LICENSE.txt for
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
1
+ 0.1.2
@@ -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.1 ruby lib
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.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
@@ -3,6 +3,7 @@ class CreateAttachments < ActiveRecord::Migration
3
3
  create_table :attachments do |t|
4
4
  t.string :name, length: 64, null: false
5
5
  t.string :mime_type, length: 64, null: false
6
+ t.number :size, null: false
6
7
  t.binary :data, null: false
7
8
  end
8
9
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binary_fixtures
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Costan