seedbank 0.0.9 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +26 -0
- data/.travis.yml +9 -0
- data/Gemfile +16 -0
- data/README.md +49 -1
- data/Rakefile +6 -7
- data/lib/seedbank.rb +8 -6
- data/lib/seedbank/dsl.rb +3 -1
- data/lib/seedbank/railtie.rb +1 -0
- data/lib/seedbank/runner.rb +31 -0
- data/lib/seedbank/version.rb +1 -1
- data/lib/tasks/seed.rake +5 -3
- data/seedbank.gemspec +6 -3
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/models/fake_model.rb +7 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +29 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +6 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +34 -0
- data/test/dummy/config/environments/test.rb +32 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +2 -0
- data/test/dummy/db/seeds.rb +0 -0
- data/test/dummy/db/seeds/circular1.seeds.rb +3 -0
- data/test/dummy/db/seeds/circular2.seeds.rb +3 -0
- data/test/dummy/db/seeds/dependency.seeds.rb +1 -0
- data/test/dummy/db/seeds/dependency2.seeds.rb +1 -0
- data/test/dummy/db/seeds/dependent.seeds.rb +3 -0
- data/test/dummy/db/seeds/dependent_on_nested.seeds.rb +3 -0
- data/test/dummy/db/seeds/dependent_on_several.seeds.rb +3 -0
- data/test/dummy/db/seeds/no_block.seeds.rb +1 -0
- data/test/dummy/script/rails +6 -0
- data/test/seedbank/runner_test.rb +59 -0
- data/test/test_helper.rb +26 -2
- metadata +118 -60
- data/test/seedbank_test.rb +0 -8
data/.gitignore
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## PROJECT::GENERAL
|
17
|
+
coverage
|
18
|
+
rdoc
|
19
|
+
pkg
|
20
|
+
|
21
|
+
## PROJECT::SPECIFIC
|
22
|
+
*.gem
|
23
|
+
test/dummy/tmp
|
24
|
+
test/dummy/log
|
25
|
+
.rvmrc
|
26
|
+
Gemfile.lock
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in seedbank.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :test do
|
7
|
+
gem 'rake'
|
8
|
+
end
|
9
|
+
|
10
|
+
# for CRuby, Rubinius, including Windows and RubyInstaller
|
11
|
+
gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
|
12
|
+
|
13
|
+
# for JRuby
|
14
|
+
platform :jruby do
|
15
|
+
gem 'activerecord-jdbcsqlite3-adapter'
|
16
|
+
end
|
data/README.md
CHANGED
@@ -76,12 +76,60 @@ Seedbank.load_tasks if defined?(Seedbank)
|
|
76
76
|
|
77
77
|
If you vendor the gem you'll need to change the require to the specific path.
|
78
78
|
|
79
|
+
Usage
|
80
|
+
=====
|
81
|
+
|
82
|
+
Seeds files are just plain old Ruby executed in your rails application environment so anything you could type into the rails console will work in your seeds.
|
83
|
+
|
84
|
+
The seed files under db/seeds are run first in alphanumeric order followed by the ones in the db/seeds/RAILS_ENV. You can add dependencies to your seed files
|
85
|
+
to enforce the run order. for example;
|
86
|
+
|
87
|
+
db/seeds/companies.seeds.rb
|
88
|
+
```ruby
|
89
|
+
Company.find_or_create_by_name('Hatch', :url => 'http://thisishatch.co.uk' )
|
90
|
+
```
|
91
|
+
|
92
|
+
db/seeds/users.seeds.rb
|
93
|
+
```ruby
|
94
|
+
after :companies do
|
95
|
+
company = Company.find_by_name('Hatch')
|
96
|
+
company.users.create(:first_name => 'James', :last_name => 'McCarthy')
|
97
|
+
end
|
98
|
+
```
|
99
|
+
|
100
|
+
db/seeds/projects.seeds.rb
|
101
|
+
```ruby
|
102
|
+
after :companies do
|
103
|
+
company = Company.find_by_name('Hatch')
|
104
|
+
company.projects.create(:title => 'Seedbank')
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
108
|
+
db/seeds/tasks.seeds.rb
|
109
|
+
```ruby
|
110
|
+
after :projects, :users do
|
111
|
+
project = Project.find_by_name('Seedbank')
|
112
|
+
user = User.find_by_first_name_and_last_name('James', 'McCarthy')
|
113
|
+
project.tasks.create(:owner => user, :title => 'Document seed dependencies in the README.md')
|
114
|
+
end
|
115
|
+
```
|
116
|
+
|
117
|
+
Contributors
|
118
|
+
============
|
119
|
+
```shell
|
120
|
+
git log | grep Author | sort | uniq
|
121
|
+
```
|
122
|
+
|
123
|
+
* James McCarthy
|
124
|
+
* Andy Triggs
|
125
|
+
* Philip Arndt
|
126
|
+
|
79
127
|
Note on Patches/Pull Request
|
80
128
|
============================
|
81
129
|
|
82
130
|
* Fork the project.
|
83
131
|
* Make your feature addition or bug fix.
|
84
|
-
* Add tests for it
|
132
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
85
133
|
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but
|
86
134
|
bump version in a commit by itself I can ignore it when I pull)
|
87
135
|
* Send me a pull request. Bonus points for topic branches.
|
data/Rakefile
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
1
2
|
require 'rake'
|
2
3
|
require 'rake/testtask'
|
3
|
-
require '
|
4
|
-
|
5
|
-
desc 'Default: run unit tests.'
|
6
|
-
task :default => :test
|
4
|
+
require 'rdoc/task'
|
7
5
|
|
8
6
|
desc 'Test the seedbank gem.'
|
9
7
|
Rake::TestTask.new(:test) do |t|
|
10
8
|
t.libs << 'lib'
|
11
9
|
t.libs << 'test'
|
12
|
-
t.pattern = 'test/**/*_test.rb'
|
10
|
+
t.pattern = 'test/seedbank/**/*_test.rb'
|
13
11
|
t.verbose = true
|
14
12
|
end
|
15
13
|
|
@@ -18,6 +16,7 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
18
16
|
rdoc.rdoc_dir = 'rdoc'
|
19
17
|
rdoc.title = 'Seedbank'
|
20
18
|
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
-
rdoc.rdoc_files.include('README')
|
22
19
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
-
end
|
20
|
+
end
|
21
|
+
|
22
|
+
task :default => ["test"]
|
data/lib/seedbank.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
require 'seedbank/dsl'
|
2
2
|
require 'seedbank/task'
|
3
3
|
require 'seedbank/task_manager'
|
4
|
+
require 'seedbank/runner'
|
4
5
|
|
5
6
|
require 'rake' unless defined?(Rake)
|
6
7
|
|
7
|
-
Rake::Task.extend(Seedbank::Task)
|
8
|
-
Rake::Application.send(:include, Seedbank::TaskManager)
|
9
|
-
|
10
8
|
module Seedbank
|
11
9
|
|
12
|
-
|
10
|
+
class << self
|
11
|
+
|
12
|
+
attr_writer :seeds_root
|
13
|
+
|
14
|
+
def seeds_root
|
15
|
+
@seeds_root ||= 'db/seeds'
|
16
|
+
end
|
13
17
|
|
14
|
-
def self.seeds_root
|
15
|
-
@@seeds_root
|
16
18
|
end
|
17
19
|
|
18
20
|
def self.load_tasks
|
data/lib/seedbank/dsl.rb
CHANGED
@@ -16,7 +16,9 @@ module Seedbank
|
|
16
16
|
fq_name = scopes.push(File.basename(seed_file, '.seeds.rb')).join(':')
|
17
17
|
|
18
18
|
args = Rake::Task.task_defined?('db:abort_if_pending_migrations') ? { fq_name => 'db:abort_if_pending_migrations' } : fq_name
|
19
|
-
task = Rake::Task.define_task(args)
|
19
|
+
task = Rake::Task.define_task(args) do |seed_task|
|
20
|
+
Seedbank::Runner.new(seed_task).module_eval(File.read(seed_file)) if File.exist?(seed_file)
|
21
|
+
end
|
20
22
|
task.add_description "Load the seed data from #{seed_file}"
|
21
23
|
fq_name
|
22
24
|
end
|
data/lib/seedbank/railtie.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Seedbank
|
2
|
+
class Runner < Module
|
3
|
+
|
4
|
+
def initialize(task)
|
5
|
+
@task = task
|
6
|
+
super()
|
7
|
+
end
|
8
|
+
|
9
|
+
# Run this seed after the specified dependencies have run
|
10
|
+
# @param dependencies [Array] seeds to run before the block is executed
|
11
|
+
#
|
12
|
+
# If a block is specified the contents of the block are executed after all the
|
13
|
+
# dependencies have been executed.
|
14
|
+
#
|
15
|
+
# If no block is specified just the dependencies are run. This makes it possible
|
16
|
+
# to create shared dependencies. For example
|
17
|
+
#
|
18
|
+
# @example db/seeds/production/users.seeds.rb
|
19
|
+
# after 'shared:users'
|
20
|
+
#
|
21
|
+
# Would look for a db/seeds/shared/users.seeds.rb seed and execute it.
|
22
|
+
def after(*dependencies, &block)
|
23
|
+
dependencies.flatten!
|
24
|
+
dependencies.map! { |dep| "db:seed:#{dep}"}
|
25
|
+
dependent_task_name = @task.name + ':body'
|
26
|
+
dependent_task = Rake::Task.define_task(dependent_task_name => dependencies, &block)
|
27
|
+
dependent_task.invoke
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
data/lib/seedbank/version.rb
CHANGED
data/lib/tasks/seed.rake
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
namespace :db do
|
2
2
|
|
3
|
+
Rake::Task.extend(Seedbank::Task)
|
4
|
+
Rake::Application.send(:include, Seedbank::TaskManager)
|
3
5
|
include Seedbank::DSL
|
4
6
|
|
5
|
-
base_dependencies
|
7
|
+
base_dependencies = ['db:seed:original']
|
6
8
|
override_dependency = []
|
7
|
-
|
8
9
|
common_dependencies = []
|
10
|
+
|
9
11
|
# Create seed tasks for all the seeds in seeds_path and add them to the dependency
|
10
12
|
# list along with the original db/seeds.rb.
|
11
13
|
Dir.glob(File.join(seeds_root, '*.seeds.rb')).each do |seed_file|
|
@@ -22,7 +24,7 @@ namespace :db do
|
|
22
24
|
environment = File.basename(e)
|
23
25
|
|
24
26
|
environment_dependencies = []
|
25
|
-
Dir.glob(File.join(seeds_root, environment, '*.seeds.rb')).each do |seed_file|
|
27
|
+
Dir.glob(File.join(seeds_root, environment, '*.seeds.rb')).sort.each do |seed_file|
|
26
28
|
environment_dependencies << define_seed_task(seed_file)
|
27
29
|
end
|
28
30
|
|
data/seedbank.gemspec
CHANGED
@@ -22,7 +22,9 @@ Gem::Specification.new do |s|
|
|
22
22
|
files and lets each environment have it's own seeds.
|
23
23
|
}
|
24
24
|
|
25
|
-
s.files
|
25
|
+
s.files = `git ls-files`.split("\n")
|
26
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
27
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
26
28
|
s.require_paths = ["lib"]
|
27
29
|
|
28
30
|
s.rdoc_options = ["--charset=UTF-8"]
|
@@ -31,8 +33,9 @@ Gem::Specification.new do |s|
|
|
31
33
|
"README.md"
|
32
34
|
]
|
33
35
|
|
34
|
-
s.
|
35
|
-
s.add_development_dependency
|
36
|
+
s.add_development_dependency "minitest", "~> 3.2"
|
37
|
+
s.add_development_dependency "flexmock"
|
38
|
+
s.add_development_dependency "rails", "~> 3.2.6"
|
36
39
|
|
37
40
|
s.post_install_message = %q{
|
38
41
|
================================================================================
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
require "active_record/railtie"
|
5
|
+
|
6
|
+
Bundler.require if defined?(Bundler)
|
7
|
+
require 'seedbank'
|
8
|
+
|
9
|
+
module Dummy
|
10
|
+
class Application < Rails::Application
|
11
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
12
|
+
config.encoding = "utf-8"
|
13
|
+
|
14
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
15
|
+
config.filter_parameters += [:password]
|
16
|
+
|
17
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
18
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
19
|
+
# like if you have constraints or database-specific column types
|
20
|
+
# config.active_record.schema_format = :sql
|
21
|
+
|
22
|
+
# Enforce whitelist mode for mass assignment.
|
23
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
24
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
25
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
26
|
+
config.active_record.whitelist_attributes = true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Print deprecation notices to the Rails logger
|
17
|
+
config.active_support.deprecation = :log
|
18
|
+
|
19
|
+
# Only use best-standards-support built into browsers
|
20
|
+
config.action_dispatch.best_standards_support = :builtin
|
21
|
+
|
22
|
+
# Raise exception on mass assignment protection for Active Record models
|
23
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
24
|
+
|
25
|
+
# Log the query plan for queries taking more than this (works
|
26
|
+
# with SQLite, MySQL, and PostgreSQL)
|
27
|
+
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
28
|
+
|
29
|
+
# Do not compress assets
|
30
|
+
config.assets.compress = false
|
31
|
+
|
32
|
+
# Expands the lines which load the assets
|
33
|
+
config.assets.debug = true
|
34
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Configure static asset server for tests with Cache-Control for performance
|
11
|
+
config.serve_static_assets = true
|
12
|
+
config.static_cache_control = "public, max-age=3600"
|
13
|
+
|
14
|
+
# Log error messages when you accidentally call methods on nil
|
15
|
+
config.whiny_nils = true
|
16
|
+
|
17
|
+
# Show full error reports and disable caching
|
18
|
+
config.consider_all_requests_local = true
|
19
|
+
config.action_controller.perform_caching = false
|
20
|
+
|
21
|
+
# Raise exceptions instead of rendering exception templates
|
22
|
+
config.action_dispatch.show_exceptions = false
|
23
|
+
|
24
|
+
# Disable request forgery protection in test environment
|
25
|
+
config.action_controller.allow_forgery_protection = false
|
26
|
+
|
27
|
+
# Raise exception on mass assignment protection for Active Record models
|
28
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
29
|
+
|
30
|
+
# Print deprecation notices to the stderr
|
31
|
+
config.active_support.deprecation = :stderr
|
32
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Dummy::Application.config.secret_token = 'c2af159f67aa6955b415217bf5aa58779dec6fccc201c7bf38f9a8ad25893d88596778df8bb7106153666f41c3161cfb7f89b639a2c15a084abb6c2c57f74c55'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
#
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters :format => [:json]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Disable root element in JSON by default.
|
12
|
+
ActiveSupport.on_load(:active_record) do
|
13
|
+
self.include_root_in_json = false
|
14
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
FakeModel.seed('dependency')
|
@@ -0,0 +1 @@
|
|
1
|
+
FakeModel.seed('dependency2')
|
@@ -0,0 +1 @@
|
|
1
|
+
after :dependency
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Seedbank::Runner do
|
4
|
+
|
5
|
+
before do
|
6
|
+
flexmock(FakeModel)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "seeds with dependency" do
|
10
|
+
|
11
|
+
subject { Rake::Task['db:seed:dependent'] }
|
12
|
+
|
13
|
+
it "runs the dependencies in order" do
|
14
|
+
FakeModel.should_receive(:seed).with('dependency').once.ordered
|
15
|
+
FakeModel.should_receive(:seed).with('dependent').once.ordered
|
16
|
+
|
17
|
+
subject.invoke
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "seeds with multiple dependencies" do
|
22
|
+
|
23
|
+
subject { Rake::Task['db:seed:dependent_on_several'] }
|
24
|
+
|
25
|
+
it "runs the dependencies in order" do
|
26
|
+
FakeModel.should_receive(:seed).with('dependency').once.ordered
|
27
|
+
FakeModel.should_receive(:seed).with('dependency2').once.ordered
|
28
|
+
FakeModel.should_receive(:seed).with('dependent on several').once.ordered
|
29
|
+
|
30
|
+
subject.invoke
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "seeds with nested dependencies" do
|
35
|
+
|
36
|
+
subject { Rake::Task['db:seed:dependent_on_nested'] }
|
37
|
+
|
38
|
+
it "runs all dependencies in order" do
|
39
|
+
FakeModel.should_receive(:seed).with('dependency').once.ordered
|
40
|
+
FakeModel.should_receive(:seed).with('dependent').once.ordered
|
41
|
+
FakeModel.should_receive(:seed).with('dependency2').once.ordered
|
42
|
+
FakeModel.should_receive(:seed).with('dependent on nested').once.ordered
|
43
|
+
|
44
|
+
subject.invoke
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "after with no block given" do
|
50
|
+
|
51
|
+
subject { Rake::Task['db:seed:no_block'] }
|
52
|
+
|
53
|
+
it "runs the dependencies" do
|
54
|
+
FakeModel.should_receive(:seed).with('dependency').once.ordered
|
55
|
+
|
56
|
+
subject.invoke
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,3 +1,27 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require
|
3
|
-
require '
|
2
|
+
require "flexmock"
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
# Configure Rails Environment
|
6
|
+
environment = ENV["RAILS_ENV"] = 'test'
|
7
|
+
rails_root = File.expand_path('../dummy', __FILE__)
|
8
|
+
|
9
|
+
require File.expand_path('config/environment.rb', rails_root)
|
10
|
+
|
11
|
+
Rails.backtrace_cleaner.remove_silencers!
|
12
|
+
|
13
|
+
Seedbank.seeds_root = File.expand_path('dummy/db/seeds', __FILE__)
|
14
|
+
|
15
|
+
class Seedbank::Spec < MiniTest::Spec
|
16
|
+
|
17
|
+
include FlexMock::TestCase
|
18
|
+
|
19
|
+
def setup
|
20
|
+
Rake.application = Rake::Application.new
|
21
|
+
Dummy::Application.load_tasks
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
MiniTest::Spec.register_spec_type(/^Seedbank::/, Seedbank::Spec)
|
metadata
CHANGED
@@ -1,37 +1,50 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seedbank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 9
|
10
|
-
version: 0.0.9
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.1
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
|
-
- James McCarthy
|
8
|
+
- James McCarthy
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2012-03-13 00:00:00
|
19
|
-
default_executable:
|
13
|
+
date: 2012-03-13 00:00:00 Z
|
20
14
|
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: minitest
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "3.2"
|
24
|
+
type: :development
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: flexmock
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rails
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.2.6
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id003
|
35
48
|
description: "\n Extends Rails seeds to split out complex seeds into multiple\n files and lets each environment have it's own seeds.\n "
|
36
49
|
email: james2mccarthy@gmail.com
|
37
50
|
executables: []
|
@@ -39,59 +52,104 @@ executables: []
|
|
39
52
|
extensions: []
|
40
53
|
|
41
54
|
extra_rdoc_files:
|
42
|
-
- MIT-LICENSE
|
43
|
-
- README.md
|
55
|
+
- MIT-LICENSE
|
56
|
+
- README.md
|
44
57
|
files:
|
45
|
-
-
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
55
|
-
- seedbank.
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
|
58
|
+
- .gitignore
|
59
|
+
- .travis.yml
|
60
|
+
- Gemfile
|
61
|
+
- MIT-LICENSE
|
62
|
+
- README.md
|
63
|
+
- Rakefile
|
64
|
+
- TODO.txt
|
65
|
+
- lib/seedbank.rb
|
66
|
+
- lib/seedbank/dsl.rb
|
67
|
+
- lib/seedbank/railtie.rb
|
68
|
+
- lib/seedbank/runner.rb
|
69
|
+
- lib/seedbank/task.rb
|
70
|
+
- lib/seedbank/task_manager.rb
|
71
|
+
- lib/seedbank/version.rb
|
72
|
+
- lib/tasks/seed.rake
|
73
|
+
- seedbank.gemspec
|
74
|
+
- test/dummy/Rakefile
|
75
|
+
- test/dummy/app/controllers/application_controller.rb
|
76
|
+
- test/dummy/app/models/fake_model.rb
|
77
|
+
- test/dummy/config.ru
|
78
|
+
- test/dummy/config/application.rb
|
79
|
+
- test/dummy/config/boot.rb
|
80
|
+
- test/dummy/config/database.yml
|
81
|
+
- test/dummy/config/environment.rb
|
82
|
+
- test/dummy/config/environments/development.rb
|
83
|
+
- test/dummy/config/environments/test.rb
|
84
|
+
- test/dummy/config/initializers/secret_token.rb
|
85
|
+
- test/dummy/config/initializers/session_store.rb
|
86
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
87
|
+
- test/dummy/config/locales/en.yml
|
88
|
+
- test/dummy/config/routes.rb
|
89
|
+
- test/dummy/db/seeds.rb
|
90
|
+
- test/dummy/db/seeds/circular1.seeds.rb
|
91
|
+
- test/dummy/db/seeds/circular2.seeds.rb
|
92
|
+
- test/dummy/db/seeds/dependency.seeds.rb
|
93
|
+
- test/dummy/db/seeds/dependency2.seeds.rb
|
94
|
+
- test/dummy/db/seeds/dependent.seeds.rb
|
95
|
+
- test/dummy/db/seeds/dependent_on_nested.seeds.rb
|
96
|
+
- test/dummy/db/seeds/dependent_on_several.seeds.rb
|
97
|
+
- test/dummy/db/seeds/no_block.seeds.rb
|
98
|
+
- test/dummy/script/rails
|
99
|
+
- test/seedbank/runner_test.rb
|
100
|
+
- test/test_helper.rb
|
60
101
|
homepage: http://github.com/james2m/seedbank
|
61
102
|
licenses: []
|
62
103
|
|
63
104
|
post_install_message: "\n ================================================================================\n\n Rails 2.x\n ---------\n If you are using Seedbank with Rails 2.x you will need to place the following at \n the end of your Rakefile so Rubygems can load the seedbank tasks;\n\n require 'seedbank'\n Seedbank.load_tasks if defined?(Seedbank)\n\n Rails 3.x\n ---------\n Your work here is done!\n\n ================================================================================\n "
|
64
105
|
rdoc_options:
|
65
|
-
- --charset=UTF-8
|
106
|
+
- --charset=UTF-8
|
66
107
|
require_paths:
|
67
|
-
- lib
|
108
|
+
- lib
|
68
109
|
required_ruby_version: !ruby/object:Gem::Requirement
|
69
110
|
none: false
|
70
111
|
requirements:
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
segments:
|
75
|
-
- 0
|
76
|
-
version: "0"
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: "0"
|
77
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
116
|
none: false
|
79
117
|
requirements:
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
segments:
|
84
|
-
- 1
|
85
|
-
- 2
|
86
|
-
- 0
|
87
|
-
version: 1.2.0
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 1.2.0
|
88
121
|
requirements: []
|
89
122
|
|
90
123
|
rubyforge_project:
|
91
|
-
rubygems_version: 1.
|
124
|
+
rubygems_version: 1.8.24
|
92
125
|
signing_key:
|
93
126
|
specification_version: 3
|
94
127
|
summary: Extends Rails seeds to split out complex seeds into their own file and have different seeds for each environment.
|
95
128
|
test_files:
|
96
|
-
- test/
|
97
|
-
- test/
|
129
|
+
- test/dummy/Rakefile
|
130
|
+
- test/dummy/app/controllers/application_controller.rb
|
131
|
+
- test/dummy/app/models/fake_model.rb
|
132
|
+
- test/dummy/config.ru
|
133
|
+
- test/dummy/config/application.rb
|
134
|
+
- test/dummy/config/boot.rb
|
135
|
+
- test/dummy/config/database.yml
|
136
|
+
- test/dummy/config/environment.rb
|
137
|
+
- test/dummy/config/environments/development.rb
|
138
|
+
- test/dummy/config/environments/test.rb
|
139
|
+
- test/dummy/config/initializers/secret_token.rb
|
140
|
+
- test/dummy/config/initializers/session_store.rb
|
141
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
142
|
+
- test/dummy/config/locales/en.yml
|
143
|
+
- test/dummy/config/routes.rb
|
144
|
+
- test/dummy/db/seeds.rb
|
145
|
+
- test/dummy/db/seeds/circular1.seeds.rb
|
146
|
+
- test/dummy/db/seeds/circular2.seeds.rb
|
147
|
+
- test/dummy/db/seeds/dependency.seeds.rb
|
148
|
+
- test/dummy/db/seeds/dependency2.seeds.rb
|
149
|
+
- test/dummy/db/seeds/dependent.seeds.rb
|
150
|
+
- test/dummy/db/seeds/dependent_on_nested.seeds.rb
|
151
|
+
- test/dummy/db/seeds/dependent_on_several.seeds.rb
|
152
|
+
- test/dummy/db/seeds/no_block.seeds.rb
|
153
|
+
- test/dummy/script/rails
|
154
|
+
- test/seedbank/runner_test.rb
|
155
|
+
- test/test_helper.rb
|