Skip to content

inocop/fixture_parts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FixtureParts

FixtureParts registers data in DB for each test.

Usage

How to use.

class HogeTest < ActiveSupport::TestCase
  # File specification
  test "hoge_count" do
    FixtureParts.load("test/fixture_parts/hoge_test/hoges.yml")
    assert_equal(1, Hoge.all.count)
  end

  # Directory specification
  test "hoge_fuga_count" do
    FixtureParts.load_dir("test/fixture_parts/hoge_test")
    assert_equal(1, Hoge.all.count)
    assert_equal(1, Fuga.all.count)
  end

  # no validation
  test "load_no_validation" do
    FixtureParts.load("test/fixture_parts/hoge_test/hoges.yml", valid: false)
  end
end

#{Rails.root}/test/fixture_parts/hoge_test/hoges.yml

one:
  id: 1
  integer: 1
  string: one
  boolean: true
  date: 2019-04-12

Installation

Add this line to your application's Gemfile:

gem 'fixture_parts'

And then execute:

$ bundle

Or install it yourself as:

$ gem install fixture_parts

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.