juwelier 2.1.0
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 +7 -0
- data/.coveralls.yml +2 -0
- data/.document +8 -0
- data/.semver +5 -0
- data/.travis.yml +7 -0
- data/.yardopts +2 -0
- data/ChangeLog.markdown +230 -0
- data/Gemfile +40 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +252 -0
- data/Rakefile +78 -0
- data/bin/juwelier +9 -0
- data/features/generator/cucumber.feature +103 -0
- data/features/generator/directory_layout.feature +86 -0
- data/features/generator/dotdocument.feature +13 -0
- data/features/generator/env_options.feature +9 -0
- data/features/generator/gemfile.feature +81 -0
- data/features/generator/git.feature +102 -0
- data/features/generator/license.feature +20 -0
- data/features/generator/rakefile.feature +158 -0
- data/features/generator/readme.feature +12 -0
- data/features/generator/test.feature +54 -0
- data/features/generator/test_helper.feature +149 -0
- data/features/placeholder.feature +5 -0
- data/features/step_definitions/debug_steps.rb +6 -0
- data/features/step_definitions/filesystem_steps.rb +70 -0
- data/features/step_definitions/generator_steps.rb +387 -0
- data/features/step_definitions/task_steps.rb +6 -0
- data/features/support/env.rb +41 -0
- data/features/tasks/build_gem.feature +9 -0
- data/features/tasks/version.feature +31 -0
- data/features/tasks/version_bumping.feature +49 -0
- data/juwelier.gemspec +241 -0
- data/lib/juwelier.rb +178 -0
- data/lib/juwelier/commands.rb +20 -0
- data/lib/juwelier/commands/build_gem.rb +40 -0
- data/lib/juwelier/commands/check_dependencies.rb +66 -0
- data/lib/juwelier/commands/install_gem.rb +31 -0
- data/lib/juwelier/commands/release_gemspec.rb +87 -0
- data/lib/juwelier/commands/release_to_git.rb +64 -0
- data/lib/juwelier/commands/release_to_rubygems.rb +28 -0
- data/lib/juwelier/commands/validate_gemspec.rb +30 -0
- data/lib/juwelier/commands/version/base.rb +55 -0
- data/lib/juwelier/commands/version/bump_major.rb +13 -0
- data/lib/juwelier/commands/version/bump_minor.rb +12 -0
- data/lib/juwelier/commands/version/bump_patch.rb +14 -0
- data/lib/juwelier/commands/version/write.rb +12 -0
- data/lib/juwelier/commands/write_gemspec.rb +39 -0
- data/lib/juwelier/errors.rb +8 -0
- data/lib/juwelier/gemcutter_tasks.rb +8 -0
- data/lib/juwelier/gemspec_helper.rb +87 -0
- data/lib/juwelier/generator.rb +304 -0
- data/lib/juwelier/generator/application.rb +63 -0
- data/lib/juwelier/generator/bacon_mixin.rb +43 -0
- data/lib/juwelier/generator/github_mixin.rb +22 -0
- data/lib/juwelier/generator/micronaut_mixin.rb +41 -0
- data/lib/juwelier/generator/minitest_mixin.rb +42 -0
- data/lib/juwelier/generator/options.rb +172 -0
- data/lib/juwelier/generator/rdoc_mixin.rb +13 -0
- data/lib/juwelier/generator/riot_mixin.rb +42 -0
- data/lib/juwelier/generator/rspec_mixin.rb +42 -0
- data/lib/juwelier/generator/shindo_mixin.rb +44 -0
- data/lib/juwelier/generator/shoulda_mixin.rb +42 -0
- data/lib/juwelier/generator/testspec_mixin.rb +42 -0
- data/lib/juwelier/generator/testunit_mixin.rb +39 -0
- data/lib/juwelier/generator/yard_mixin.rb +15 -0
- data/lib/juwelier/rubyforge_tasks.rb +95 -0
- data/lib/juwelier/rubygems_dot_org_tasks.rb +38 -0
- data/lib/juwelier/rubygems_tasks.rb +38 -0
- data/lib/juwelier/specification.rb +110 -0
- data/lib/juwelier/tasks.rb +239 -0
- data/lib/juwelier/templates/.document +5 -0
- data/lib/juwelier/templates/.gitignore +49 -0
- data/lib/juwelier/templates/Gemfile +12 -0
- data/lib/juwelier/templates/LICENSE.txt +20 -0
- data/lib/juwelier/templates/README.rdoc +19 -0
- data/lib/juwelier/templates/Rakefile +9 -0
- data/lib/juwelier/templates/bacon/flunking.rb +7 -0
- data/lib/juwelier/templates/bacon/helper.rb +10 -0
- data/lib/juwelier/templates/bundler_setup.erb +10 -0
- data/lib/juwelier/templates/features/default.feature +9 -0
- data/lib/juwelier/templates/features/support/env.rb +11 -0
- data/lib/juwelier/templates/juwelier_tasks.erb +31 -0
- data/lib/juwelier/templates/micronaut/flunking.rb +7 -0
- data/lib/juwelier/templates/micronaut/helper.rb +19 -0
- data/lib/juwelier/templates/minitest/flunking.rb +7 -0
- data/lib/juwelier/templates/minitest/helper.rb +13 -0
- data/lib/juwelier/templates/other_tasks.erb +70 -0
- data/lib/juwelier/templates/riot/flunking.rb +11 -0
- data/lib/juwelier/templates/riot/helper.rb +5 -0
- data/lib/juwelier/templates/rspec/.rspec +1 -0
- data/lib/juwelier/templates/rspec/flunking.rb +7 -0
- data/lib/juwelier/templates/rspec/helper.rb +14 -0
- data/lib/juwelier/templates/shindo/flunking.rb +8 -0
- data/lib/juwelier/templates/shindo/helper.rb +7 -0
- data/lib/juwelier/templates/shoulda/flunking.rb +7 -0
- data/lib/juwelier/templates/shoulda/helper.rb +12 -0
- data/lib/juwelier/templates/simplecov.erb +16 -0
- data/lib/juwelier/templates/testspec/flunking.rb +7 -0
- data/lib/juwelier/templates/testspec/helper.rb +7 -0
- data/lib/juwelier/templates/testunit/flunking.rb +7 -0
- data/lib/juwelier/templates/testunit/helper.rb +11 -0
- data/lib/juwelier/version.rb +10 -0
- data/lib/juwelier/version_helper.rb +141 -0
- data/test/fixtures/bar/VERSION.yml +4 -0
- data/test/fixtures/bar/bin/foo_the_ultimate_bin +1 -0
- data/test/fixtures/bar/hey_include_me_in_gemspec +0 -0
- data/test/fixtures/bar/lib/foo_the_ultimate_lib.rb +1 -0
- data/test/fixtures/existing-project-with-version-constant/.document +5 -0
- data/test/fixtures/existing-project-with-version-constant/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-constant/LICENSE.txt +20 -0
- data/test/fixtures/existing-project-with-version-constant/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-constant/Rakefile +85 -0
- data/test/fixtures/existing-project-with-version-constant/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-constant/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-constant/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-constant/test/test_helper.rb +10 -0
- data/test/fixtures/existing-project-with-version-plaintext/.document +5 -0
- data/test/fixtures/existing-project-with-version-plaintext/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-plaintext/LICENSE.txt +20 -0
- data/test/fixtures/existing-project-with-version-plaintext/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/Rakefile +84 -0
- data/test/fixtures/existing-project-with-version-plaintext/VERSION +1 -0
- data/test/fixtures/existing-project-with-version-plaintext/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-plaintext/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-plaintext/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/test/test_helper.rb +10 -0
- data/test/fixtures/existing-project-with-version-yaml/.document +5 -0
- data/test/fixtures/existing-project-with-version-yaml/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-yaml/LICENSE.txt +20 -0
- data/test/fixtures/existing-project-with-version-yaml/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-yaml/Rakefile +84 -0
- data/test/fixtures/existing-project-with-version-yaml/VERSION.yml +4 -0
- data/test/fixtures/existing-project-with-version-yaml/bin/foo_the_ultimate_bin +0 -0
- data/test/fixtures/existing-project-with-version-yaml/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-yaml/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-yaml/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-yaml/test/test_helper.rb +10 -0
- data/test/geminstaller.yml +12 -0
- data/test/juwelier/commands/test_build_gem.rb +112 -0
- data/test/juwelier/commands/test_install_gem.rb +35 -0
- data/test/juwelier/commands/test_release_to_gemcutter.rb +39 -0
- data/test/juwelier/commands/test_release_to_git.rb +271 -0
- data/test/juwelier/commands/test_release_to_github.rb +477 -0
- data/test/juwelier/commands/test_validate_gemspec.rb +27 -0
- data/test/juwelier/commands/test_write_gemspec.rb +103 -0
- data/test/juwelier/commands/version/test_base.rb +53 -0
- data/test/juwelier/commands/version/test_bump_major.rb +22 -0
- data/test/juwelier/commands/version/test_bump_minor.rb +19 -0
- data/test/juwelier/commands/version/test_bump_patch.rb +20 -0
- data/test/juwelier/commands/version/test_write.rb +22 -0
- data/test/juwelier/generator/test_application.rb +142 -0
- data/test/juwelier/generator/test_options.rb +227 -0
- data/test/juwelier/test_gemspec_helper.rb +44 -0
- data/test/juwelier/test_generator.rb +140 -0
- data/test/juwelier/test_generator_initialization.rb +150 -0
- data/test/juwelier/test_generator_mixins.rb +23 -0
- data/test/juwelier/test_specification.rb +245 -0
- data/test/juwelier/test_tasks.rb +50 -0
- data/test/juwelier/test_version_helper.rb +214 -0
- data/test/shoulda_macros/juwelier_macros.rb +35 -0
- data/test/test_helper.rb +174 -0
- data/test/test_juwelier.rb +177 -0
- metadata +396 -0
| 
            File without changes
         | 
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Gem::Specification.new do |s|
         | 
| 4 | 
            +
              s.name = %q{existing-project-with-version}
         | 
| 5 | 
            +
              s.version = "1.5.3"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 8 | 
            +
              s.authors = ["Josh Nichols"]
         | 
| 9 | 
            +
              s.date = %q{2009-03-13}
         | 
| 10 | 
            +
              s.email = %q{fred.mitchell@gmx.com}
         | 
| 11 | 
            +
              s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
         | 
| 12 | 
            +
              s.files = ["README.rdoc", "VERSION.yml", "lib/existing_project_with_version.rb", "test/existing_project_with_version_test.rb", "test/test_helper.rb", "LICENSE"]
         | 
| 13 | 
            +
              s.has_rdoc = true
         | 
| 14 | 
            +
              s.homepage = %q{http://github.com/flajann2/existing-project-with-version}
         | 
| 15 | 
            +
              s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
         | 
| 16 | 
            +
              s.require_paths = ["lib"]
         | 
| 17 | 
            +
              s.rubygems_version = %q{1.3.1}
         | 
| 18 | 
            +
              s.summary = %q{Summarize your gem}
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              if s.respond_to? :specification_version then
         | 
| 21 | 
            +
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         | 
| 22 | 
            +
                s.specification_version = 2
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
         | 
| 25 | 
            +
                else
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
              else
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            end
         | 
| 
            File without changes
         | 
| @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            # Dependencies required to run the test suite
         | 
| 2 | 
            +
            gems:
         | 
| 3 | 
            +
            - name: rspec
         | 
| 4 | 
            +
              version: '~> 1.1.12'
         | 
| 5 | 
            +
            - name: Shoulda
         | 
| 6 | 
            +
              version: '~> 1.2.0'
         | 
| 7 | 
            +
            - name: ruby-debug
         | 
| 8 | 
            +
              version: '~> 0.10.3'
         | 
| 9 | 
            +
            - name: rr
         | 
| 10 | 
            +
              version: '~> 0.7.1'
         | 
| 11 | 
            +
            - name: mhennemeyer-output_catcher
         | 
| 12 | 
            +
              version: '~> 1.0.1'
         | 
| @@ -0,0 +1,112 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
            require 'juwelier/commands/build_gem'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            class Juwelier
         | 
| 5 | 
            +
              module Commands
         | 
| 6 | 
            +
                class TestBuildGem < Test::Unit::TestCase
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  context "after running without a version" do
         | 
| 9 | 
            +
                    setup do
         | 
| 10 | 
            +
                      initialize_build_gem_environment
         | 
| 11 | 
            +
                      @command.run
         | 
| 12 | 
            +
                    end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                    should "check if the gemspec helper has a version" do
         | 
| 15 | 
            +
                      assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.has_version? }
         | 
| 16 | 
            +
                    end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                    should "update version of gemspec helper if the gemspec doesn't have a version" do
         | 
| 19 | 
            +
                      assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.update_version(@version_helper)}
         | 
| 20 | 
            +
                    end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                    should "call gemspec helper's parse" do
         | 
| 23 | 
            +
                      assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.parse }
         | 
| 24 | 
            +
                    end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                    should "build from parsed gemspec" do
         | 
| 27 | 
            +
                      if Gem::Version.new(`gem -v`) >= Gem::Version.new("2.0.0.a")
         | 
| 28 | 
            +
                        assert_received(Gem::Package) {|builder_class| builder_class.build(@gemspec) }
         | 
| 29 | 
            +
                      else
         | 
| 30 | 
            +
                        assert_received(Gem::Builder) {|builder_class| builder_class.new(@gemspec) }
         | 
| 31 | 
            +
                        assert_received(@builder) {|builder| builder.build }
         | 
| 32 | 
            +
                      end
         | 
| 33 | 
            +
                    end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                    should 'make package directory' do
         | 
| 36 | 
            +
                      assert_received(@file_utils) {|file_utils| file_utils.mkdir_p './pkg'}
         | 
| 37 | 
            +
                    end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                    should 'move built gem into package directory' do
         | 
| 40 | 
            +
                      assert_received(@file_utils) {|file_utils| file_utils.mv './zomg-1.2.3.gem', './pkg'}
         | 
| 41 | 
            +
                    end
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                  
         | 
| 44 | 
            +
                  context 'after running with a version' do
         | 
| 45 | 
            +
                    setup do
         | 
| 46 | 
            +
                      initialize_build_gem_environment true
         | 
| 47 | 
            +
                      @command.run
         | 
| 48 | 
            +
                    end
         | 
| 49 | 
            +
                    
         | 
| 50 | 
            +
                    should "check if the gemspec helper has a version" do
         | 
| 51 | 
            +
                      assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.has_version? }
         | 
| 52 | 
            +
                    end
         | 
| 53 | 
            +
                    
         | 
| 54 | 
            +
                    should "update version of gemspec helper if the gemspec doesn't have a version" do
         | 
| 55 | 
            +
                      assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.update_version(@version_helper).never }
         | 
| 56 | 
            +
                    end
         | 
| 57 | 
            +
                    
         | 
| 58 | 
            +
                  end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                  build_command_context "build for juwelier" do
         | 
| 61 | 
            +
                    setup do
         | 
| 62 | 
            +
                      @command = Juwelier::Commands::BuildGem.build_for(@juwelier)
         | 
| 63 | 
            +
                    end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                    should "assign base_dir" do
         | 
| 66 | 
            +
                      assert_same @base_dir, @juwelier.base_dir
         | 
| 67 | 
            +
                    end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                    should "assign gemspec_helper" do
         | 
| 70 | 
            +
                      assert_same @gemspec_helper, @juwelier.gemspec_helper
         | 
| 71 | 
            +
                    end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                    should "return BuildGem" do
         | 
| 74 | 
            +
                      assert_kind_of Juwelier::Commands::BuildGem, @command
         | 
| 75 | 
            +
                    end
         | 
| 76 | 
            +
                  end
         | 
| 77 | 
            +
                  
         | 
| 78 | 
            +
                  def initialize_build_gem_environment(has_version = false)
         | 
| 79 | 
            +
                    @gemspec = Object.new
         | 
| 80 | 
            +
                    stub(@gemspec).file_name { 'zomg-1.2.3.gem' }
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                    @gemspec_helper = Object.new
         | 
| 83 | 
            +
                    stub(@gemspec_helper).parse { @gemspec }
         | 
| 84 | 
            +
                    stub(@gemspec_helper).update_version
         | 
| 85 | 
            +
                    stub(@gemspec_helper).has_version? { has_version }
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                    @version_helper = "Juwelier::VersionHelper"
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                    @builder = Object.new
         | 
| 90 | 
            +
                    if Gem::Version.new(`gem -v`) >= Gem::Version.new("2.0.0.a")
         | 
| 91 | 
            +
                      stub(Gem::Package).build { 'zomg-1.2.3.gem' }
         | 
| 92 | 
            +
                    else
         | 
| 93 | 
            +
                      stub(Gem::Builder).new { @builder }
         | 
| 94 | 
            +
                      stub(@builder).build { 'zomg-1.2.3.gem' }
         | 
| 95 | 
            +
                    end
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                    @file_utils = Object.new
         | 
| 98 | 
            +
                    stub(@file_utils).mkdir_p './pkg'
         | 
| 99 | 
            +
                    stub(@file_utils).mv './zomg-1.2.3.gem', './pkg'
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                    @base_dir = '.'
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                    @command = Juwelier::Commands::BuildGem.new
         | 
| 104 | 
            +
                    @command.base_dir = @base_dir
         | 
| 105 | 
            +
                    @command.file_utils = @file_utils
         | 
| 106 | 
            +
                    @command.gemspec_helper = @gemspec_helper
         | 
| 107 | 
            +
                    @command.version_helper = @version_helper
         | 
| 108 | 
            +
                  end
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                end
         | 
| 111 | 
            +
              end
         | 
| 112 | 
            +
            end
         | 
| @@ -0,0 +1,35 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class Juwelier
         | 
| 4 | 
            +
              module Commands
         | 
| 5 | 
            +
                class TestInstallGem < Test::Unit::TestCase
         | 
| 6 | 
            +
                  rubyforge_command_context "running" do
         | 
| 7 | 
            +
                    setup do
         | 
| 8 | 
            +
                      stub(@gemspec_helper).gem_path { 'pkg/zomg-1.1.1.gem' } 
         | 
| 9 | 
            +
                      stub(@command).gem_command { 'ruby -S gem' }
         | 
| 10 | 
            +
                      stub(@command).sh
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                      @command.run
         | 
| 13 | 
            +
                    end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                    should "call sh with gem install" do
         | 
| 16 | 
            +
                      assert_received(@command) {|command| command.sh 'ruby -S gem install pkg/zomg-1.1.1.gem' }
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  build_command_context "build for juwelier" do
         | 
| 21 | 
            +
                    setup do
         | 
| 22 | 
            +
                      @command = Juwelier::Commands::InstallGem.build_for(@juwelier)
         | 
| 23 | 
            +
                    end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                    should "assign gemspec helper" do
         | 
| 26 | 
            +
                      assert_equal @gemspec_helper, @command.gemspec_helper
         | 
| 27 | 
            +
                    end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                    should "assign output" do
         | 
| 30 | 
            +
                      assert_equal @output, @command.output
         | 
| 31 | 
            +
                    end
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
            end
         | 
| @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class Juwelier
         | 
| 4 | 
            +
              module Commands
         | 
| 5 | 
            +
                class TestReleaseToRubygems < Test::Unit::TestCase
         | 
| 6 | 
            +
                  def self.subject
         | 
| 7 | 
            +
                    Juwelier::Commands::ReleaseToRubygems.new
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  gemcutter_command_context "rubyforge_project is defined in gemspec and package exists on rubyforge" do
         | 
| 11 | 
            +
                    setup do
         | 
| 12 | 
            +
                      stub(@gemspec_helper).gem_path {'pkg/zomg-1.2.3.gem'}
         | 
| 13 | 
            +
                      stub(@command).sh
         | 
| 14 | 
            +
                      @command.run
         | 
| 15 | 
            +
                    end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                    should "push to rubygems" do
         | 
| 18 | 
            +
                      push_command = "gem push #{@gemspec_helper.gem_path}"
         | 
| 19 | 
            +
                      assert_received(@command) { |command| command.sh(push_command) }
         | 
| 20 | 
            +
                    end
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  build_command_context "build for juwelier" do
         | 
| 24 | 
            +
                    setup do
         | 
| 25 | 
            +
                      @command = Juwelier::Commands::ReleaseToRubygems.build_for(@juwelier)
         | 
| 26 | 
            +
                    end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                    should "assign gemspec helper" do
         | 
| 29 | 
            +
                      assert_equal @gemspec_helper, @command.gemspec_helper
         | 
| 30 | 
            +
                    end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                    should "assign output" do
         | 
| 33 | 
            +
                      assert_equal @output, @command.output
         | 
| 34 | 
            +
                    end
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
                  
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
            end
         | 
| @@ -0,0 +1,271 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class Juwelier
         | 
| 4 | 
            +
              module Commands
         | 
| 5 | 
            +
                class TestReleaseToGit < Test::Unit::TestCase
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  rubyforge_command_context "running" do
         | 
| 8 | 
            +
                    context "happily" do
         | 
| 9 | 
            +
                      setup do
         | 
| 10 | 
            +
                        stub(@command).clean_staging_area? { true }
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                        stub(@repo).checkout(anything)
         | 
| 13 | 
            +
                        stub(@repo) do
         | 
| 14 | 
            +
                          add_tag(anything)
         | 
| 15 | 
            +
                          push(anything, anything)
         | 
| 16 | 
            +
                        end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                        stub(@repo).push
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                        stub(@command).release_not_tagged? { true }
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                        @command.run
         | 
| 23 | 
            +
                      end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                      should "checkout master" do
         | 
| 26 | 
            +
                        assert_received(@repo) {|repo| repo.checkout('master') }
         | 
| 27 | 
            +
                      end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                      should "push" do
         | 
| 30 | 
            +
                        assert_received(@repo) {|repo| repo.push('origin', 'master:master') }
         | 
| 31 | 
            +
                      end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                    end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                    context "happily with different remote, local branch and remote branch" do
         | 
| 36 | 
            +
                      setup do
         | 
| 37 | 
            +
                        stub(@command).clean_staging_area? { true }
         | 
| 38 | 
            +
                        stub(@command).release_tag { "v1.2.0" }
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                        stub(@repo).checkout(anything)
         | 
| 41 | 
            +
                        stub(@repo) do
         | 
| 42 | 
            +
                          add_tag(anything)
         | 
| 43 | 
            +
                          push(anything, anything)
         | 
| 44 | 
            +
                        end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                        stub(@repo).push
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                        stub(@command).release_not_tagged? { true }
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                        @command.run({:remote => 'upstream', :local_branch => 'feature', :remote_branch => 'v1'})
         | 
| 51 | 
            +
                      end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                      should "checkout master" do
         | 
| 54 | 
            +
                        assert_received(@repo) {|repo| repo.checkout('feature') }
         | 
| 55 | 
            +
                      end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                      should "tag version" do
         | 
| 58 | 
            +
                        assert_received(@repo) {|repo| repo.add_tag('v1.2.0') }
         | 
| 59 | 
            +
                      end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                      should "push" do
         | 
| 62 | 
            +
                        assert_received(@repo) {|repo| repo.push('upstream', 'feature:v1') }
         | 
| 63 | 
            +
                      end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                    end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                    context "happily with different branch" do
         | 
| 68 | 
            +
                      setup do
         | 
| 69 | 
            +
                        stub(@command).clean_staging_area? { true }
         | 
| 70 | 
            +
                        stub(@command).release_tag { "v3.2.0" }
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                        stub(@repo).checkout(anything)
         | 
| 73 | 
            +
                        stub(@repo) do
         | 
| 74 | 
            +
                          add_tag(anything)
         | 
| 75 | 
            +
                          push(anything, anything)
         | 
| 76 | 
            +
                        end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                        stub(@repo).push
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                        stub(@command).release_not_tagged? { true }
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                        @command.run({:branch => 'v3'})
         | 
| 83 | 
            +
                      end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                      should "checkout master" do
         | 
| 86 | 
            +
                        assert_received(@repo) {|repo| repo.checkout('v3') }
         | 
| 87 | 
            +
                      end
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                      should "tag version" do
         | 
| 90 | 
            +
                        assert_received(@repo) {|repo| repo.add_tag('v3.2.0') }
         | 
| 91 | 
            +
                      end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                      should "push" do
         | 
| 94 | 
            +
                        assert_received(@repo) {|repo| repo.push('origin', 'v3:v3') }
         | 
| 95 | 
            +
                      end
         | 
| 96 | 
            +
                    end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                    context "with an unclean staging area" do
         | 
| 99 | 
            +
                      setup do
         | 
| 100 | 
            +
                        stub(@command).clean_staging_area? { false }
         | 
| 101 | 
            +
                        stub(@command).system
         | 
| 102 | 
            +
                      end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                      should 'raise error' do
         | 
| 105 | 
            +
                        assert_raises RuntimeError, /try commiting/i do
         | 
| 106 | 
            +
                          @command.run
         | 
| 107 | 
            +
                        end
         | 
| 108 | 
            +
                      end
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                      should 'display git status' do
         | 
| 111 | 
            +
                        @command.run rescue nil
         | 
| 112 | 
            +
                        assert_received(@command) {|command| command.system("git status") }
         | 
| 113 | 
            +
                      end
         | 
| 114 | 
            +
                    end
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                    context "with a release already tagged" do
         | 
| 117 | 
            +
                      setup do
         | 
| 118 | 
            +
                        stub(@command).clean_staging_area? { true }
         | 
| 119 | 
            +
             | 
| 120 | 
            +
                        stub(@repo).checkout(anything)
         | 
| 121 | 
            +
             | 
| 122 | 
            +
                        stub(@repo).push
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                        stub(@command).release_not_tagged? { false }
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                        @command.run
         | 
| 127 | 
            +
                      end
         | 
| 128 | 
            +
             | 
| 129 | 
            +
                      should "checkout master" do
         | 
| 130 | 
            +
                        assert_received(@repo) {|repo| repo.checkout('master') }
         | 
| 131 | 
            +
                      end
         | 
| 132 | 
            +
             | 
| 133 | 
            +
                      should "push" do
         | 
| 134 | 
            +
                        assert_received(@repo) {|repo| repo.push('origin', 'master:master') }
         | 
| 135 | 
            +
                      end
         | 
| 136 | 
            +
             | 
| 137 | 
            +
                    end
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                  end
         | 
| 140 | 
            +
             | 
| 141 | 
            +
             | 
| 142 | 
            +
                  build_command_context "building from juwelier" do
         | 
| 143 | 
            +
                    setup do
         | 
| 144 | 
            +
                      @command = Juwelier::Commands::ReleaseToGit.build_for(@juwelier)
         | 
| 145 | 
            +
                    end
         | 
| 146 | 
            +
             | 
| 147 | 
            +
                    should "assign gemspec" do
         | 
| 148 | 
            +
                      assert_same @gemspec, @command.gemspec
         | 
| 149 | 
            +
                    end
         | 
| 150 | 
            +
             | 
| 151 | 
            +
                    should "assign version" do
         | 
| 152 | 
            +
                      assert_same @version, @command.version
         | 
| 153 | 
            +
                    end
         | 
| 154 | 
            +
             | 
| 155 | 
            +
                    should "assign repo" do
         | 
| 156 | 
            +
                      assert_same @repo, @command.repo
         | 
| 157 | 
            +
                    end
         | 
| 158 | 
            +
             | 
| 159 | 
            +
                    should "assign output" do
         | 
| 160 | 
            +
                      assert_same @output, @command.output
         | 
| 161 | 
            +
                    end
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                    should "assign gemspec_helper" do
         | 
| 164 | 
            +
                      assert_same @gemspec_helper, @command.gemspec_helper
         | 
| 165 | 
            +
                    end
         | 
| 166 | 
            +
             | 
| 167 | 
            +
                    should "assign base_dir" do
         | 
| 168 | 
            +
                      assert_same @base_dir, @command.base_dir
         | 
| 169 | 
            +
                    end
         | 
| 170 | 
            +
                  end
         | 
| 171 | 
            +
             | 
| 172 | 
            +
                  # FIXME this code had its ruby-git stuff replaced with `` and system, which is much harder to test, so re-enable these someday
         | 
| 173 | 
            +
                  #context "clean_staging_area?" do
         | 
| 174 | 
            +
             | 
| 175 | 
            +
                  #  should "be false if there added files" do
         | 
| 176 | 
            +
                  #    repo = build_repo :added => %w(README)
         | 
| 177 | 
            +
             | 
| 178 | 
            +
                  #    command = Juwelier::Commands::ReleaseToGit.new :repo => repo
         | 
| 179 | 
            +
             | 
| 180 | 
            +
                  #    assert ! command.clean_staging_area?
         | 
| 181 | 
            +
                  #  end
         | 
| 182 | 
            +
             | 
| 183 | 
            +
                  #  should "be false if there are changed files" do
         | 
| 184 | 
            +
                  #    repo = build_repo :changed => %w(README)
         | 
| 185 | 
            +
             | 
| 186 | 
            +
                  #    command = Juwelier::Commands::ReleaseToGit.new
         | 
| 187 | 
            +
                  #    command.repo = repo
         | 
| 188 | 
            +
             | 
| 189 | 
            +
                  #    assert ! command.clean_staging_area?
         | 
| 190 | 
            +
                  #  end
         | 
| 191 | 
            +
             | 
| 192 | 
            +
                  #  should "be false if there are deleted files" do
         | 
| 193 | 
            +
                  #    repo = build_repo :deleted => %w(README)
         | 
| 194 | 
            +
             | 
| 195 | 
            +
                  #    command = Juwelier::Commands::ReleaseToGit.new
         | 
| 196 | 
            +
                  #    command.repo = repo
         | 
| 197 | 
            +
             | 
| 198 | 
            +
                  #    assert ! command.clean_staging_area?
         | 
| 199 | 
            +
                  #  end
         | 
| 200 | 
            +
             | 
| 201 | 
            +
                  #  should "be true if nothing added, changed, or deleted" do
         | 
| 202 | 
            +
                  #    repo = build_repo
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                  #    command = Juwelier::Commands::ReleaseToGit.new
         | 
| 205 | 
            +
                  #    command.repo = repo
         | 
| 206 | 
            +
             | 
| 207 | 
            +
                  #    assert command.clean_staging_area?
         | 
| 208 | 
            +
                  #  end
         | 
| 209 | 
            +
                  #end
         | 
| 210 | 
            +
             | 
| 211 | 
            +
                  context "release_tagged? when no tag exists" do
         | 
| 212 | 
            +
                    setup do
         | 
| 213 | 
            +
                      @repo = Object.new
         | 
| 214 | 
            +
                      stub(@repo).tag('v1.2.3') { raise Git::GitTagNameDoesNotExist, tag }
         | 
| 215 | 
            +
             | 
| 216 | 
            +
                      @output = StringIO.new
         | 
| 217 | 
            +
             | 
| 218 | 
            +
                      @command                = Juwelier::Commands::ReleaseToGit.new
         | 
| 219 | 
            +
                      @command.output         = @output
         | 
| 220 | 
            +
                      @command.repo           = @repo
         | 
| 221 | 
            +
                      @command.version        = '1.2.3'
         | 
| 222 | 
            +
                    end
         | 
| 223 | 
            +
             | 
| 224 | 
            +
                    should_eventually "be true" do
         | 
| 225 | 
            +
                      assert @command.release_not_tagged?
         | 
| 226 | 
            +
                    end
         | 
| 227 | 
            +
             | 
| 228 | 
            +
                  end
         | 
| 229 | 
            +
             | 
| 230 | 
            +
                  context "release_tagged? when tag exists" do
         | 
| 231 | 
            +
                    setup do
         | 
| 232 | 
            +
                      @repo = Object.new
         | 
| 233 | 
            +
                      stub(@repo) do
         | 
| 234 | 
            +
                        tag('v1.2.3') { Object.new }
         | 
| 235 | 
            +
                      end
         | 
| 236 | 
            +
             | 
| 237 | 
            +
                      @output = StringIO.new
         | 
| 238 | 
            +
             | 
| 239 | 
            +
                      @command                = Juwelier::Commands::ReleaseToGit.new
         | 
| 240 | 
            +
                      @command.output         = @output
         | 
| 241 | 
            +
                      @command.repo           = @repo
         | 
| 242 | 
            +
                      @command.version        = '1.2.3'
         | 
| 243 | 
            +
                    end
         | 
| 244 | 
            +
             | 
| 245 | 
            +
                    should_eventually "be false" do
         | 
| 246 | 
            +
                      assert @command.release_not_tagged?
         | 
| 247 | 
            +
                    end
         | 
| 248 | 
            +
             | 
| 249 | 
            +
                  end
         | 
| 250 | 
            +
             | 
| 251 | 
            +
                  def build_repo(options = {})
         | 
| 252 | 
            +
                    status = build_status options
         | 
| 253 | 
            +
                    repo = Object.new
         | 
| 254 | 
            +
                    stub(repo).status { status }
         | 
| 255 | 
            +
                    repo
         | 
| 256 | 
            +
                  end
         | 
| 257 | 
            +
             | 
| 258 | 
            +
                  def build_status(options = {})
         | 
| 259 | 
            +
                    options = {:added => [], :deleted => [], :changed => []}.merge(options)
         | 
| 260 | 
            +
             | 
| 261 | 
            +
                    status = Object.new
         | 
| 262 | 
            +
                    stub(status) do
         | 
| 263 | 
            +
                      added { options[:added] }
         | 
| 264 | 
            +
                      deleted { options[:deleted] }
         | 
| 265 | 
            +
                      changed { options[:changed] }
         | 
| 266 | 
            +
                    end
         | 
| 267 | 
            +
                    
         | 
| 268 | 
            +
                  end
         | 
| 269 | 
            +
                end
         | 
| 270 | 
            +
              end
         | 
| 271 | 
            +
            end
         |