factory_girl_rails-4.7.0/0000755000004100000410000000000012706167354015443 5ustar www-datawww-datafactory_girl_rails-4.7.0/Rakefile0000644000004100000410000000074112706167354017112 0ustar www-datawww-datarequire 'bundler/setup' require 'bundler/gem_tasks' require 'cucumber/rake/task' Cucumber::Rake::Task.new(:cucumber) do |t| t.fork = true t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')] end require 'appraisal' desc 'Run the test suite' task :default do |t| if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/ exec 'rake cucumber' else Rake::Task['appraise'].execute end end task :appraise => ['appraisal:install'] do |t| exec 'rake appraisal' end factory_girl_rails-4.7.0/Gemfile.lock0000644000004100000410000000630712706167354017673 0ustar www-datawww-dataPATH remote: . specs: factory_girl_rails (4.7.0) factory_girl (~> 4.7.0) railties (>= 3.0.0) GEM remote: https://rubygems.org/ specs: actionpack (4.1.1) actionview (= 4.1.1) activesupport (= 4.1.1) rack (~> 1.5.2) rack-test (~> 0.6.2) actionview (4.1.1) activesupport (= 4.1.1) builder (~> 3.1) erubis (~> 2.7.0) activemodel (4.1.1) activesupport (= 4.1.1) builder (~> 3.1) activerecord (4.1.1) activemodel (= 4.1.1) activesupport (= 4.1.1) arel (~> 5.0.0) activerecord-jdbc-adapter (1.3.15) activerecord (>= 2.2) activerecord-jdbcsqlite3-adapter (1.3.15) activerecord-jdbc-adapter (~> 1.3.15) jdbc-sqlite3 (>= 3.7.2, < 3.9) activesupport (4.1.1) i18n (~> 0.6, >= 0.6.9) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.1) tzinfo (~> 1.1) appraisal (1.0.3) bundler rake thor (>= 0.14.0) arel (5.0.1.20140414130214) aruba (0.5.4) childprocess (>= 0.3.6) cucumber (>= 1.1.1) rspec-expectations (>= 2.7.0) builder (3.2.2) childprocess (0.5.3) ffi (~> 1.0, >= 1.0.11) coffee-rails (4.0.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) coffee-script (2.2.0) coffee-script-source execjs coffee-script-source (1.7.0) cucumber (1.3.19) builder (>= 2.1.2) diff-lcs (>= 1.1.3) gherkin (~> 2.12) multi_json (>= 1.7.5, < 2.0) multi_test (>= 0.1.2) diff-lcs (1.2.5) erubis (2.7.0) execjs (2.0.2) factory_girl (4.7.0) activesupport (>= 3.0.0) ffi (1.9.3) ffi (1.9.3-java) gherkin (2.12.2) multi_json (~> 1.3) gherkin (2.12.2-java) multi_json (~> 1.3) i18n (0.7.0) jdbc-sqlite3 (3.8.7) jquery-rails (3.1.0) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) jruby-openssl (0.9.6-java) json (1.8.3) json (1.8.3-java) minitest (5.8.4) multi_json (1.11.2) multi_test (0.1.2) power_assert (0.2.3) rack (1.5.5) rack-test (0.6.3) rack (>= 1.0) railties (4.1.1) actionpack (= 4.1.1) activesupport (= 4.1.1) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (11.1.2) rspec-core (2.14.8) rspec-expectations (2.14.5) diff-lcs (>= 1.1.3, < 2.0) rspec-mocks (2.14.6) rspec-rails (2.14.2) actionpack (>= 3.0) activemodel (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) rspec-core (~> 2.14.0) rspec-expectations (~> 2.14.0) rspec-mocks (~> 2.14.0) sqlite3 (1.3.9) test-unit (3.0.9) power_assert therubyrhino (2.0.4) therubyrhino_jar (>= 1.7.3) therubyrhino_jar (1.7.4) thor (0.19.1) thread_safe (0.3.5) thread_safe (0.3.5-java) tzinfo (1.2.2) thread_safe (~> 0.1) uglifier (2.5.0) execjs (>= 0.3.0) json (>= 1.8.0) PLATFORMS java ruby DEPENDENCIES activerecord-jdbcsqlite3-adapter appraisal aruba coffee-rails cucumber (= 1.3.19) factory_girl_rails! jdbc-sqlite3 jquery-rails jruby-openssl rake rspec-rails sqlite3 test-unit therubyrhino uglifier BUNDLED WITH 1.11.2 factory_girl_rails-4.7.0/factory_girl_rails.gemspec0000644000004100000410000000131012706167354022661 0ustar www-datawww-dataGem::Specification.new do |s| s.name = %q{factory_girl_rails} s.version = '4.7.0' s.authors = ["Joe Ferris"] s.email = %q{jferris@thoughtbot.com} s.homepage = "http://github.com/thoughtbot/factory_girl_rails" s.summary = %q{factory_girl_rails provides integration between factory_girl and rails 3} s.description = %q{factory_girl_rails provides integration between factory_girl and rails 3 (currently just automatic factory definition loading)} s.files = `git ls-files`.split("\n") s.require_paths = ["lib"] s.license = "MIT" s.add_runtime_dependency('railties', '>= 3.0.0') s.add_runtime_dependency('factory_girl', '~> 4.7.0') end factory_girl_rails-4.7.0/bin/0000755000004100000410000000000012706167354016213 5ustar www-datawww-datafactory_girl_rails-4.7.0/bin/setup0000755000004100000410000000057412706167354017307 0ustar www-datawww-data#!/usr/bin/env sh # Run this script immediately after cloning the codebase. # Exit if any subcommand fails set -e # Set up Ruby dependencies via Bundler bundle install # Add binstubs to PATH in ~/.zshenv like this: # export PATH=".git/safe/../../bin:$PATH" mkdir -p .git/safe # Set up Appraisal to help us test against multiple Rails versions bundle exec appraisal install factory_girl_rails-4.7.0/Gemfile0000644000004100000410000000061612706167354016741 0ustar www-datawww-datasource 'https://rubygems.org' gemspec gem 'appraisal' gem 'aruba' gem 'coffee-rails' gem 'cucumber', '1.3.19' gem 'jquery-rails' gem 'rake' gem 'rspec-rails' gem 'uglifier' gem 'test-unit' gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby gem 'jdbc-sqlite3', platforms: :jruby gem 'therubyrhino', platforms: :jruby gem 'jruby-openssl', platforms: :jruby gem 'sqlite3', platforms: :ruby factory_girl_rails-4.7.0/features/0000755000004100000410000000000012706167354017261 5ustar www-datawww-datafactory_girl_rails-4.7.0/features/step_definitions/0000755000004100000410000000000012706167354022627 5ustar www-datawww-datafactory_girl_rails-4.7.0/features/step_definitions/rails_steps.rb0000644000004100000410000000207312706167354025506 0ustar www-datawww-dataWhen /^I add "([^"]+)" from this project as a dependency$/ do |gem_name| append_to_file('Gemfile', %{gem "#{gem_name}", :path => "#{PROJECT_ROOT}"\n}) end When /^I add "([^"]+)" as a dependency$/ do |gem_name| append_to_file('Gemfile', %{gem "#{gem_name}"\n}) end When /^I print out "([^"]*)"$/ do |path| in_current_dir do File.open(path, 'r') do |f| puts f.inspect end end end When /^I configure the factories as:$/ do |string| append_to_file File.join('config', 'application.rb'), <<-END class Testapp::Application #{string} end END end When /^I configure the factories directory as "([^"]+)"$/ do |factory_dir| append_to_file File.join('config', 'application.rb'), <<-END class Testapp::Application config.generators do |g| g.fixture_replacement :factory_girl, :dir => "#{factory_dir}" end end END end When /^I comment out gem "([^"]*)" from my Gemfile$/ do |gem_name| in_current_dir do content = File.read('Gemfile') File.open('Gemfile', 'w') do |f| f.write content.sub(/gem ['"]#{gem_name}/, '#\1') end end end factory_girl_rails-4.7.0/features/step_definitions/appraisal.rb0000644000004100000410000000041312706167354025126 0ustar www-datawww-dataWhen /^I run `([^"]+)` with a clean environment$/ do |command| step %{I successfully run `ruby -e 'system({"BUNDLE_GEMFILE" => nil, "DISABLE_SPRING" => "true"}, "#{command}")'`} end # system({'BUNDLE_GEMFILE' => nil}, "cd tmp/aruba/testapp && #{command} && cd -") factory_girl_rails-4.7.0/features/fixture_replacement_config.feature0000644000004100000410000001342112706167354026231 0ustar www-datawww-dataFeature: In order to not have to manually configure Factory Girl as the Rails testing fixture replacement by using the --fixture-replacement=factory_girl option I would like the Factory Girl Rails gem to configure Factory Girl as the fixture replacement. Background: Given I successfully run `bundle exec rails new testapp` And I cd to "testapp" And I add "factory_girl_rails" from this project as a dependency Scenario: Using Factory Girl and Factory Girl Rails with Test Unit generates a factory file and does not generate a fixture file And I run `bundle install` with a clean environment And I run `bundle exec rails generate model User name:string` with a clean environment Then the following files should exist: | test/factories/users.rb | And the following files should not exist: | test/fixtures/users.yml | Scenario: Using Factory Girl and Factory Girl Rails with RSpec should generate a factory file When I add "rspec-rails" as a dependency And I configure the factories as: """ config.generators do |g| g.test_framework :rspec, fixture: true g.fixture_replacement :factory_girl end """ And I run `bundle install` with a clean environment Then the output should contain "rspec-rails" And I run `bundle exec rails generate model User name:string` with a clean environment Then the following files should exist: | spec/factories/users.rb | And the following files should not exist: | spec/fixtures/users.yml | Scenario: Using Factory Girl and Factory Girl Rails with RSpec and suffix configuration should generate a factory file with suffix When I add "rspec-rails" as a dependency And I configure the factories as: """ config.generators do |g| g.test_framework :rspec, fixture: true g.fixture_replacement :factory_girl, suffix: 'factory' end """ And I run `bundle install` with a clean environment Then the output should contain "rspec-rails" And I run `bundle exec rails generate model User name:string` with a clean environment Then the following files should exist: | spec/factories/users_factory.rb | And the following files should not exist: | spec/fixtures/users.yml | Scenario: Using Factory Girl and Factory Girl Rails does not override a manually-configured factories directory using RSpec When I add "rspec-rails" as a dependency And I configure the factories directory as "custom/dir" And I run `bundle install` with a clean environment Then the output should contain "rspec-rails" And I run `bundle exec rails generate model User name:string` with a clean environment Then the following files should not exist: | test/factories/users.rb | | spec/factories/users.rb | But the following files should exist: | custom/dir/users.rb | Scenario: Using Factory Girl and Factory Girl Rails does not override a manually-configured factories directory using Test::Unit When I configure the factories directory as "custom/dir" And I run `bundle install` with a clean environment And I run `bundle exec rails generate model User name:string` with a clean environment Then the following files should not exist: | test/factories/users.rb | | spec/factories/users.rb | But the following files should exist: | custom/dir/users.rb | Scenario: Using Factory Girl Rails with MiniTest should generate a factory file When I run `bundle install` with a clean environment And I run `bundle exec rails generate model User name:string` with a clean environment Then the following files should exist: | test/factories/users.rb | But the following files should not exist: | spec/fixtures/users.yml | Scenario: Using Factory Girl Rails with MiniTest and a custom directory should generate a factory file When I configure the factories directory as "custom/dir" And I run `bundle install` with a clean environment And I run `bundle exec rails generate model User name:string` with a clean environment Then the following files should exist: | custom/dir/users.rb | But the following files should not exist: | spec/fixtures/users.yml | Scenario: Disable Factory Girl generator When I configure the factories as: """ config.generators do |g| g.factory_girl false end """ And I run `bundle install` with a clean environment And I run `bundle exec rails generate model User name:string` with a clean environment Then the following files should not exist: | test/factories/users.rb | | spec/factories/users.rb | Scenario: Use a suffix with the Factory Girl generator When I add "rspec-rails" as a dependency When I configure the factories as: """ config.generators do |g| g.factory_girl suffix: 'suffix' end """ And I run `bundle install` with a clean environment And I run `bundle exec rails generate model User name:string` with a clean environment Then the following files should exist: | spec/factories/users_suffix.rb | Then the following files should not exist: | spec/factories/users.rb | Scenario: Use a filename_proc with the Factory Girl generator When I add "rspec-rails" as a dependency When I configure the factories as: """ config.generators do |g| g.factory_girl filename_proc: Proc.new { |tb| "prefix_#{tb.singularize}_suffix" } end """ And I run `bundle install` with a clean environment And I run `bundle exec rails generate model User name:string` with a clean environment Then the following files should exist: | spec/factories/prefix_user_suffix.rb | Then the following files should not exist: | spec/factories/users.rb | factory_girl_rails-4.7.0/features/generators.feature0000644000004100000410000000422212706167354023007 0ustar www-datawww-dataFeature: In order to easily generate factory files instead of fixture files when generating models As a user of Rails and Factory Girl I would like to use factory_girl_rails generators. Background: Given I successfully run `bundle exec rails new testapp` And I cd to "testapp" And I add "factory_girl_rails" from this project as a dependency Scenario: The factory_girl_rails generators create a factory file for each model if there is not a factories.rb file When I run `bundle install` with a clean environment And I run `bundle exec rails generate model User name:string age:integer` with a clean environment And I run `bundle exec rails generate model Namespaced::User name:string` with a clean environment Then the output should contain "test/factories/users.rb" And the output should contain "test/factories/namespaced_users.rb" And the file "test/factories/users.rb" should contain exactly: """ FactoryGirl.define do factory :user do name "MyString" age 1 end end """ And the file "test/factories/namespaced_users.rb" should contain "factory :namespaced_user, class: 'Namespaced::User' do" Scenario: The factory_girl_rails generators add a factory in the correct spot When I run `bundle install` with a clean environment And I write to "test/factories.rb" with: """ FactoryGirl.define do end """ And I run `bundle exec rails generate model User name:string` with a clean environment Then the file "test/factories.rb" should contain exactly: """ FactoryGirl.define do factory :user do name "MyString" end end """ Scenario: The factory_girl_rails generators does not create a factory file for each model if there is a factories.rb file in the test directory When I run `bundle install` with a clean environment And I write to "test/factories.rb" with: """ FactoryGirl.define do end """ And I run `bundle exec rails generate model User name:string` with a clean environment Then the file "test/factories.rb" should contain "factory :user do" factory_girl_rails-4.7.0/features/load_definitions.feature0000644000004100000410000000514012706167354024150 0ustar www-datawww-dataFeature: automatically load step definitions Background: When I successfully run `bundle exec rails new testapp` And I cd to "testapp" And I add "factory_girl_rails" from this project as a dependency And I add "test-unit" as a dependency And I run `bundle install` with a clean environment And I write to "db/migrate/1_create_users.rb" with: """ class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :name end end end """ When I run `bundle exec rake db:migrate` with a clean environment And I write to "app/models/user.rb" with: """ class User < ActiveRecord::Base end """ Scenario: generate a Rails application and use factory definitions When I write to "test/factories.rb" with: """ FactoryGirl.define do factory :user do name "Frank" end end """ When I write to "test/unit/user_test.rb" with: """ require 'test_helper' class UserTest < ActiveSupport::TestCase test "use factory" do user = FactoryGirl.create(:user) assert_equal 'Frank', user.name end end """ When I run `bundle exec rake test` with a clean environment Then the output should contain "1 assertions, 0 failures, 0 errors" Scenario: use factories advertised by railties/engines/3rd-party gems When I append to "config/application.rb" with: """ require File.expand_path('../../lib/some_railtie/railties.rb', __FILE__) """ When I write to "lib/some_railtie/railties.rb" with: """ module SomeRailtie class Railtie < ::Rails::Engine initializer "some_railtie.factories", :after => "factory_girl.set_factory_paths" do FactoryGirl.definition_file_paths << File.expand_path('../factories', __FILE__) end end end """ When I write to "lib/some_railtie/factories.rb" with: """ FactoryGirl.define do factory :factory_from_some_railtie, class: 'User' do name 'Artem' end end """ When I write to "test/unit/user_test.rb" with: """ require 'test_helper' class UserTest < ActiveSupport::TestCase test "use factory of some_railtie" do user = FactoryGirl.create(:factory_from_some_railtie) assert_equal 'Artem', user.name end end """ When I run `bundle exec rake test` with a clean environment Then the output should contain "1 assertions, 0 failures, 0 errors" factory_girl_rails-4.7.0/features/support/0000755000004100000410000000000012706167354020775 5ustar www-datawww-datafactory_girl_rails-4.7.0/features/support/env.rb0000644000004100000410000000124312706167354022112 0ustar www-datawww-datarequire 'aruba/cucumber' PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze Aruba.configure do |config| config.exit_timeout = Integer ENV.fetch("ARUBA_TIMEOUT") { 120 } end Aruba.configure do |config| config.before_cmd do |cmd| set_env('JRUBY_OPTS', "-X-C #{ENV['JRUBY_OPTS']}") # disable JIT since these processes are so short lived java_options = ENV['JAVA_OPTS'] if 1.size == 4 # 4 for 32 bit java, 8 for 64 bit java. set_env('JAVA_OPTS', "-d32 #{java_options}") else set_env('JAVA_OPTS', "-XX:+TieredCompilation -XX:TieredStopAtLevel=1 #{java_options}") end end end if RUBY_PLATFORM == 'java' factory_girl_rails-4.7.0/NEWS0000644000004100000410000000063312706167354016144 0ustar www-datawww-data4.7.0 (April 1, 2016) No notable changes 4.4.1 (February 26, 2014) Support Spring 4.2.1 (February 8, 2013) Fix bug when configuring FG and RSpec fixture directory Remove debugging Require factory_girl_rails explicitly in generator 4.2.0 (January 25, 2013) Add appraisal and get test suite working reliably with turn gem Support MiniTest Allow a custom directory for factories to be specified factory_girl_rails-4.7.0/.travis.yml0000644000004100000410000000110112706167354017545 0ustar www-datawww-datalanguage: ruby env: - ARUBA_TIMEOUT=240 before_install: - gem update --system - gem update bundler - gem cleanup bundler cache: bundler rvm: - 2.1.5 - 2.2.4 - 2.3.0 - jruby-19mode branches: only: - master install: - "travis_retry bundle install --jobs 8" gemfile: - gemfiles/rails3.2.gemfile - gemfiles/rails4.1.gemfile - gemfiles/rails4.2.gemfile - gemfiles/rails5.0.gemfile matrix: fast_finish: true allow_failures: - rvm: jruby-19mode gemfile: gemfiles/rails5.0.gemfile - rvm: 2.1.5 gemfile: gemfiles/rails5.0.gemfile factory_girl_rails-4.7.0/lib/0000755000004100000410000000000012706167354016211 5ustar www-datawww-datafactory_girl_rails-4.7.0/lib/generators/0000755000004100000410000000000012706167354020362 5ustar www-datawww-datafactory_girl_rails-4.7.0/lib/generators/factory_girl/0000755000004100000410000000000012706167354023046 5ustar www-datawww-datafactory_girl_rails-4.7.0/lib/generators/factory_girl/model/0000755000004100000410000000000012706167354024146 5ustar www-datawww-datafactory_girl_rails-4.7.0/lib/generators/factory_girl/model/model_generator.rb0000644000004100000410000000424412706167354027645 0ustar www-datawww-datarequire 'generators/factory_girl' require 'factory_girl_rails' module FactoryGirl module Generators class ModelGenerator < Base argument( :attributes, type: :array, default: [], banner: "field:type field:type" ) class_option( :dir, type: :string, default: "test/factories", desc: "The directory or file root where factories belong" ) class_option( :suffix, type: :string, default: nil, desc: "Suffix to add factory file" ) def create_fixture_file if File.exist?(factories_file) insert_factory_into_existing_file else create_factory_file end end private def factories_file options[:dir] + ".rb" end def insert_factory_into_existing_file insert_into_file( factories_file, factory_definition, after: "FactoryGirl.define do\n" ) end def create_factory_file file = File.join(options[:dir], "#{filename}.rb") create_file(file, single_file_factory_definition) end def factory_definition <<-RUBY factory :#{singular_table_name}#{explicit_class_option} do #{factory_attributes.gsub(/^/, " ")} end RUBY end def single_file_factory_definition <<-RUBY FactoryGirl.define do #{factory_definition.chomp} end RUBY end def factory_attributes attributes.map do |attribute| "#{attribute.name} #{attribute.default.inspect}" end.join("\n") end def filename if factory_girl_options[:filename_proc].present? factory_girl_options[:filename_proc].call(table_name) else [table_name, filename_suffix].compact.join('_') end end def filename_suffix factory_girl_options[:suffix] || options[:suffix] end def factory_girl_options generators.options[:factory_girl] || {} end def generators config = FactoryGirl::Railtie.config config.respond_to?(:app_generators) ? config.app_generators : config.generators end end end end factory_girl_rails-4.7.0/lib/generators/factory_girl.rb0000644000004100000410000000070412706167354023374 0ustar www-datawww-datarequire 'rails/generators/named_base' module FactoryGirl module Generators class Base < Rails::Generators::NamedBase #:nodoc: def self.source_root @_factory_girl_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'factory_girl', generator_name, 'templates')) end def explicit_class_option ", class: '#{class_name}'" unless class_name == singular_table_name.camelize end end end end factory_girl_rails-4.7.0/lib/factory_girl_rails/0000755000004100000410000000000012706167354022067 5ustar www-datawww-datafactory_girl_rails-4.7.0/lib/factory_girl_rails/generators/0000755000004100000410000000000012706167354024240 5ustar www-datawww-datafactory_girl_rails-4.7.0/lib/factory_girl_rails/generators/null_generator.rb0000644000004100000410000000023212706167354027602 0ustar www-datawww-datamodule FactoryGirlRails module Generators class NullGenerator def initialize(generators) end def run end end end end factory_girl_rails-4.7.0/lib/factory_girl_rails/generators/rspec_generator.rb0000644000004100000410000000104712706167354027751 0ustar www-datawww-datamodule FactoryGirlRails module Generators class RSpecGenerator def initialize(generators) @generators = generators end def run @generators.fixture_replacement fixture_replacement_setting, dir: factory_girl_directory end private def fixture_replacement_setting @generators.options[:rails][:fixture_replacement] || :factory_girl end def factory_girl_directory @generators.options.fetch(:factory_girl, {}).fetch(:dir, 'spec/factories') end end end end factory_girl_rails-4.7.0/lib/factory_girl_rails/generators/non_rspec_generator.rb0000644000004100000410000000061512706167354030623 0ustar www-datawww-datamodule FactoryGirlRails module Generators class NonRSpecGenerator def initialize(generators) @generators = generators end def run @generators.test_framework test_framework, fixture: false, fixture_replacement: :factory_girl end private def test_framework @generators.options[:rails][:test_framework] end end end end factory_girl_rails-4.7.0/lib/factory_girl_rails/generator.rb0000644000004100000410000000172312706167354024405 0ustar www-datawww-datarequire 'factory_girl_rails/generators/rspec_generator' require 'factory_girl_rails/generators/non_rspec_generator' require 'factory_girl_rails/generators/null_generator' module FactoryGirlRails class Generator def initialize(config) @generators = if config.respond_to?(:app_generators) config.app_generators else config.generators end end def run generator.new(@generators).run end def generator if factory_girl_disabled? Generators::NullGenerator else if test_framework == :rspec Generators::RSpecGenerator else Generators::NonRSpecGenerator end end end def test_framework rails_options[:test_framework] end def factory_girl_disabled? rails_options[:factory_girl] == false end def rails_options @generators.options[:rails] end end end factory_girl_rails-4.7.0/lib/factory_girl_rails/railtie.rb0000644000004100000410000000122512706167354024045 0ustar www-datawww-datarequire 'factory_girl' require 'factory_girl_rails/generator' require 'rails' module FactoryGirl class Railtie < Rails::Railtie initializer "factory_girl.set_fixture_replacement" do FactoryGirlRails::Generator.new(config).run end initializer "factory_girl.set_factory_paths" do FactoryGirl.definition_file_paths = [ Rails.root.join('factories'), Rails.root.join('test', 'factories'), Rails.root.join('spec', 'factories') ] end config.after_initialize do FactoryGirl.find_definitions if defined?(Spring) Spring.after_fork { FactoryGirl.reload } end end end end factory_girl_rails-4.7.0/lib/factory_girl_rails.rb0000644000004100000410000000010212706167354022405 0ustar www-datawww-datarequire 'factory_girl_rails/railtie' module FactoryGirlRails end factory_girl_rails-4.7.0/gemfiles/0000755000004100000410000000000012706167354017236 5ustar www-datawww-datafactory_girl_rails-4.7.0/gemfiles/rails4.1.gemfile0000644000004100000410000000101012706167354022115 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "appraisal" gem "aruba" gem "coffee-rails" gem "cucumber", "1.3.19" gem "jquery-rails" gem "rake" gem "rspec-rails" gem "uglifier" gem "test-unit" gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby gem "jdbc-sqlite3", :platforms => :jruby gem "therubyrhino", :platforms => :jruby gem "jruby-openssl", :platforms => :jruby gem "sqlite3", :platforms => :ruby gem "rails", "~> 4.1.9" gem "sass-rails" gem "spring" gemspec :path => "../" factory_girl_rails-4.7.0/gemfiles/rails3.2.gemfile0000644000004100000410000000077412706167354022135 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "appraisal" gem "aruba" gem "coffee-rails" gem "cucumber", "1.3.19" gem "jquery-rails" gem "rake" gem "rspec-rails" gem "uglifier" gem "test-unit" gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby gem "jdbc-sqlite3", :platforms => :jruby gem "therubyrhino", :platforms => :jruby gem "jruby-openssl", :platforms => :jruby gem "sqlite3", :platforms => :ruby gem "rails", "~> 3.2.21" gem "sass-rails" gemspec :path => "../" factory_girl_rails-4.7.0/gemfiles/rails5.0.gemfile0000644000004100000410000000105212706167354022123 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "appraisal" gem "aruba" gem "coffee-rails" gem "cucumber", "1.3.19" gem "jquery-rails" gem "rake" gem "rspec-rails", "~> 3.5.0.beta3" gem "uglifier" gem "test-unit" gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby gem "jdbc-sqlite3", :platforms => :jruby gem "therubyrhino", :platforms => :jruby gem "jruby-openssl", :platforms => :jruby gem "sqlite3", :platforms => :ruby gem "activerecord", "~> 5.0.0.beta3" gem "railties", "~> 5.0.0.beta3" gemspec :path => "../" factory_girl_rails-4.7.0/gemfiles/rails4.2.gemfile0000644000004100000410000000075212706167354022132 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "appraisal" gem "aruba" gem "coffee-rails" gem "cucumber", "1.3.19" gem "jquery-rails" gem "rake" gem "rspec-rails" gem "uglifier" gem "test-unit" gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby gem "jdbc-sqlite3", :platforms => :jruby gem "therubyrhino", :platforms => :jruby gem "jruby-openssl", :platforms => :jruby gem "sqlite3", :platforms => :ruby gem "rails", "~> 4.2.0" gemspec :path => "../" factory_girl_rails-4.7.0/.gitignore0000644000004100000410000000012512706167354017431 0ustar www-datawww-data*.swp .bundle gemfiles/*.lock coverage factory_girl_rails-*.gem pkg rdoc test.db tmp factory_girl_rails-4.7.0/CONTRIBUTING.md0000644000004100000410000000211412706167354017672 0ustar www-datawww-data# Contributing We love pull requests from everyone. By participating in this project, you agree to abide by the thoughtbot [code of conduct]. [code of conduct]: https://thoughtbot.com/open-source-code-of-conduct Fork, then clone the repo: git clone git@github.com:your-username/factory_girl_rails.git Set up your machine: ./bin/setup Make sure the tests pass: rake Make your change. Add tests for your change. Make the tests pass: rake Push to your fork and [submit a pull request][pr]. [pr]: https://github.com/thoughtbot/factory_girl_rails/compare/ At this point you're waiting on us. We like to at least comment on pull requests within three business days (and, typically, one business day). We may suggest some changes or improvements or alternatives. Some things that will increase the chance that your pull request is accepted: * Write tests. * Follow our [style guide][style]. * Write a [good commit message][commit]. [style]: https://github.com/thoughtbot/guides/tree/master/style [commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html factory_girl_rails-4.7.0/LICENSE0000644000004100000410000000207012706167354016447 0ustar www-datawww-dataCopyright (c) 2008-2013 Joe Ferris and thoughtbot, inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. factory_girl_rails-4.7.0/Appraisals0000644000004100000410000000063612706167354017472 0ustar www-datawww-data# These are the versions of Rails we want to test against. appraise 'rails3.2' do gem 'rails', '~> 3.2.21' gem 'sass-rails' end appraise 'rails4.1' do gem 'rails', '~> 4.1.9' gem 'sass-rails' gem 'spring' end appraise 'rails4.2' do gem 'rails', '~> 4.2.0' end appraise "rails5.0" do gem "activerecord", "~> 5.0.0.beta3" gem "railties", "~> 5.0.0.beta3" gem "rspec-rails", "~> 3.5.0.beta3" end factory_girl_rails-4.7.0/README.md0000644000004100000410000000542512706167354016730 0ustar www-datawww-data# factory_girl_rails [![Build Status][ci-image]][ci] [![Code Climate][grade-image]][grade] [factory_girl][fg] is a fixtures replacement with a straightforward definition syntax, support for multiple build strategies (saved instances, unsaved instances, attribute hashes, and stubbed objects), and support for multiple factories for the same class (`user`, `admin_user`, and so on), including factory inheritance. ## Rails factory_girl_rails provides Rails integration for [factory_girl][fg]. Currently, automatic factory definition loading is the only Rails-specific feature. Supported Rails versions are listed in [`Appraisals`](Appraisals). Supported Ruby versions are listed in [`.travis.yml`](.travis.yml). ## Download Github: http://github.com/thoughtbot/factory_girl_rails Gem: gem install factory_girl_rails ## Configuration Add `factory_girl_rails` to your Gemfile: ```ruby gem 'factory_girl_rails' ``` Generators for factories will automatically substitute fixture (and maybe any other `fixture_replacement` you set). If you want to disable this feature, add the following to your application.rb file: ```ruby config.generators do |g| g.factory_girl false end ``` Default factories directory is `test/factories`, or `spec/factories` if `test_framework` generator is set to `:rspec`; change this behavior with: ```ruby config.generators do |g| g.factory_girl dir: 'custom/dir/for/factories' end ``` If you use factory_girl for fixture replacement, ensure that factory_girl_rails is available in the development group. If it's not, Rails will generate standard .yml files instead of factory files. factory_girl takes an option `suffix: 'some_suffix'` to generate factories as `modelname_some_suffix.rb`. If you use factory_girl for fixture replacement and already have a `factories.rb` file in the directory that contains your tests, factory_girl_rails will insert new factory definitions at the top of `factories.rb`. ## Contributing Please see [CONTRIBUTING.md](CONTRIBUTING.md). ## Credits [factory_girl][fg] was originally written by Joe Ferris. ![thoughtbot](http://thoughtbot.com/images/tm/logo.png) factory_girl is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community) The names and logos for thoughtbot are trademarks of thoughtbot, inc. ## License factory_girl_rails is Copyright © 2008-2014 Joe Ferris and thoughtbot. It is free software, and may be redistributed under the terms specified in the [LICENSE]() file. [fg]: https://github.com/thoughtbot/factory_girl [ci]: http://travis-ci.org/thoughtbot/factory_girl_rails?branch=master [ci-image]: https://secure.travis-ci.org/thoughtbot/factory_girl_rails.png [grade]: https://codeclimate.com/github/thoughtbot/factory_girl_rails [grade-image]: https://codeclimate.com/github/thoughtbot/factory_girl_rails.png