Skip to content

Commit

Permalink
Merge pull request #7 from bquorning/rails-5-support
Browse files Browse the repository at this point in the history
Make work with Rails 5
  • Loading branch information
sinisterchipmunk committed Jul 1, 2016
2 parents fb09919 + 6963d38 commit 6aa4fd9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
21 changes: 18 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
rvm:
- 2.0.0
- 2.1.8
- 2.2.4
- 2.3.0
- ruby-head
- jruby-19mode
- jruby-head
- rbx-19mode

env:
- RAILS_VERSION="~> 3.1"
- RAILS_VERSION="~> 3.2"
- RAILS_VERSION="~> 4.0"
- RAILS_VERSION="~> 3.1.0"
- RAILS_VERSION="~> 3.2.0"
- RAILS_VERSION="~> 4.0.0"
- RAILS_VERSION="~> 4.1.0"
- RAILS_VERSION="~> 4.2.0"
- RAILS_VERSION="~> 5.0.0"

matrix:
allow_failures:
- rvm: ruby-head
- rvm: jruby-19mode
- rvm: rbx-19mode
- rvm: jruby-head
exclude:
- rvm: 2.3.0
env: RAILS_VERSION="~> 3.1.0"
- rvm: 2.3.0
env: RAILS_VERSION="~> 3.2.0"
- rvm: 2.0.0
env: RAILS_VERSION="~> 5.0.0"
- rvm: 2.1.8
env: RAILS_VERSION="~> 5.0.0"
1 change: 0 additions & 1 deletion genspec.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Gem::Specification.new do |s|

s.add_dependency 'thor'
s.add_dependency 'rspec', '~> 2'
s.add_dependency 'sc-core-ext', "~> 1.2.1"

s.add_development_dependency 'coveralls'
end
Expand Down
8 changes: 5 additions & 3 deletions lib/genspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
if defined?(Rails)
if Rails::VERSION::MAJOR == 2
raise "Use genspec 0.1.x for Rails 2; this version is for Rails 3."
elsif [3, 4].include? Rails::VERSION::MAJOR
elsif [3, 4, 5].include? Rails::VERSION::MAJOR
require 'rails/generators'
else
raise "Unsupported Rails version: #{Rails::VERSION::STRING}"
Expand All @@ -20,8 +20,10 @@
module GenSpec
def self.root; @root; end
def self.root=(root); @root = root; end

require 'sc-core-ext'

require 'active_support'
require "active_support/core_ext/string/inflections"
require "active_support/core_ext/hash/reverse_merge"
require 'genspec/version' unless defined?(GenSpec::VERSION)
require 'genspec/shell'
require 'genspec/matchers'
Expand Down
9 changes: 5 additions & 4 deletions lib/genspec/matchers/generation_method_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def initialize(method_name, *args, &block)
def report_actual_args(args)
# save a reference to the set of args that most *closely* matched the expectation.
return(@actual_args = args) if @actual_args.nil?
matches = (method_args % args).length
if matches > (method_args % @actual_args).length
matches = (method_args & args).length
if matches > (method_args & @actual_args).length
@actual_args = args
end
end
Expand Down Expand Up @@ -85,8 +85,9 @@ def invoking

send(:"#{method_name}_without_intercept", *argus, &block)
end

alias_method_chain :"#{method_name}", :intercept

alias_method :"#{method_name}_without_intercept", :"#{method_name}"
alias_method :"#{method_name}", :"#{method_name}_with_intercept"
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/generators/test_rails3_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
it "should modify Gemfile" do
out = ""
subject.should generate {
File.read("Gemfile").strip.should_not be_blank
File.read("Gemfile").strip.should_not be_empty
out.concat File.read("Gemfile")
}
out.strip.should == 'source "http://gems.github.com/"'
out.strip.should =~ %r(\Asource ['"]http://gems.github.com/['"]\z)
end

context "with no options or arguments" do
Expand Down

0 comments on commit 6aa4fd9

Please sign in to comment.