seedbank 0.4.0 → 0.5.0

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.hound.yml +3 -0
  4. data/.rubocop.yml +18 -0
  5. data/.rubocop_todo.yml +29 -0
  6. data/.travis.yml +10 -9
  7. data/Gemfile +5 -4
  8. data/README.md +50 -25
  9. data/Rakefile +2 -1
  10. data/TODO.txt +3 -3
  11. data/gemfiles/rake10.gemfile +1 -4
  12. data/gemfiles/rake11.gemfile +12 -0
  13. data/gemfiles/{rake0.9.gemfile → rake12.gemfile} +3 -4
  14. data/lib/seedbank/dsl.rb +65 -43
  15. data/lib/seedbank/railtie.rb +2 -7
  16. data/lib/seedbank/runner.rb +19 -32
  17. data/lib/seedbank/version.rb +2 -1
  18. data/lib/seedbank.rb +15 -6
  19. data/lib/tasks/seed.rake +16 -20
  20. data/seedbank.gemspec +35 -58
  21. data/test/dummy/Rakefile +1 -0
  22. data/test/dummy/app/controllers/application_controller.rb +1 -0
  23. data/test/dummy/config/application.rb +2 -22
  24. data/test/dummy/config/boot.rb +2 -1
  25. data/test/dummy/config/environment.rb +1 -0
  26. data/test/dummy/config/environments/development.rb +3 -7
  27. data/test/dummy/config/environments/test.rb +4 -9
  28. data/test/dummy/config/initializers/secret_token.rb +1 -0
  29. data/test/dummy/config/initializers/session_store.rb +2 -1
  30. data/test/dummy/config/initializers/wrap_parameters.rb +2 -1
  31. data/test/dummy/config/routes.rb +1 -0
  32. data/test/dummy/config.ru +2 -1
  33. data/test/dummy/db/seeds/circular1.seeds.rb +2 -1
  34. data/test/dummy/db/seeds/circular2.seeds.rb +2 -1
  35. data/test/dummy/db/seeds/dependency.seeds.rb +1 -0
  36. data/test/dummy/db/seeds/dependency2.seeds.rb +1 -0
  37. data/test/dummy/db/seeds/dependent.seeds.rb +2 -1
  38. data/test/dummy/db/seeds/dependent_on_nested.seeds.rb +2 -1
  39. data/test/dummy/db/seeds/dependent_on_several.seeds.rb +2 -1
  40. data/test/dummy/db/seeds/development/users.seeds.rb +1 -0
  41. data/test/dummy/db/seeds/no_block.seeds.rb +2 -1
  42. data/test/dummy/db/seeds/reference_memos.seeds.rb +2 -1
  43. data/test/dummy/db/seeds/with_block_memo.seeds.rb +2 -1
  44. data/test/dummy/db/seeds/with_inline_memo.seeds.rb +1 -0
  45. data/test/dummy/db/seeds.rb +1 -0
  46. data/test/dummy/script/rails +3 -2
  47. data/test/lib/seedbank/dsl_test.rb +58 -75
  48. data/test/lib/seedbank/runner_test.rb +39 -46
  49. data/test/lib/tasks/seed_rake_test.rb +85 -48
  50. data/test/test_helper.rb +13 -11
  51. metadata +50 -24
  52. data/test/dummy/lib/tasks/dsl.rake +0 -4
data/seedbank.gemspec CHANGED
@@ -1,59 +1,36 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "seedbank/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = %q{seedbank}
7
- s.version = Seedbank::VERSION
8
- s.date = `git log -1 --format="%cd" --date=short lib/seedbank/version.rb`
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">=1.2.0") if s.respond_to?(:required_rubygems_version=)
11
- s.rubygems_version = %q{1.3.5}
12
- s.license = "MIT"
13
-
14
- s.authors = ["James McCarthy"]
15
- s.email = %q{james2mccarthy@gmail.com}
16
- s.homepage = %q{http://github.com/james2m/seedbank}
17
- s.summary = %q{
18
- Extends Rails seeds to split out complex seeds into their own file
19
- and have different seeds for each environment.
20
- }
21
- s.description = %q{
22
- Extends Rails seeds to split out complex seeds into multiple
23
- files and lets each environment have it's own seeds.
24
- }
25
- s.license = "MIT"
26
-
27
- s.files = `git ls-files`.split("\n")
28
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
29
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
30
- s.require_paths = ["lib"]
31
-
32
- s.rdoc_options = ["--charset=UTF-8"]
33
- s.extra_rdoc_files = [
34
- "MIT-LICENSE",
35
- "README.md"
36
- ]
37
-
38
- s.add_development_dependency "minitest", "~> 5.0"
39
- s.add_development_dependency "rails", "~> 3.2"
40
-
41
- s.post_install_message = %q{
42
- ================================================================================
43
-
44
- Rails 2.x
45
- ---------
46
- If you are using Seedbank with Rails 2.x you will need to place the following at
47
- the end of your Rakefile so Rubygems can load the seedbank tasks;
48
-
49
- require 'seedbank'
50
- Seedbank.load_tasks if defined?(Seedbank)
51
-
52
- Rails 3.x and 4.x
53
- ---------
54
- Your work here is done!
55
-
56
- ================================================================================
57
- }
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'seedbank/version'
6
+ require 'English'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = 'seedbank'
10
+ spec.version = Seedbank::VERSION
11
+ spec.authors = ['James McCarthy']
12
+ spec.email = ['[james2mccarthy@gmail.com']
13
+ spec.required_ruby_version = '>= 2.1'
14
+ spec.summary = 'Generate seeds data for your Ruby application.'
15
+ spec.description = %(
16
+ Adds simple rake commands for seeding your database. Simple dependencies let you organise your seeds.
17
+ If you are using Rails, Seedbank extends Rails seeds and lets you add seeds for each environment.
18
+ )
19
+ spec.date = `git log -1 --format="%cd" --date=short lib/seedbank/version.rb`
20
+ spec.homepage = 'http://github.com/james2m/seedbank'
21
+ spec.license = 'MIT'
22
+
23
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
24
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
26
+ spec.require_paths = ['lib']
27
+
28
+ spec.rdoc_options = ['--charset=UTF-8']
29
+ spec.extra_rdoc_files = ['MIT-LICENSE', 'README.md']
30
+
31
+ spec.add_dependency 'rake', '>= 10.0'
32
+
33
+ spec.add_development_dependency 'bundler', '~> 1.11'
34
+ spec.add_development_dependency 'rails', '~> 4.2'
35
+ spec.add_development_dependency 'minitest', '~> 5.0'
58
36
  end
59
-
data/test/dummy/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env rake
2
+ # frozen_string_literal: true
2
3
  # Add your own tasks in files placed in lib/tasks ending in .rake,
3
4
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
5
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class ApplicationController < ActionController::Base
2
3
  protect_from_forgery
3
4
  end
@@ -1,29 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  require File.expand_path('../boot', __FILE__)
2
3
 
3
- # Pick the frameworks you want:
4
- require "active_record/railtie"
5
-
6
- Bundler.require if defined?(Bundler)
7
- require 'seedbank'
4
+ Bundler.require(:default, Rails.env)
8
5
 
9
6
  module Dummy
10
7
  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
8
  end
28
9
  end
29
-
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rubygems'
2
3
  gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
4
 
@@ -7,4 +8,4 @@ if File.exist?(gemfile)
7
8
  Bundler.setup
8
9
  end
9
10
 
10
- $:.unshift File.expand_path('../../../../lib', __FILE__)
11
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Load the rails application
2
3
  require File.expand_path('../application', __FILE__)
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  Dummy::Application.configure do
2
3
  # Settings specified here will take precedence over those in config/application.rb
3
4
 
@@ -5,12 +6,13 @@ Dummy::Application.configure do
5
6
  # every request. This slows down response time but is perfect for development
6
7
  # since you don't have to restart the web server when you make code changes.
7
8
  config.cache_classes = false
9
+ config.eager_load = false
8
10
 
9
11
  # Log error messages when you accidentally call methods on nil.
10
12
  config.whiny_nils = true
11
13
 
12
14
  # Show full error reports and disable caching
13
- config.consider_all_requests_local = true
15
+ config.consider_all_requests_local = true
14
16
  config.action_controller.perform_caching = false
15
17
 
16
18
  # Print deprecation notices to the Rails logger
@@ -19,16 +21,10 @@ Dummy::Application.configure do
19
21
  # Only use best-standards-support built into browsers
20
22
  config.action_dispatch.best_standards_support = :builtin
21
23
 
22
- # Raise exception on mass assignment protection for Active Record models
23
- config.active_record.mass_assignment_sanitizer = :strict
24
-
25
24
  # Log the query plan for queries taking more than this (works
26
25
  # with SQLite, MySQL, and PostgreSQL)
27
26
  config.active_record.auto_explain_threshold_in_seconds = 0.5
28
27
 
29
28
  # Do not compress assets
30
29
  config.assets.compress = false
31
-
32
- # Expands the lines which load the assets
33
- config.assets.debug = true
34
30
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  Dummy::Application.configure do
2
3
  # Settings specified here will take precedence over those in config/application.rb
3
4
 
@@ -6,26 +7,20 @@ Dummy::Application.configure do
6
7
  # your test database is "scratch space" for the test suite and is wiped
7
8
  # and recreated between test runs. Don't rely on the data there!
8
9
  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"
10
+ config.eager_load = false
13
11
 
14
12
  # Log error messages when you accidentally call methods on nil
15
13
  config.whiny_nils = true
16
14
 
17
15
  # Show full error reports and disable caching
18
- config.consider_all_requests_local = true
16
+ config.consider_all_requests_local = true
19
17
  config.action_controller.perform_caching = false
20
18
 
21
19
  # Raise exceptions instead of rendering exception templates
22
20
  config.action_dispatch.show_exceptions = false
23
21
 
24
22
  # 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
23
+ config.action_controller.allow_forgery_protection = false
29
24
 
30
25
  # Print deprecation notices to the stderr
31
26
  config.active_support.deprecation = :stderr
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Your secret key for verifying the integrity of signed cookies.
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
- Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
4
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
5
 
5
6
  # Use the database for sessions instead of the cookie-based default,
6
7
  # which shouldn't be used to store highly confidential information
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
  #
3
4
  # This file contains settings for ActionController::ParamsWrapper which
@@ -5,7 +6,7 @@
5
6
 
6
7
  # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
8
  ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters :format => [:json]
9
+ wrap_parameters format: [:json]
9
10
  end
10
11
 
11
12
  # Disable root element in JSON by default.
@@ -1,2 +1,3 @@
1
+ # frozen_string_literal: true
1
2
  Dummy::Application.routes.draw do
2
3
  end
data/test/dummy/config.ru CHANGED
@@ -1,4 +1,5 @@
1
+ # frozen_string_literal: true
1
2
  # This file is used by Rack-based servers to start the application.
2
3
 
3
- require ::File.expand_path('../config/environment', __FILE__)
4
+ require ::File.expand_path('../config/environment', __FILE__)
4
5
  run Dummy::Application
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  after :circular2 do
2
3
  FakeModel.seed('circular1')
3
- end
4
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  after :circular1 do
2
3
  FakeModel.seed('circular2')
3
- end
4
+ end
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  FakeModel.seed('dependency')
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  FakeModel.seed('dependency2')
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  after :dependency do
2
3
  FakeModel.seed('dependent')
3
- end
4
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  after :dependent, :dependency2 do
2
3
  FakeModel.seed('dependent on nested')
3
- end
4
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  after :dependency, :dependency2 do
2
3
  FakeModel.seed('dependent on several')
3
- end
4
+ end
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  FakeModel.seed('development:users')
@@ -1 +1,2 @@
1
- after :dependency
1
+ # frozen_string_literal: true
2
+ after :dependency
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  after('with_block_memo') do
2
3
  block_let
3
4
  inline_let
4
5
  inline_method
5
- end
6
+ end
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  after('with_inline_memo') do
2
3
  FakeModel.seed 'with_block_memo'
3
4
  let(:block_let) { FakeModel.calling_let 'BLOCK_LET' }
4
5
  let!(:block_let!) { FakeModel.calling_let! 'BLOCK_LET!' }
5
- end
6
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  def inline_method
2
3
  FakeModel.calling_method 'inline_method'
3
4
  end
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  FakeModel.seed('db/seeds.rb')
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
  # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
4
 
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
5
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
6
+ require File.expand_path('../../config/boot', __FILE__)
6
7
  require 'rails/commands'
@@ -1,135 +1,119 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
- describe Seedbank::DSL do
4
-
5
- describe "scope_from_seed_file" do
6
-
7
- it "is added to the namesapce" do
8
- ns = Rake.application.in_namespace(:seedy) { self }
9
-
10
- ns.must_respond_to :scope_from_seed_file
11
- end
4
+ using Seedbank::DSL
12
5
 
13
- describe "in an environment directory" do
6
+ describe Seedbank::DSL do
7
+ # TODO: This is private so should really be tested indirectly.
8
+ describe 'scope_from_seed_file' do
9
+ subject { scope_from_seed_file(seed_file) }
14
10
 
11
+ describe 'in an environment directory' do
15
12
  let(:seed_file) { File.expand_path('development/users.seeds.rb', Seedbank.seeds_root) }
16
- let(:seed_namespace) { %w(development) }
13
+ let(:seed_namespace) { %w[development] }
17
14
 
18
- subject { Seedbank::DSL.scope_from_seed_file seed_file }
19
-
20
- it "returns the enviroment scope" do
15
+ it 'returns the enviroment scope' do
21
16
  subject.must_equal seed_namespace
22
17
  end
23
18
  end
24
19
 
25
- describe "in a nested directory" do
26
-
20
+ describe 'in a nested directory' do
27
21
  let(:seed_file) { File.expand_path('development/shared/accounts.seeds.rb', Seedbank.seeds_root) }
28
- let(:seed_namespace) { %w(development shared) }
22
+ let(:seed_namespace) { %w[development shared] }
29
23
 
30
- subject { Seedbank::DSL.scope_from_seed_file seed_file }
31
-
32
- it "returns the nested scope" do
24
+ it 'returns the nested scope' do
33
25
  subject.must_equal seed_namespace
34
26
  end
35
27
  end
36
28
 
37
- describe "in seeds root" do
38
-
29
+ describe 'in seeds root' do
39
30
  let(:seed_file) { File.expand_path('no_block.seeds.rb', Seedbank.seeds_root) }
40
31
 
41
- subject { Seedbank::DSL.scope_from_seed_file seed_file }
42
-
43
- it "returns an array" do
32
+ it 'returns an array' do
44
33
  subject.must_be_instance_of Array
45
34
  end
46
35
 
47
- it "must be empty" do
36
+ it 'must be empty' do
48
37
  subject.must_be_empty
49
38
  end
50
39
  end
51
40
  end
52
41
 
53
- describe "seeds_root" do
54
-
42
+ describe 'seeds_root' do
55
43
  let(:seeds_root) { '/my/seeds/directory' }
56
44
 
57
- subject { Seedbank::DSL.send(:seeds_root) }
45
+ subject { Seedbank::DSL.seeds_root }
58
46
 
59
- it "returns a Pathname" do
47
+ it 'returns a Pathname' do
60
48
  Seedbank.stub(:seeds_root, seeds_root) do
61
-
62
49
  subject.must_equal Pathname.new(seeds_root)
63
-
64
50
  end
65
51
  end
66
-
67
52
  end
68
53
 
69
- describe "glob_seed_files_matching" do
70
-
71
- describe "with no namespace" do
72
-
54
+ describe 'glob_seed_files_matching' do
55
+ describe 'with no namespace' do
73
56
  let(:pattern) { '*.seeds.rb' }
74
57
 
75
- it "returns all the files matching the pattern in seeds_root" do
58
+ it 'returns all the files matching the pattern in seeds_root' do
76
59
  expected_files = Dir.glob(File.join(Seedbank.seeds_root, pattern))
77
60
 
78
61
  Seedbank::DSL.glob_seed_files_matching(pattern).must_equal expected_files
79
62
  end
80
-
81
63
  end
82
64
 
83
- describe "with a namespace" do
84
-
65
+ describe 'with a namespace' do
85
66
  let(:pattern) { '*.seeds.rb' }
86
67
  let(:namespace) { 'development' }
87
68
 
88
- it "returns all the files matching the pattern in seeds_root" do
69
+ it 'returns all the files matching the pattern in seeds_root' do
89
70
  expected_files = Dir.glob(File.join(Seedbank.seeds_root, namespace, pattern))
90
71
 
91
72
  Seedbank::DSL.glob_seed_files_matching(namespace, pattern).must_equal expected_files
92
73
  end
93
-
94
74
  end
95
-
96
75
  end
97
76
 
98
- describe "define_seed_task" do
77
+ describe 'define_seed_task' do
78
+ subject { Seedbank::DSL.define_seed_task(seed_file, task_name => dependencies) }
99
79
 
100
80
  let(:task_name) { 'scoped:my_seed' }
101
- let(:dependencies) { ['environment'] }
81
+ let(:dependencies) { ['scoped:another_seed'] }
102
82
  let(:seed_file) { File.expand_path('development/users.seeds.rb', Seedbank.seeds_root) }
103
83
 
104
- it "returns a fully qualified task name" do
105
- returned_name = Seedbank::DSL.define_seed_task(seed_file, task_name => dependencies)
84
+ def define_prerequisite_task
85
+ Rake::Task.define_task('scoped:another_seed')
86
+ end
106
87
 
107
- returned_name.must_equal task_name
88
+ before do
89
+ define_prerequisite_task
108
90
  end
109
91
 
110
- it "creates a Rake Task" do
111
- Seedbank::DSL.define_seed_task(seed_file, task_name => dependencies)
92
+ it 'returns a fully qualified task name' do
93
+ subject.must_equal task_name
94
+ end
112
95
 
96
+ it 'creates a Rake Task' do
97
+ subject
113
98
  Rake::Task[task_name].wont_be_nil
114
99
  end
115
100
 
116
- it "sets Rake Task description" do
117
- Seedbank::DSL.define_seed_task(seed_file, task_name => dependencies)
101
+ it 'sets Rake Task description' do
102
+ subject
103
+ relative_file = Pathname.new(seed_file).relative_path_from(Rails.root)
118
104
 
119
- Rake::Task[task_name].comment.must_equal "Load the seed data from #{seed_file}"
105
+ Rake::Task[task_name].comment.must_equal "Load the seed data from #{relative_file}"
120
106
  end
121
107
 
122
- it "sets Rake Task action to the seed_file contents" do
123
- Seedbank::DSL.define_seed_task(seed_file, task_name => dependencies)
124
-
108
+ it 'sets Rake Task action to the seed_file contents' do
109
+ subject
125
110
  FakeModel.expect :seed, true, ['development:users']
126
-
127
111
  Rake::Task[task_name].invoke
128
112
  end
129
113
 
130
- describe "when db:abort_if_pending_migrations exists" do
131
- it "sets Rake Task dependencies" do
132
- Seedbank::DSL.define_seed_task(seed_file, task_name => dependencies)
114
+ describe 'when db:abort_if_pending_migrations exists' do
115
+ it 'sets Rake Task dependencies' do
116
+ subject
133
117
  expected_dependencies = dependencies.map { |dependency| Rake::Task[dependency] }
134
118
  expected_dependencies << Rake::Task['db:abort_if_pending_migrations']
135
119
 
@@ -137,39 +121,39 @@ describe Seedbank::DSL do
137
121
  end
138
122
  end
139
123
 
140
- describe "when db:abort_if_pending_migrations does not exist" do
141
- it "sets Rake Task dependencies" do
124
+ describe 'when db:abort_if_pending_migrations does not exist' do
125
+ it 'adds environment dependency' do
142
126
  Rake.application.clear
143
- Rake::Task.define_task 'environment'
127
+ define_prerequisite_task
144
128
 
145
- Seedbank::DSL.define_seed_task(seed_file, task_name => dependencies)
129
+ expected_dependencies = dependencies.map { |dependency| Rake::Task[dependency] }
130
+ expected_dependencies << Rake::Task.define_task('environment')
131
+ subject
146
132
 
147
- Rake::Task[task_name].prerequisite_tasks.must_equal dependencies.map { |dependency| Rake::Task[dependency] }
133
+ Rake::Task[task_name].prerequisite_tasks.must_equal expected_dependencies
148
134
  end
149
135
  end
150
136
  end
151
137
 
152
- describe "override_seed_task" do
153
-
154
- describe "when no task exists to override" do
155
-
138
+ describe 'override_seed_task' do
139
+ describe 'when no task exists to override' do
156
140
  let(:task_name) { 'my_task' }
157
- let(:dependencies) { ['seedy:users'] }
141
+ let(:dependencies) { ['db:abort_if_pending_migrations'] }
158
142
 
159
- it "creates a new task" do
143
+ it 'creates a new task' do
160
144
  Seedbank::DSL.override_seed_task(task_name => dependencies)
161
145
 
162
146
  Rake::Task[task_name].wont_be_nil
163
147
  end
164
148
 
165
- it "applies the dependencies" do
149
+ it 'applies the dependencies' do
166
150
  expected_dependencies = dependencies.map { |dependency| Rake::Task[dependency] }
167
151
  Seedbank::DSL.override_seed_task(task_name => dependencies)
168
152
 
169
153
  Rake::Task[task_name].prerequisite_tasks.must_equal expected_dependencies
170
154
  end
171
155
 
172
- it "applies the description" do
156
+ it 'applies the description' do
173
157
  description = 'Expected Description'
174
158
  Rake.application.last_description = description
175
159
 
@@ -178,6 +162,5 @@ describe Seedbank::DSL do
178
162
  Rake::Task[task_name].full_comment.must_equal description
179
163
  end
180
164
  end
181
-
182
165
  end
183
166
  end