generator_spec 0.8.1 → 0.8.2
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/Gemfile.lock +1 -1
- data/MIT-LICENSE +20 -0
- data/lib/generator_spec/test_case.rb +6 -2
- data/lib/generator_spec/version.rb +1 -1
- data/spec/generator_spec/matcher_spec.rb +1 -1
- data/spec/generator_spec/test_case_spec.rb +24 -1
- data/spec/support/test_generator/test_generator.rb +2 -1
- metadata +3 -2
data/Gemfile.lock
CHANGED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 Steve Hodgkiss
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -12,8 +12,12 @@ module GeneratorSpec
|
|
12
12
|
|
13
13
|
included do
|
14
14
|
cattr_accessor :test_case, :test_case_instance
|
15
|
-
|
16
|
-
self.
|
15
|
+
|
16
|
+
self.test_case = Class.new(Rails::Generators::TestCase) do
|
17
|
+
def fake_test_case; end
|
18
|
+
def add_assertion; end
|
19
|
+
end
|
20
|
+
self.test_case_instance = self.test_case.new(:fake_test_case)
|
17
21
|
end
|
18
22
|
|
19
23
|
module ClassMethods
|
@@ -27,7 +27,7 @@ describe TestGenerator, "using normal assert methods" do
|
|
27
27
|
include GeneratorSpec::TestCase
|
28
28
|
tests TestGenerator
|
29
29
|
destination File.expand_path("../../tmp", __FILE__)
|
30
|
-
arguments %w(test)
|
30
|
+
arguments %w(test --test)
|
31
31
|
|
32
32
|
before(:all) do
|
33
33
|
prepare_destination
|
@@ -45,4 +45,27 @@ describe TestGenerator, "using normal assert methods" do
|
|
45
45
|
it "removes files" do
|
46
46
|
assert_no_file ".gitignore"
|
47
47
|
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe TestGenerator, "with contexts" do
|
51
|
+
include GeneratorSpec::TestCase
|
52
|
+
tests TestGenerator
|
53
|
+
destination File.expand_path("../../tmp", __FILE__)
|
54
|
+
before { prepare_destination }
|
55
|
+
|
56
|
+
context "with --test flag" do
|
57
|
+
before { run_generator %w(test --test) }
|
58
|
+
|
59
|
+
it "creates a test initializer" do
|
60
|
+
assert_file "config/initializers/test.rb", "# Initializer"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "without any flags" do
|
65
|
+
before { run_generator %w(test) }
|
66
|
+
|
67
|
+
it "doesn't create a test initializer" do
|
68
|
+
assert_no_file "config/initializers/test.rb"
|
69
|
+
end
|
70
|
+
end
|
48
71
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class TestGenerator < Rails::Generators::Base
|
2
2
|
argument :name, :type => :string
|
3
|
+
class_option :test, :type => :boolean, :default => false
|
3
4
|
source_root File.expand_path('../templates', __FILE__)
|
4
5
|
|
5
6
|
def copy_initializer
|
6
|
-
template "initializer.rb", "config/initializers/test.rb"
|
7
|
+
template "initializer.rb", "config/initializers/test.rb" if options[:test]
|
7
8
|
end
|
8
9
|
|
9
10
|
def create_migration
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: generator_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.8.
|
5
|
+
version: 0.8.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Steve Hodgkiss
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-17 00:00:00 +00:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- .rspec
|
50
50
|
- Gemfile
|
51
51
|
- Gemfile.lock
|
52
|
+
- MIT-LICENSE
|
52
53
|
- README.md
|
53
54
|
- Rakefile
|
54
55
|
- generator_spec.gemspec
|