generator_spec 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- generator_spec (0.8.0)
4
+ generator_spec (0.8.1)
5
5
  rails (~> 3.0)
6
6
  rspec-rails
7
7
 
@@ -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
- self.test_case = Class.new(Rails::Generators::TestCase)
16
- self.test_case_instance = self.test_case.new(:test)
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
@@ -1,3 +1,3 @@
1
1
  module GeneratorSpec
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.2"
3
3
  end
@@ -4,7 +4,7 @@ describe TestGenerator, "using custom matcher" do
4
4
  include GeneratorSpec::TestCase
5
5
  tests TestGenerator
6
6
  destination File.expand_path("../../tmp", __FILE__)
7
- arguments %w(test)
7
+ arguments %w(test --test)
8
8
 
9
9
  before do
10
10
  prepare_destination
@@ -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.1
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-06 00:00:00 +00:00
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