Skip to content

Commit 03cac0f

Browse files
author
Prem Sichanugrist
committed
Add gemspec support in group clause
Fixes #76
1 parent 41ede2f commit 03cac0f

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

lib/appraisal/group.rb

+20-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Group
66
def initialize(group_names)
77
@dependencies = DependencyList.new
88
@group_names = group_names
9+
@gemspec = nil
910
end
1011

1112
def run(&block)
@@ -16,9 +17,26 @@ def gem(name, *requirements)
1617
@dependencies.add(name, requirements)
1718
end
1819

20+
def gemspec(options = {})
21+
@gemspec = Gemspec.new(options)
22+
end
23+
1924
def to_s
20-
"group #{Utils.format_arguments(@group_names)} do\n" +
21-
@dependencies.to_s.strip.gsub(/^/, ' ') + "\nend"
25+
<<-OUTPUT.strip
26+
group #{Utils.format_arguments(@group_names)} do
27+
#{dependencies_list}
28+
end
29+
OUTPUT
30+
end
31+
32+
private
33+
34+
def dependencies_list
35+
[@dependencies.to_s, @gemspec.to_s].
36+
reject(&:empty?).
37+
join("\n\n").
38+
gsub(/^/, " ").
39+
strip
2240
end
2341
end
2442
end

spec/acceptance/gemfile_dsl_compatibility_spec.rb

+33
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,37 @@
136136
expect(content_of "gemfiles/1.1.0.gemfile").to include('gem "bacon", "1.1.0"')
137137
expect(content_of "gemfiles/1.2.0.gemfile").to include('gem "bacon", "1.2.0"')
138138
end
139+
140+
it "supports gemspec in the group block" do
141+
build_gem "bacon", "1.0.0"
142+
build_gemspec
143+
144+
build_gemfile <<-Gemfile
145+
gem "appraisal", path: #{PROJECT_ROOT.inspect}
146+
147+
group :plugin do
148+
gemspec
149+
end
150+
Gemfile
151+
152+
build_appraisal_file <<-Appraisals
153+
appraise "1.0.0" do
154+
gem "bacon", "1.0.0"
155+
end
156+
Appraisals
157+
158+
run "bundle install --local"
159+
run "appraisal generate"
160+
161+
expect(content_of "gemfiles/1.0.0.gemfile").to eq <<-gemfile.strip_heredoc
162+
# This file was generated by Appraisal
163+
164+
gem "appraisal", :path => #{PROJECT_ROOT.inspect}
165+
gem "bacon", "1.0.0"
166+
167+
group :plugin do
168+
gemspec :path => "../"
169+
end
170+
gemfile
171+
end
139172
end

0 commit comments

Comments
 (0)