generator_spec 0.9.3 → 0.9.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b7e9059728e32e462c0ba6f3d27c2ff641f958d8
4
- data.tar.gz: 0256f4c0a7b39b431723ed4291f5e3b31a13eb9b
2
+ SHA256:
3
+ metadata.gz: 259e672a9eabc7d6c46c0679efa9a0fce1f4b39fa6ba9bdf7a3698343710ff62
4
+ data.tar.gz: 926d8dcf4a13a5319c430b94efa7bcc57ec0ce041aeb141e6fc26949a2ac9ae8
5
5
  SHA512:
6
- metadata.gz: 88e68ec9f6ae5c4b0ce18a68c6daabbf0bc65a15b325795dac059498b9bfe6cef524a64ad516c58012e2cec579bc94fa8e87cecd5d37be6bee58d0e7ee711ec4
7
- data.tar.gz: 3100f8a199176d304187d3e61ce3f5194f7654d95bb466f7c086e7fdcea0f81c9080447c767ce54fb078ad0aadbdff651c5933d981bdbc2a0218ef433ccc01d0
6
+ metadata.gz: 697ffb8f6a9a6ad285a222024db30f542d055821fb755d0ebb047e7a408b4724e902b33fc7b15a3a9f910ccdd7dea3f357895ee57c2c5ae86c216b55aab47a69
7
+ data.tar.gz: 8c698a7a3c0c94e82262cd3eb1f058f2343100d9c214ef81e22d089c1fe27335c31c15009328efdc27191fce2dd17218a5f1d8a113bf40d626a0c97c4fe2da50
data/.travis.yml CHANGED
@@ -1,11 +1,4 @@
1
1
  language: ruby
2
- sudo: false
3
- cache: bundler
4
2
  rvm:
5
- - 2.1
6
- - 2.0.0
7
- - jruby
8
- - rbx-2
9
- matrix:
10
- allow_failures:
11
- - rvm: jruby
3
+ - 2.4
4
+ - 2.3
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  platforms :rbx do
4
- gem 'rubysl', '~> 2.0'
4
+ # gem 'rubysl', '~> 2.2'
5
5
  gem 'rubinius-developer_tools'
6
6
  end
7
7
 
data/README.md CHANGED
@@ -19,7 +19,7 @@ Spec (files in `spec/lib/generators` are recognized as generator type example gr
19
19
 
20
20
  require "generator_spec"
21
21
 
22
- describe TestGenerator do
22
+ describe TestGenerator, type: :generator do
23
23
  destination File.expand_path("../../tmp", __FILE__)
24
24
  arguments %w(something)
25
25
 
@@ -46,7 +46,7 @@ describe TestGenerator, "using custom matcher", type: :generator do
46
46
  end
47
47
 
48
48
  specify do
49
- destination_root.should have_structure {
49
+ expect(destination_root).to have_structure {
50
50
  no_file "test.rb"
51
51
  directory "config" do
52
52
  directory "initializers" do
@@ -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"
@@ -131,7 +148,9 @@ module GeneratorSpec
131
148
  end
132
149
 
133
150
  def have_structure(&block)
151
+ error = 'You must pass a block to have_structure (Use {} instead of do/end!)'
152
+ raise RuntimeError, error unless block_given?
134
153
  Root.new(&block)
135
154
  end
136
155
  end
137
- end
156
+ end
@@ -1,3 +1,3 @@
1
1
  module GeneratorSpec
2
- VERSION = '0.9.3'
2
+ VERSION = '0.9.5'
3
3
  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
@@ -44,7 +44,19 @@ describe TestGenerator, 'using custom matcher' do
44
44
  end
45
45
  end
46
46
  }
47
- }.to raise_error
47
+ }.to raise_error RSpec::Expectations::ExpectationNotMetError
48
+ end
49
+
50
+ it 'fails when it doesnt match with do/end instead of {}' do
51
+ expect {
52
+ expect(destination_root).to have_structure do
53
+ directory 'db' do
54
+ directory 'migrate' do
55
+ no_file '123_create_tests.rb'
56
+ end
57
+ end
58
+ end
59
+ }.to raise_error RuntimeError, /You must pass a block/
48
60
  end
49
61
  end
50
62
 
@@ -60,6 +72,7 @@ module GeneratorSpec
60
72
  let(:location) { TMP_ROOT.join('test_file') }
61
73
 
62
74
  context 'with no contains' do
75
+
63
76
  it 'doesnt throw if the file exists' do
64
77
  write_file(location, '')
65
78
  expect {
@@ -72,6 +85,7 @@ module GeneratorSpec
72
85
  file.matches?(TMP_ROOT)
73
86
  }.to throw_symbol(:failure)
74
87
  end
88
+
75
89
  end
76
90
 
77
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.3
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: 2014-11-28 00:00:00.000000000 Z
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
- rubyforge_project: generator_spec
105
- rubygems_version: 2.2.2
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:
@@ -117,4 +116,3 @@ test_files:
117
116
  - spec/support/test_generator/templates/initializer.rb
118
117
  - spec/support/test_generator/templates/migration.rb
119
118
  - spec/support/test_generator/test_generator.rb
120
- has_rdoc: