genspec 0.3.0 → 0.3.1
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 +4 -4
- data/.travis.yml +3 -0
- data/lib/genspec.rb +5 -1
- data/lib/genspec/matchers/base.rb +1 -1
- data/lib/genspec/matchers/generation_method_matcher.rb +2 -2
- data/lib/genspec/version.rb +1 -1
- data/spec/generators/migration_spec.rb +1 -1
- data/spec/generators/test_rails3_spec.rb +1 -1
- data/spec/spec_helper.rb +9 -2
- data/spec/support/generators/question/question_generator.rb +1 -1
- data/spec/support/generators/test_rails3/test_rails3_generator.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75981b2df31e29244d8c38691d098fb64fab64d0
|
4
|
+
data.tar.gz: b7bf7d18e376bfd62dde9c7a4c6c004fc3ff6724
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95cd7496ca88976ff649f652cfd4cea630a76b62399c052add342e4e52882a0e5c1b4b04edb2a33190fd37c6eb8e95b1fa3fd85d3ef0345c0c53412d5587ce3c
|
7
|
+
data.tar.gz: faffdeff2700c52728ebe15c368573523c771e0dd5b0aafefd38d37990d1fd544bf629cb496c9fb0ae264cc0057d86af1f494f4b42e4885cd7dfa8def6d076db
|
data/.travis.yml
CHANGED
@@ -18,6 +18,9 @@ env:
|
|
18
18
|
# which isn't considered here), I'm assuming no.
|
19
19
|
- RAILS_VERSION="none" RSPEC_VERSION="~> 2.0"
|
20
20
|
- RAILS_VERSION="none" RSPEC_VERSION="~> 3.0"
|
21
|
+
# don't use rails, but define a module called Rails. This happens if you
|
22
|
+
# pull in ActiveRecord and then require AR's generators.
|
23
|
+
- RAILS_VERSION="none" DEFINE_RAILS_MODULE=1
|
21
24
|
|
22
25
|
matrix:
|
23
26
|
allow_failures:
|
data/lib/genspec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'thor'
|
2
|
-
if defined?(Rails)
|
2
|
+
if defined?(Rails) && defined?(Rails::VERSION)
|
3
3
|
if Rails::VERSION::MAJOR == 2
|
4
4
|
raise "Use genspec 0.1.x for Rails 2; this version is for Rails 3."
|
5
5
|
elsif [3, 4, 5].include? Rails::VERSION::MAJOR
|
@@ -22,6 +22,10 @@ module GenSpec
|
|
22
22
|
def self.root; @root; end
|
23
23
|
def self.root=(root); @root = root; end
|
24
24
|
|
25
|
+
def self.rails?
|
26
|
+
defined?(Rails) && defined?(Rails::VERSION)
|
27
|
+
end
|
28
|
+
|
25
29
|
require 'genspec/version' unless defined?(GenSpec::VERSION)
|
26
30
|
require 'genspec/shell'
|
27
31
|
require 'genspec/matchers'
|
@@ -30,7 +30,7 @@ module GenSpec
|
|
30
30
|
if @described.kind_of?(Class)
|
31
31
|
@generator = @described
|
32
32
|
else
|
33
|
-
if
|
33
|
+
if GenSpec.rails?
|
34
34
|
@generator = Rails::Generators.find_by_namespace(@described, base)
|
35
35
|
else
|
36
36
|
@generator = Thor::Util.find_by_namespace(@described)
|
@@ -117,9 +117,9 @@ class GenSpec::Matchers::GenerationMethodMatcher < GenSpec::Matchers::Base
|
|
117
117
|
def generation_methods
|
118
118
|
GENERATION_CLASSES.inject([]) do |arr, mod|
|
119
119
|
if mod.kind_of?(String)
|
120
|
-
next arr if !
|
120
|
+
next arr if !GenSpec.rails? && mod =~ /^Rails/
|
121
121
|
mod = mod.split('::').inject(Kernel) do |container, name|
|
122
|
-
container.const_get(name)
|
122
|
+
container && container.const_get(name)
|
123
123
|
end
|
124
124
|
end
|
125
125
|
arr.concat mod.public_instance_methods.collect { |i| i.to_s }.reject { |i| i =~ /=/ }
|
data/lib/genspec/version.rb
CHANGED
@@ -56,7 +56,7 @@ describe :test_rails3 do
|
|
56
56
|
# Rails-specific actions are also working. If they are, it's safe to say custom extensions
|
57
57
|
# will work fine too.
|
58
58
|
it 'should add_source "http://gems.github.com/"' do
|
59
|
-
if
|
59
|
+
if GenSpec.rails?
|
60
60
|
expect(subject).to add_source("http://gems.github.com/")
|
61
61
|
end
|
62
62
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -12,7 +12,13 @@ Bundler.setup
|
|
12
12
|
if ENV['RAILS_VERSION'] != 'none'
|
13
13
|
require 'rails'
|
14
14
|
require 'rails/generators'
|
15
|
-
|
15
|
+
elsif ENV['DEFINE_RAILS_MODULE']
|
16
|
+
# Rails module can be defined while missing common constants like VERSION
|
17
|
+
# if you pull in a rails component like ActiveRecord, then require the
|
18
|
+
# activerecord generators. Maybe this can happen in other scenarios too.
|
19
|
+
# Anyway the existence of a Rails module alone should not break genspec.
|
20
|
+
module Rails; end
|
21
|
+
end
|
16
22
|
|
17
23
|
module CustomActions
|
18
24
|
def act_upon(file)
|
@@ -20,7 +26,8 @@ module CustomActions
|
|
20
26
|
end
|
21
27
|
end
|
22
28
|
|
23
|
-
|
29
|
+
require 'genspec'
|
30
|
+
unless GenSpec.rails?
|
24
31
|
require 'thor/group'
|
25
32
|
require File.expand_path('support/generators/test_rails3/test_rails3_generator', File.dirname(__FILE__))
|
26
33
|
require File.expand_path('support/generators/question/question_generator', File.dirname(__FILE__))
|
@@ -1,4 +1,4 @@
|
|
1
|
-
base =
|
1
|
+
base = GenSpec.rails? ? Rails::Generators::Base : Thor::Group
|
2
2
|
|
3
3
|
class TestRails3 < base
|
4
4
|
include Thor::Actions
|
@@ -24,7 +24,7 @@ class TestRails3 < base
|
|
24
24
|
|
25
25
|
def gen_gem_source
|
26
26
|
if File.file?("Gemfile")
|
27
|
-
if
|
27
|
+
if GenSpec.rails?
|
28
28
|
add_source "http://gems.github.com/"
|
29
29
|
else
|
30
30
|
append_file "Gemfile", 'source "http://gems.github.com/"'
|