generator_spec 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +2 -9
- data/Gemfile +1 -1
- data/lib/generator_spec/matcher.rb +27 -10
- data/lib/generator_spec/version.rb +1 -1
- data/spec/generator_spec/matcher_spec.rb +3 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 259e672a9eabc7d6c46c0679efa9a0fce1f4b39fa6ba9bdf7a3698343710ff62
|
4
|
+
data.tar.gz: 926d8dcf4a13a5319c430b94efa7bcc57ec0ce041aeb141e6fc26949a2ac9ae8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 697ffb8f6a9a6ad285a222024db30f542d055821fb755d0ebb047e7a408b4724e902b33fc7b15a3a9f910ccdd7dea3f357895ee57c2c5ae86c216b55aab47a69
|
7
|
+
data.tar.gz: 8c698a7a3c0c94e82262cd3eb1f058f2343100d9c214ef81e22d089c1fe27335c31c15009328efdc27191fce2dd17218a5f1d8a113bf40d626a0c97c4fe2da50
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -2,8 +2,13 @@ module GeneratorSpec
|
|
2
2
|
module Matcher
|
3
3
|
# Taken (with permission) from beard by Yahuda Katz
|
4
4
|
# https://github.com/carlhuda/beard
|
5
|
-
|
5
|
+
|
6
6
|
class File
|
7
|
+
|
8
|
+
def description
|
9
|
+
'file attributes and content'
|
10
|
+
end
|
11
|
+
|
7
12
|
def initialize(name, &block)
|
8
13
|
@contents = []
|
9
14
|
@name = name
|
@@ -24,9 +29,9 @@ module GeneratorSpec
|
|
24
29
|
|
25
30
|
check_contents(root.join(@name))
|
26
31
|
end
|
27
|
-
|
32
|
+
|
28
33
|
protected
|
29
|
-
|
34
|
+
|
30
35
|
def check_contents(file)
|
31
36
|
contents = ::File.read(file)
|
32
37
|
|
@@ -37,20 +42,24 @@ module GeneratorSpec
|
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
40
|
-
|
45
|
+
|
41
46
|
class Migration < File
|
47
|
+
def description
|
48
|
+
'valid migration file'
|
49
|
+
end
|
50
|
+
|
42
51
|
def matches?(root)
|
43
52
|
file_name = migration_file_name(root, @name)
|
44
|
-
|
53
|
+
|
45
54
|
unless file_name && file_name.exist?
|
46
55
|
throw :failure, @name
|
47
56
|
end
|
48
|
-
|
57
|
+
|
49
58
|
check_contents(file_name)
|
50
59
|
end
|
51
|
-
|
60
|
+
|
52
61
|
protected
|
53
|
-
|
62
|
+
|
54
63
|
def migration_file_name(root, name) #:nodoc:
|
55
64
|
directory, file_name = ::File.dirname(root.join(name)), ::File.basename(name).sub(/\.rb$/, '')
|
56
65
|
migration = Dir.glob("#{directory}/[0-9]*_*.rb").grep(/\d+_#{file_name}.rb$/).first
|
@@ -61,6 +70,10 @@ module GeneratorSpec
|
|
61
70
|
class Directory
|
62
71
|
attr_reader :tree
|
63
72
|
|
73
|
+
def description
|
74
|
+
'has directory structure'
|
75
|
+
end
|
76
|
+
|
64
77
|
def initialize(root = nil, &block)
|
65
78
|
@tree = {}
|
66
79
|
@negative_tree = []
|
@@ -83,7 +96,7 @@ module GeneratorSpec
|
|
83
96
|
def location(name)
|
84
97
|
[@root, name].compact.join("/")
|
85
98
|
end
|
86
|
-
|
99
|
+
|
87
100
|
def migration(name, &block)
|
88
101
|
@tree[name] = Migration.new(location(name), &block)
|
89
102
|
end
|
@@ -110,6 +123,10 @@ module GeneratorSpec
|
|
110
123
|
end
|
111
124
|
|
112
125
|
class Root < Directory
|
126
|
+
def description
|
127
|
+
'have specified directory structure'
|
128
|
+
end
|
129
|
+
|
113
130
|
def failure_message
|
114
131
|
if @failure.is_a?(Array) && @failure[0] == :not
|
115
132
|
"Structure should not have had #{@failure[1]}, but it did"
|
@@ -136,4 +153,4 @@ module GeneratorSpec
|
|
136
153
|
Root.new(&block)
|
137
154
|
end
|
138
155
|
end
|
139
|
-
end
|
156
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'tmpdir'
|
3
3
|
|
4
|
-
TMP_ROOT = Pathname.new(Dir.tmpdir)
|
4
|
+
TMP_ROOT = Pathname.new(Dir.tmpdir).join('generator')
|
5
5
|
|
6
6
|
describe TestGenerator, 'using custom matcher' do
|
7
7
|
include GeneratorSpec::TestCase
|
@@ -72,6 +72,7 @@ module GeneratorSpec
|
|
72
72
|
let(:location) { TMP_ROOT.join('test_file') }
|
73
73
|
|
74
74
|
context 'with no contains' do
|
75
|
+
|
75
76
|
it 'doesnt throw if the file exists' do
|
76
77
|
write_file(location, '')
|
77
78
|
expect {
|
@@ -84,6 +85,7 @@ module GeneratorSpec
|
|
84
85
|
file.matches?(TMP_ROOT)
|
85
86
|
}.to throw_symbol(:failure)
|
86
87
|
end
|
88
|
+
|
87
89
|
end
|
88
90
|
|
89
91
|
context 'with contains' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: generator_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Hodgkiss
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -86,7 +86,7 @@ homepage: https://github.com/stevehodgkiss/generator_spec
|
|
86
86
|
licenses:
|
87
87
|
- MIT
|
88
88
|
metadata: {}
|
89
|
-
post_install_message:
|
89
|
+
post_install_message:
|
90
90
|
rdoc_options: []
|
91
91
|
require_paths:
|
92
92
|
- lib
|
@@ -101,9 +101,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
|
-
|
105
|
-
|
106
|
-
signing_key:
|
104
|
+
rubygems_version: 3.4.10
|
105
|
+
signing_key:
|
107
106
|
specification_version: 4
|
108
107
|
summary: Test Rails generators with RSpec
|
109
108
|
test_files:
|