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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3740bec750e728d9bb6506135c75d721b407214a
4
- data.tar.gz: 0e822cbddfcf0ca68e68a44bfb6dd868fa661c0b
3
+ metadata.gz: 75981b2df31e29244d8c38691d098fb64fab64d0
4
+ data.tar.gz: b7bf7d18e376bfd62dde9c7a4c6c004fc3ff6724
5
5
  SHA512:
6
- metadata.gz: b2f5e61ad14a6af712f092a67721ca0a7312e01c472c1c78a8abb2730d3babeab14dd4ea381d1272299b46445e0dd475e607f546d9867086dc54a02ecec08715
7
- data.tar.gz: 51076fb0b0f07ad9ce83544a88e7e21d8be623a1d2ac14c4a39950e3b203193104b82e94dcb30cd3ed77ca5f868f03d58a6716a4e0e238476a65e942bf8c5b9a
6
+ metadata.gz: 95cd7496ca88976ff649f652cfd4cea630a76b62399c052add342e4e52882a0e5c1b4b04edb2a33190fd37c6eb8e95b1fa3fd85d3ef0345c0c53412d5587ce3c
7
+ data.tar.gz: faffdeff2700c52728ebe15c368573523c771e0dd5b0aafefd38d37990d1fd544bf629cb496c9fb0ae264cc0057d86af1f494f4b42e4885cd7dfa8def6d076db
@@ -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:
@@ -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 defined?(Rails)
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 !defined?(Rails) && mod =~ /^Rails/
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 =~ /=/ }
@@ -2,7 +2,7 @@ module GenSpec
2
2
  class Version
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- PATCH = 0
5
+ PATCH = 1
6
6
  RELEASE = nil
7
7
 
8
8
  STRING = (RELEASE ? [MAJOR, MINOR, PATCH, RELEASE] : [MAJOR, MINOR, PATCH]).join('.')
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- if defined?(Rails)
3
+ if GenSpec.rails?
4
4
  describe :my_migration do
5
5
  it "should run migration template" do
6
6
  # bug, raising NameError: undefined local variable or method `interceptor'
@@ -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 defined?(Rails)
59
+ if GenSpec.rails?
60
60
  expect(subject).to add_source("http://gems.github.com/")
61
61
  end
62
62
  end
@@ -12,7 +12,13 @@ Bundler.setup
12
12
  if ENV['RAILS_VERSION'] != 'none'
13
13
  require 'rails'
14
14
  require 'rails/generators'
15
- end
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
- if !defined?(Rails)
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 = defined?(Rails) ? Rails::Generators::Base : Thor::Group
1
+ base = GenSpec.rails? ? Rails::Generators::Base : Thor::Group
2
2
 
3
3
  class Question < base
4
4
  include Thor::Actions
@@ -1,4 +1,4 @@
1
- base = defined?(Rails) ? Rails::Generators::Base : Thor::Group
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 defined?(Rails)
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/"'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin MacKenzie IV