Skip to content

Instantly share code, notes, and snippets.

@theoretick
Created December 15, 2017 18:39
Show Gist options
  • Save theoretick/afb9666b0809c470b75002f84d0578dd to your computer and use it in GitHub Desktop.
Save theoretick/afb9666b0809c470b75002f84d0578dd to your computer and use it in GitHub Desktop.
#!/bin/sh
# forked from https://gist.github.com/Draiken/dbe1bd2af0d583c28d75
echo "Generating rails app"
rails new fabrication_test --quiet
cd fabrication_test
echo "gem 'fabrication'" >> Gemfile
echo "Installing fabrication"
bundle install > /dev/null
echo "Generating models and fabricators"
mkdir test/fabricators
cat > test/fabricators/fabricators.rb <<EOF
Fabricator(:author) do
end
Fabricator(:post) do
author
end
EOF
rails g model author --quiet
rails g model post author:references --quiet
rake db:migrate > /dev/null
echo "Running: rails runner \"puts Fabricate(:post, author_id: 999).author_id\""
rails runner "puts Fabricate(:post, author_id: 999).author_id"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment