rspec_for_generators 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -19,35 +19,37 @@ To install using edge
19
19
 
20
20
  The following demonstrates an example usage. There are many more options and cool DSL convenience methods. Check out the code!
21
21
 
22
- <pre>
23
- # spec/spec_helper.rb
24
- require 'rspec'
22
+ ### spec/spec_helper.rb
25
23
 
26
- # This is required for rails_spec_helper.rb to work. Not sure how to better set this configuration value.
27
- # It's the relative root for which the Rails mock app is created. So if it's set to point to the spec folder,
28
- # then rails will be put under ../tmp, relative to /spec, so that /tmp will be a folder in the current project root.
29
- # Note: In the near future I will provide a better way to achieve this by hooking into some step in the Rails 3 loading behavior
24
+ <pre>require 'rspec'
25
+
26
+ # The following somewhat ugly 'hack' is currently required for rails_spec_helper.rb to work.
27
+ # It's the relative root for which the Rails mock app is created.
28
+ # So if it's set to point to the spec folder, then the temporary rails application
29
+ # will be generated in ../tmp, relative to the folder of this file : File.dirname(__FILE__)
30
+ # Thus in this example the /tmp folder will be in the current project root.
31
+
32
+ # Note: In the near future I will provide a better way to achieve this, by hooking into the Rails 3 loading
33
+ # behavior as described in a *Rails Dispatch* article by *wycatz*
30
34
 
31
35
  module Rails
32
36
  def config_root_dir
33
- File.dirname(__FILE)
37
+ File.dirname(__FILE__)
34
38
  end
35
39
  end
36
40
 
37
41
  # load this rspec toolbox to help spec generators
38
- require 'rspec_for_generators'
42
+ require 'rspec_for_generators'</pre>
43
+
44
+ ### spec/generators/canable.rb
39
45
 
40
- <pre>
46
+ Convenience way to define which generators to require
41
47
 
42
- <pre>
43
- # spec/generators/canable.rb
44
- require_generators :canable => ['model', 'user']
45
- </pre>
48
+ <pre>require_generators :canable => ['model', 'user']</pre>
46
49
 
47
- <pre>
48
- # spec/generators/model_generator_spec.rb
50
+ ### spec/generators/model_generator_spec.rb
49
51
 
50
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
52
+ <pre>require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
51
53
 
52
54
  # list of generators to spec are loaded
53
55
  require 'generators/canable'
@@ -93,8 +95,7 @@ describe 'model_generator' do
93
95
  end
94
96
  end
95
97
  end
96
- end
97
- </pre>
98
+ end</pre>
98
99
 
99
100
  ## Note on Patches/Pull Requests
100
101
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -11,11 +11,15 @@ require 'rspec_for_generators/rails_spec_helper'
11
11
  Rails::Generators.configure!
12
12
 
13
13
  # require the generators
14
- def require_generators generator_list
15
- generator_list.each do |name, generators|
16
- generators.each do |generator_name|
17
- require File.join('generators', name.to_s, generator_name.to_s, "#{generator_name}_generator")
18
- end
14
+ def require_generators *generator_list
15
+ generator_list.each do |name, generators|
16
+ if !generators || generators.empty
17
+ require File.join('generators', name.to_s, "#{name.to_s}_generator")
18
+ else
19
+ generators.each do |generator_name|
20
+ require File.join('generators', name.to_s, generator_name.to_s, "#{generator_name}_generator")
21
+ end
22
+ end
19
23
  end
20
24
  end
21
25
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rspec_for_generators}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
- require 'generators/demo/demo_generator'
2
+ require_generators :demo
3
3
 
4
4
  describe 'model_generator' do
5
5
  include RSpec::Rails::Model
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kristian Mandrup