Permalink
Browse files

Fix gem templates, add specs for nested constants

  • Loading branch information...
1 parent 3ac4d82 commit 838b567c662c6ea60976d3837048ccce6b297353 @indirect indirect committed Aug 15, 2010
@@ -2,6 +2,6 @@
<%= ' '*i %>module <%= c %>
<%- end -%>
<%= ' '*config[:constant_array].size %># Your code goes here...
-<%- config[:constant_array].size.downto(0) do |i| -%>
+<%- (config[:constant_array].size-1).downto(0) do |i| -%>
<%= ' '*i %>end
<%- end -%>
@@ -2,6 +2,6 @@
<%= ' '*i %>module <%= c %>
<%- end -%>
<%= ' '*config[:constant_array].size %>VERSION = "0.0.1"
-<%- config[:constant_array].size.downto(0) do |i| -%>
+<%- (config[:constant_array].size-1).downto(0) do |i| -%>
<%= ' '*i %>end
<%- end -%>
@@ -30,7 +30,7 @@
bundle 'gem test'
@app = bundled_app("test")
gemspec = File.read("#{@app.to_s}/test.gemspec")
- File.open("#{@app.to_s}/test.gemspec", 'w') {|f| f << gemspec.gsub(/TODO/, '')}
+ File.open("#{@app.to_s}/test.gemspec", 'w'){|f| f << gemspec.gsub('TODO: ', '') }
@helper = Bundler::GemHelper.new(@app.to_s)
end
@@ -41,7 +41,8 @@
it "installs" do
@helper.install_gem
- should_be_installed("test 0.0.1")
+ bundled_app('test/pkg/test-0.0.1.gem').should exist
+ %x{gem list}.should include("test (0.0.1)")
end
it "shouldn't push if there are uncommitted files" do
View
@@ -1,11 +1,23 @@
require "spec_helper"
describe "bundle gem" do
+ before :each do
+ bundle 'gem test-gem'
+ end
+
it "generates a gem skeleton" do
- bundle 'gem test'
- bundled_app("test/Gemfile").should exist
- bundled_app("test/Rakefile").should exist
- bundled_app("test/lib/test.rb").should exist
- bundled_app("test/lib/test/version.rb").should exist
+ bundled_app("test-gem/Gemfile").should exist
+ bundled_app("test-gem/Rakefile").should exist
+ bundled_app("test-gem/lib/test-gem.rb").should exist
+ bundled_app("test-gem/lib/test-gem/version.rb").should exist
+ end
+
+ it "starts with version 0.0.1" do
+ bundled_app("test-gem/lib/test-gem/version.rb").read.should =~ /VERSION = "0.0.1"/
+ end
+
+ it "nests constants so they work" do
+ bundled_app("test-gem/lib/test-gem/version.rb").read.should =~ /module Test\n module Gem/
+ bundled_app("test-gem/lib/test-gem.rb").read.should =~ /module Test\n module Gem/
end
end

0 comments on commit 838b567

Please sign in to comment.