generator_spec 0.0.2 → 0.0.3
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/README.md +3 -0
- data/lib/generator_spec/matcher.rb +32 -2
- data/lib/generator_spec/version.rb +1 -1
- data/spec/generator_spec/matcher_spec.rb +3 -0
- metadata +2 -20
data/README.md
CHANGED
@@ -23,15 +23,41 @@ module GeneratorSpec
|
|
23
23
|
throw :failure, root.join(@name)
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
check_contents(root.join(@name))
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
def check_contents(file)
|
32
|
+
contents = ::File.read(file)
|
27
33
|
|
28
34
|
@contents.each do |string|
|
29
35
|
unless contents.include?(string)
|
30
|
-
throw :failure, [
|
36
|
+
throw :failure, [file, string, contents]
|
31
37
|
end
|
32
38
|
end
|
33
39
|
end
|
34
40
|
end
|
41
|
+
|
42
|
+
class Migration < File
|
43
|
+
def matches?(root)
|
44
|
+
file_name = migration_file_name(root, @name)
|
45
|
+
|
46
|
+
unless file_name && file_name.exist?
|
47
|
+
throw :failure, file_name
|
48
|
+
end
|
49
|
+
|
50
|
+
check_contents(file_name)
|
51
|
+
end
|
52
|
+
|
53
|
+
protected
|
54
|
+
|
55
|
+
def migration_file_name(root, name) #:nodoc:
|
56
|
+
directory, file_name = ::File.dirname(root.join(name)), ::File.basename(name).sub(/\.rb$/, '')
|
57
|
+
migration = Dir.glob("#{directory}/[0-9]*_*.rb").grep(/\d+_#{file_name}.rb$/).first
|
58
|
+
Pathname.new(migration) if migration
|
59
|
+
end
|
60
|
+
end
|
35
61
|
|
36
62
|
class Directory
|
37
63
|
attr_reader :tree
|
@@ -58,6 +84,10 @@ module GeneratorSpec
|
|
58
84
|
def location(name)
|
59
85
|
[@root, name].compact.join("/")
|
60
86
|
end
|
87
|
+
|
88
|
+
def migration(name, &block)
|
89
|
+
@tree[name] = Migration.new(location(name), &block)
|
90
|
+
end
|
61
91
|
|
62
92
|
def matches?(root)
|
63
93
|
@tree.each do |file, value|
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: generator_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 27
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 0.0.2
|
5
|
+
version: 0.0.3
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Steve Hodgkiss
|
@@ -26,10 +21,6 @@ dependencies:
|
|
26
21
|
requirements:
|
27
22
|
- - ~>
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 7
|
30
|
-
segments:
|
31
|
-
- 3
|
32
|
-
- 0
|
33
24
|
version: "3.0"
|
34
25
|
type: :runtime
|
35
26
|
version_requirements: *id001
|
@@ -41,9 +32,6 @@ dependencies:
|
|
41
32
|
requirements:
|
42
33
|
- - ">="
|
43
34
|
- !ruby/object:Gem::Version
|
44
|
-
hash: 3
|
45
|
-
segments:
|
46
|
-
- 0
|
47
35
|
version: "0"
|
48
36
|
type: :runtime
|
49
37
|
version_requirements: *id002
|
@@ -88,23 +76,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
76
|
requirements:
|
89
77
|
- - ">="
|
90
78
|
- !ruby/object:Gem::Version
|
91
|
-
hash: 3
|
92
|
-
segments:
|
93
|
-
- 0
|
94
79
|
version: "0"
|
95
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
81
|
none: false
|
97
82
|
requirements:
|
98
83
|
- - ">="
|
99
84
|
- !ruby/object:Gem::Version
|
100
|
-
hash: 3
|
101
|
-
segments:
|
102
|
-
- 0
|
103
85
|
version: "0"
|
104
86
|
requirements: []
|
105
87
|
|
106
88
|
rubyforge_project: generator_spec
|
107
|
-
rubygems_version: 1.5.
|
89
|
+
rubygems_version: 1.5.2
|
108
90
|
signing_key:
|
109
91
|
specification_version: 3
|
110
92
|
summary: Test Rails generators with RSpec
|