uuids 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5da4310e0513240c73c5f30d4d04fe9806271af8
4
- data.tar.gz: 4a0f7b2b9b9a141ad21e76b1d0f44cfc6fec9b41
3
+ metadata.gz: 5b59630d1254cf17915e3a7b7beb44845dd1812f
4
+ data.tar.gz: 9eb598e421669103dcbf1c227e71e0ce5a5b775a
5
5
  SHA512:
6
- metadata.gz: 7fa00c4678aee17d4d0ceef8da2ec8c2019e4363107ef1ba772f9ca89daa99fae98a1aaf49e887259a716994a68b55364abd05bc9be2a5f3b898bb6b04955756
7
- data.tar.gz: a2eb9c7475f5ccce7d5d1cb4ae45054ef3e9c9400585e28b10060135c1d8dfac8d39cd7e2f9ca526043aa64915c786493456b879ed76fe8515f69d6ca9f508be
6
+ metadata.gz: e8c87ee98ad9b849aa557e1da0b42fb1da5b699dfce7e3039bdc448c0b2fda9884865b233d79b37f79a008ce33b2b71540bbb276c8b352e0999d14c6588c8ed3
7
+ data.tar.gz: 5c94540825bcbf75fc55890c4ac28c1d5dfac97e41050de8e11a60796b4c4e82bf3b3431d7f1e93b7d7f6af7a713b7dd1ab4e420daf2fcb617c5e0f6b5a43f23
@@ -3,10 +3,6 @@ AllCops:
3
3
  - 'spec/dummy/**/*'
4
4
  - 'Rakefile'
5
5
 
6
- Lint/Eval:
7
- Exclude:
8
- - 'spec/**/*'
9
-
10
6
  Lint/HandleExceptions:
11
7
  Exclude:
12
8
  - 'spec/**/*'
@@ -33,7 +29,13 @@ Style/Documentation:
33
29
  - 'db/**/*'
34
30
  - 'lib/uuids/version.rb'
35
31
 
36
- Style/EmptyLinesAroundBody:
32
+ Style/EmptyLinesAroundClassBody:
33
+ Enabled: false
34
+
35
+ Style/EmptyLinesAroundMethodBody:
36
+ Enabled: false
37
+
38
+ Style/EmptyLinesAroundModuleBody:
37
39
  Enabled: false
38
40
 
39
41
  Style/EmptyLineBetweenDefs:
data/bin/uuids CHANGED
@@ -1,13 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- require_relative "../lib/generators"
2
+ require "active_record_install"
3
3
 
4
- # Runs the generator.
5
- #
6
- # @example
7
- # $ uuids install
8
- #
9
- # To see additional options call
10
- #
11
- # $ uuids install -h
12
- #
13
- Generators::Install.start
4
+ ActiveRecordInstall::Generator.start(
5
+ [File.expand_path("../..", __FILE__), "uuids"] + ARGV[1..-1]
6
+ )
@@ -8,7 +8,9 @@ module Uuids
8
8
  # Model scopes.
9
9
  module ClassMethods
10
10
 
11
- # Selects distinct records by uuids (relation scope).
11
+ # Selects records by uuid.
12
+ #
13
+ # by_uuid(*values)
12
14
  #
13
15
  # @example
14
16
  #
@@ -26,8 +28,7 @@ module Uuids
26
28
  # Params:
27
29
  # <tt>*values</tt>:: a list of uuids to select records by.
28
30
  #
29
- # Returns the <tt>ActiveRecord::Relation</tt> object.
30
- #
31
+ # Returns an <tt>ActiveRecord::Relation</tt> scope.
31
32
  def by_uuid(*values)
32
33
  first_value = values.first
33
34
  list = first_value.is_a?(Array) ? first_value : values
@@ -1,5 +1,5 @@
1
1
  module Uuids
2
2
 
3
3
  # Current release.
4
- VERSION = "1.4.1"
4
+ VERSION = "1.4.2"
5
5
  end
@@ -3,49 +3,41 @@ require "spec_helper_dev"
3
3
 
4
4
  describe "$ uuids", :sandbox do
5
5
 
6
- let(:files_in_sandbox) { Dir["#{ sandbox }/**/*.*"] }
7
-
8
6
  describe "install" do
9
7
 
10
- context "without options" do
8
+ let!(:root) { File.expand_path("../../..", __FILE__) }
9
+ let!(:migrations) { Dir["#{ root }/db/migrate/*.rb"] }
11
10
 
12
- let!(:dir) { "#{ sandbox }/db/migrate" }
13
- before { run_in_sandbox "uuids install" }
11
+ describe "without options" do
14
12
 
15
- it "copies migrations to 'db/migrate'" do
16
- migrations.each { |file| expect(dir).to have_migration_from file }
17
- end
13
+ before { run_in_sandbox "uuids install" }
18
14
 
19
- it "doesn't add other files" do
20
- expect(files_in_sandbox.count).to eq migrations.count
15
+ it "copies migrations to `db/migrate`" do
16
+ migrations.each do |migration|
17
+ expect(migration).to have_copy_in_sandbox "db/migrate"
18
+ end
21
19
  end
22
20
  end
23
21
 
24
- context "-d" do
25
-
26
- let!(:dir) { "#{ sandbox }/spec/dummy/db/migrate" }
27
- before { run_in_sandbox "uuids install -d" }
22
+ describe "-d" do
28
23
 
29
- it "copies migrations to 'spec/dummy/db/migrate'" do
30
- migrations.each { |file| expect(dir).to have_migration_from file }
31
- end
24
+ before { run_in_sandbox "uuids install -d" }
32
25
 
33
- it "doesn't add other files" do
34
- expect(files_in_sandbox.count).to eq migrations.count
26
+ it "copies migrations to `spec/dummy/db/migrate`" do
27
+ migrations.each do |migration|
28
+ expect(migration).to have_copy_in_sandbox "spec/dummy/db/migrate"
29
+ end
35
30
  end
36
31
  end
37
32
 
38
- context "-f folder" do
39
-
40
- let!(:dir) { "#{ sandbox }/folder/db/migrate" }
41
- before { run_in_sandbox "uuids install -f folder" }
33
+ describe "-f folder" do
42
34
 
43
- it "copies migrations to 'some_path/db/migrate'" do
44
- migrations.each { |file| expect(dir).to have_migration_from file }
45
- end
35
+ before { run_in_sandbox "uuids install -f folder" }
46
36
 
47
- it "doesn't add other files" do
48
- expect(files_in_sandbox.count).to eq migrations.count
37
+ it "copies migrations to `folder/db/migrate`" do
38
+ migrations.each do |migration|
39
+ expect(migration).to have_copy_in_sandbox "folder/db/migrate"
40
+ end
49
41
  end
50
42
  end
51
43
  end
Binary file
@@ -6,7 +6,7 @@ Coveralls.wear! "rails"
6
6
  require_relative "dummy/lib/dummy"
7
7
 
8
8
  # Loads support files for runtime tests.
9
- %w(runtime all).each do |env|
9
+ %w(all runtime).each do |env|
10
10
  support = File.expand_path "../support/#{ env }/**/*.rb", __FILE__
11
11
  Dir[support].each { |f| require f }
12
12
  end
@@ -6,7 +6,7 @@ require "coveralls"
6
6
  Coveralls.wear! "rails"
7
7
 
8
8
  # Loads generators.
9
- require_relative "../lib/generators"
9
+ require "active_record_install"
10
10
 
11
11
  # Loads support files for development tests.
12
12
  %w(development all).each do |env|
@@ -0,0 +1,15 @@
1
+ # Captures stdout I/O.
2
+ #
3
+ # @example
4
+ # capture_stdout { do_something }
5
+ #
6
+ def capture_stdout
7
+ begin
8
+ $stdout = StringIO.new
9
+ yield
10
+ result = $stdout.string
11
+ ensure
12
+ $stdout = STDOUT
13
+ end
14
+ result
15
+ end
@@ -1,4 +1,4 @@
1
- require_relative "capture"
1
+ require_relative "capture_stdout"
2
2
 
3
3
  # Path to the `tmp/sandbox`.
4
4
  def sandbox
@@ -18,7 +18,7 @@ end
18
18
 
19
19
  # Runs code from `sandbox`.
20
20
  def try_in_sandbox
21
- FileUtils.cd(sandbox) { capture(:stdout) { yield } }
21
+ FileUtils.cd(sandbox) { capture_stdout { yield } }
22
22
  end
23
23
 
24
24
  # Runs cli from `sandbox`.
@@ -1,14 +1,15 @@
1
- # Checks if a directory has a migration from given source file.
2
- RSpec::Matchers.define :have_migration_from do |source|
3
- match do |dir|
1
+ require_relative "../helpers/sandbox"
2
+
3
+ # Checks if a migration is properly copied to sandbox subfolder
4
+ RSpec::Matchers.define :have_copy_in_sandbox do |folder|
5
+ match do |source|
4
6
 
5
- # Search file that matches source with any timestamp.
6
7
  basename = File.basename(source, ".rb")[14..-1]
7
8
  sample = "*#{ basename }.uuids.rb"
8
- search = File.join(dir, sample)
9
+ search = File.join(sandbox, folder, sample)
9
10
  file = Dir[search].first
10
11
 
11
- # Check the file exists and has required content.
12
+ # Check whether file exists and has required content.
12
13
  expect(file).not_to be_nil
13
14
  expect(File.read file).to eq File.read source
14
15
  end
@@ -1,3 +1,5 @@
1
+ require_relative "../config/factory_girl"
2
+
1
3
  FactoryGirl.define do
2
4
  factory :record do
3
5
  end
@@ -1,3 +1,5 @@
1
+ require_relative "../config/factory_girl"
2
+
1
3
  FactoryGirl.define do
2
4
  factory :uuid, class: Uuids::Uuid do
3
5
  value { SecureRandom.uuid }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uuids
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kozin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-14 00:00:00.000000000 Z
11
+ date: 2014-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -25,33 +25,33 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.1'
27
27
  - !ruby/object:Gem::Dependency
28
- name: i18n
28
+ name: active_record_install
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.6'
34
- type: :runtime
33
+ version: '0.4'
34
+ type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.6'
40
+ version: '0.4'
41
41
  - !ruby/object:Gem::Dependency
42
- name: thor
42
+ name: coveralls
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.19'
47
+ version: '0.7'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.19'
54
+ version: '0.7'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: database_cleaner
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '4.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.3'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: inch
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -109,61 +123,61 @@ dependencies:
109
123
  - !ruby/object:Gem::Version
110
124
  version: '4.11'
111
125
  - !ruby/object:Gem::Dependency
112
- name: rspec
126
+ name: rake
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: '3.1'
131
+ version: '10.3'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: '3.1'
138
+ version: '10.3'
125
139
  - !ruby/object:Gem::Dependency
126
- name: rubocop
140
+ name: rspec
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: '0.26'
145
+ version: '3.1'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: '0.26'
152
+ version: '3.1'
139
153
  - !ruby/object:Gem::Dependency
140
- name: sqlite3
154
+ name: rubocop
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - "~>"
144
158
  - !ruby/object:Gem::Version
145
- version: '1.3'
159
+ version: '0.26'
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: '1.3'
166
+ version: '0.26'
153
167
  - !ruby/object:Gem::Dependency
154
- name: rake
168
+ name: sqlite3
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
171
  - - "~>"
158
172
  - !ruby/object:Gem::Version
159
- version: '10.3'
173
+ version: '1.3'
160
174
  type: :development
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
178
  - - "~>"
165
179
  - !ruby/object:Gem::Version
166
- version: '10.3'
180
+ version: '1.3'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: timecop
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -197,9 +211,6 @@ files:
197
211
  - config/locales/en.yml
198
212
  - config/locales/ru.yml
199
213
  - db/migrate/20141016112506_create_uuids_uuids.rb
200
- - lib/generators.rb
201
- - lib/generators/install.rb
202
- - lib/generators/install/copy_migration.rb
203
214
  - lib/uuids.rb
204
215
  - lib/uuids/base.rb
205
216
  - lib/uuids/base/has_uuids.rb
@@ -219,8 +230,6 @@ files:
219
230
  - spec/dummy/db/schema.rb
220
231
  - spec/dummy/db/test.sqlite3
221
232
  - spec/dummy/lib/dummy.rb
222
- - spec/lib/generators/install/copy_migration_spec.rb
223
- - spec/lib/generators/install_spec.rb
224
233
  - spec/lib/uuids/base_spec.rb
225
234
  - spec/spec_helper.rb
226
235
  - spec/spec_helper_dev.rb
@@ -230,7 +239,7 @@ files:
230
239
  - spec/support/all/config/rspec.rb
231
240
  - spec/support/development/config/sandbox.rb
232
241
  - spec/support/development/config/timecop.rb
233
- - spec/support/development/helpers/capture.rb
242
+ - spec/support/development/helpers/capture_stdout.rb
234
243
  - spec/support/development/helpers/migrations.rb
235
244
  - spec/support/development/helpers/sandbox.rb
236
245
  - spec/support/development/matchers/migrations.rb
@@ -281,15 +290,13 @@ test_files:
281
290
  - spec/dummy/lib/dummy.rb
282
291
  - spec/dummy/Rakefile
283
292
  - spec/app/models/uuids/uuid_spec.rb
284
- - spec/lib/generators/install/copy_migration_spec.rb
285
- - spec/lib/generators/install_spec.rb
286
293
  - spec/lib/uuids/base_spec.rb
287
294
  - spec/bin/uuids_spec.rb
288
295
  - spec/support/development/config/timecop.rb
289
296
  - spec/support/development/config/sandbox.rb
290
297
  - spec/support/development/matchers/sandbox.rb
291
298
  - spec/support/development/matchers/migrations.rb
292
- - spec/support/development/helpers/capture.rb
299
+ - spec/support/development/helpers/capture_stdout.rb
293
300
  - spec/support/development/helpers/sandbox.rb
294
301
  - spec/support/development/helpers/migrations.rb
295
302
  - spec/support/all/config/garbage_collection.rb
@@ -1,10 +0,0 @@
1
- # Generators dependencies.
2
- require "thor"
3
- require "pathname"
4
-
5
- # `uuids` generators code.
6
- Dir[File.expand_path("../generators/**/*.rb", __FILE__)].each { |f| require f }
7
-
8
- # Namespace for generators.
9
- module Generators
10
- end
@@ -1,92 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Generators
4
-
5
- # An installer for the `uuids` gem.
6
- # Copies module migration into an external project.
7
- #
8
- # @example
9
- # installer = Generators::Install.start [], { dummy: true }
10
- # # => creates `spec/dummy/db/migrage/{timestamp}_uuids_uuids.uuids.rb
11
- #
12
- # Options:
13
- # <tt>dummy:</tt> (optional, boolean, default: false)
14
- # ... flag to copy migrations to a dummy app. If not set, the migration
15
- # will be added to the root `db/migrate` folder.
16
- #
17
- # Adds the "uuids" gem's migration to a module that uses the gem.
18
- #
19
- class Install < Thor::Group
20
- include Thor::Actions
21
-
22
- # Root for db migrations to be copied.
23
- source_root File.expand_path "../../../db/migrate", __FILE__
24
- namespace :install
25
-
26
- class_option(
27
- :dummy,
28
- aliases: "-d",
29
- default: false,
30
- desc: "Copy migrations to dummy (`spec/dummy/db/migrate`) folder.",
31
- required: false,
32
- type: :boolean
33
- )
34
-
35
- class_option(
36
- :folder,
37
- aliases: "-f",
38
- desc: "A folder to copy migrations to (`given_folder/db/migrate`).",
39
- required: false,
40
- type: :string
41
- )
42
-
43
- # Creates a folder for migrations.
44
- def prepare_folder
45
- empty_directory dir, skip: true
46
- end
47
-
48
- # Copies migrations to proper folder
49
- def copy_migrations
50
- copies.each do |copy|
51
- copy_file copy.source, copy.target, copy.content unless copy.created?
52
- end
53
- end
54
-
55
- private
56
-
57
- def source_root
58
- File.expand_path "../../../db/migrate", __FILE__
59
- end
60
-
61
- def dir
62
- @dir ||= "#{ folder || dummy || "" }db/migrate/"
63
- end
64
-
65
- def folder
66
- @folder ||= begin
67
- folder = options["folder"]
68
- folder ? "#{ folder }/" : nil
69
- end
70
- end
71
-
72
- def dummy
73
- @dummy ||= "spec/dummy/" if options["dummy"]
74
- end
75
-
76
- def sources
77
- @sources ||= Dir[File.expand_path("*.rb", source_root)]
78
- end
79
-
80
- def copies
81
- @copies ||= sources.map do |file|
82
- CopyMigration.new(
83
- gemname: "uuids",
84
- source_root: source_root,
85
- source_file: file,
86
- target_root: destination_root,
87
- target_dir: dir
88
- )
89
- end
90
- end
91
- end
92
- end
@@ -1,104 +0,0 @@
1
- # encoding: utf-8
2
- require_relative "../install"
3
-
4
- module Generators
5
- class Install
6
-
7
- # Description for migration to copy.
8
- #
9
- # @example
10
- #
11
- # copy = CopyMigration.new(
12
- # gemname: "uuids",
13
- # source_root: "/",
14
- # source_file: "/db/migrate/20141016112506_create_uuids_uuids.rb",
15
- # target_root: "/items",
16
- # target_dir: "db/migrate"
17
- # )
18
- #
19
- # copy.source
20
- # # => "/db/migrate/20141016112506_create_uuids_uuids.rb"
21
- # copy.target
22
- # # => "/db/migrate/20150101000001_create_uuids_uuids.uuids.rb"
23
- # copy.content
24
- # # => returns uuids content.
25
- # copy.created?
26
- # # => returns true after the first copy created with any timestamp.
27
- #
28
- class CopyMigration
29
-
30
- # Initialized parameters.
31
- attr_reader(
32
- :gemname, :source_root, :source_file, :target_root, :target_dir
33
- )
34
-
35
- # Instance initializer.
36
- #
37
- # @example
38
- # CopyMigration.new(params)
39
- #
40
- # Params:
41
- # <tt>:gemname</tt>:: the name of the gem.
42
- # <tt>:source_root</tt>:: the uuids db/migrate folder path.
43
- # <tt>:source_file</tt>:: full path to migration file.
44
- # <tt>:target_root</tt>:: path to root of application to create copy.
45
- # <tt>:target_dir</tt>:: a folder in application root for migrations.
46
- #
47
- # All params are required.
48
- #
49
- def initialize(params)
50
- @gemname = params[:gemname]
51
- @source_root = params[:source_root]
52
- @source_file = params[:source_file]
53
- @target_root = params[:target_root]
54
- @target_dir = params[:target_dir]
55
- end
56
-
57
- # Returns a source path to the migration.
58
- def source
59
- filepath.relative_path_from(rootpath).to_s
60
- end
61
-
62
- # Returns a target file name to copy the migration to.
63
- def target
64
- File.join(target_dir, "#{ timestamp }#{ suffix }")
65
- end
66
-
67
- # Returns the migration content.
68
- def content
69
- File.read filepath
70
- end
71
-
72
- # Checks if a copy already created.
73
- def created?
74
- search != []
75
- end
76
-
77
- private
78
-
79
- def filepath
80
- @filepath ||= Pathname.new(source_file)
81
- end
82
-
83
- def suffix
84
- @suffix ||= "#{ basename }.#{ gemname }.rb"
85
- end
86
-
87
- def search
88
- Dir[File.join(target_root, target_dir, "*#{ suffix }")]
89
- end
90
-
91
- def rootpath
92
- Pathname.new(source_root)
93
- end
94
-
95
- def timestamp
96
- @timestamp ||= Time.now.utc.strftime "%Y%m%d%H%M%S"
97
- end
98
-
99
- def basename
100
- File.basename(source_file, ".rb")[14..-1]
101
- end
102
- end
103
- end
104
- end
@@ -1,66 +0,0 @@
1
- # encoding: utf-8
2
- require "spec_helper_dev"
3
-
4
- module Generators
5
- class Install
6
- describe CopyMigration, :sandbox do
7
-
8
- let(:filename) { "20140101010101_create_items_items" }
9
- let(:filepath) { "#{ sandbox }/#{ filename }.rb" }
10
- let(:content) { "some content" }
11
- let(:params) do
12
- {
13
- gemname: "uuids",
14
- source_root: sandbox,
15
- source_file: filepath,
16
- target_root: sandbox,
17
- target_dir: "db/migrate"
18
- }
19
- end
20
-
21
- before { File.write filepath, content }
22
- subject { CopyMigration.new params }
23
-
24
- describe "#source" do
25
-
26
- it "returns migrations source" do
27
- expect(subject.source).to eq("#{ filename }.rb")
28
- end
29
- end
30
-
31
- describe "#target" do
32
-
33
- let(:regexp) do
34
- Regexp.new "db/migrate/\\d{14}_create_items_items[.]uuids[.]rb"
35
- end
36
-
37
- it "returns the name of migration target" do
38
- expect(subject.target).to match(regexp)
39
- end
40
- end
41
-
42
- describe "#content" do
43
-
44
- it "returns the migration content" do
45
- expect(subject.content).to eq(content)
46
- end
47
- end
48
-
49
- describe "#created?" do
50
-
51
- let(:folder) { File.join sandbox, "db", "migrate" }
52
- let(:copy) { File.join(folder, "#{ filename }.uuids.rb") }
53
-
54
- it "returns false before migration copy created" do
55
- expect(subject).not_to be_created
56
- end
57
-
58
- it "returns true after migration copy created" do
59
- FileUtils.mkdir_p folder
60
- File.write copy, content
61
- expect(subject).to be_created
62
- end
63
- end
64
- end
65
- end
66
- end
@@ -1,73 +0,0 @@
1
- # encoding: utf-8
2
- require "spec_helper_dev"
3
-
4
- module Generators
5
- describe Install, :sandbox do
6
-
7
- describe "#invoke_all" do
8
-
9
- def run_with_options(options = {})
10
- try_in_sandbox do
11
- subject = Install.new [], options
12
- subject.invoke_all
13
- end
14
- end
15
-
16
- let(:files_in_sandbox) { Dir["#{ sandbox }/**/*.*"] }
17
-
18
- context "without options" do
19
-
20
- let!(:dir) { "#{ sandbox }/db/migrate" }
21
- before { run_with_options }
22
-
23
- it "copies migrations to 'db/migrate'" do
24
- migrations.each { |file| expect(dir).to have_migration_from file }
25
- end
26
-
27
- it "doesn't add other files" do
28
- expect(files_in_sandbox.count).to eq migrations.count
29
- end
30
- end
31
-
32
- context "dummy: true" do
33
-
34
- let!(:dir) { "#{ sandbox }/spec/dummy/db/migrate" }
35
- before { run_with_options dummy: true }
36
-
37
- it "copies migrations to 'spec/dummy/db/migrate'" do
38
- migrations.each { |file| expect(dir).to have_migration_from file }
39
- end
40
-
41
- it "doesn't add other files" do
42
- expect(files_in_sandbox.count).to eq migrations.count
43
- end
44
- end
45
-
46
- context "folder: 'folder'" do
47
-
48
- let!(:dir) { "#{ sandbox }/folder/db/migrate" }
49
- before { run_with_options folder: "folder" }
50
-
51
- it "copies migrations to 'some_path/db/migrate'" do
52
- migrations.each { |file| expect(dir).to have_migration_from file }
53
- end
54
-
55
- it "doesn't add other files" do
56
- expect(files_in_sandbox.count).to eq migrations.count
57
- end
58
- end
59
-
60
- context "if a migration is already added" do
61
-
62
- before do
63
- run_with_options
64
- Timecop.travel(Time.now + 10) { run_with_options }
65
- end
66
-
67
- it "doesn't copy it again" do
68
- expect(files_in_sandbox.count).to eq migrations.count
69
- end
70
- end
71
- end
72
- end
73
- end
@@ -1,16 +0,0 @@
1
- # Captures given stream.
2
- #
3
- # @example
4
- # capture(:stdout) { do_something }
5
- #
6
- def capture(stream)
7
- begin
8
- stream = stream.to_s
9
- eval "$#{stream} = StringIO.new"
10
- yield
11
- result = eval("$#{stream}").string
12
- ensure
13
- eval("$#{stream} = #{stream.upcase}")
14
- end
15
- result
16
- end