Sha256: 9af931ebc974d8a3420e2f719ff8a5e333d2f3d0a2e942a9324a782d33205264

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

require 'test_helper'

class Jeweler
  module Commands
    class TestWriteGemspec < Test::Unit::TestCase

      context "after run" do
        setup do
          @gemspec = Gem::Specification.new {|s| s.name = 'zomg' }
          @gemspec_helper = Object.new
          stub(@gemspec_helper).spec { @gemspec }
          stub(@gemspec_helper).path { 'zomg.gemspec' }
          stub(@gemspec_helper).write

          @output = StringIO.new

          @version_helper = Object.new
          stub(@version_helper).to_s  { '1.2.3' }
          stub(@version_helper).refresh

          @command = Jeweler::Commands::WriteGemspec.new
          @command.base_dir = 'tmp'
          @command.version_helper = @version_helper
          @command.gemspec = @gemspec
          @command.output = @output
          @command.gemspec_helper = @gemspec_helper

          @now = Time.now
          stub(Time.now).now { @now }

          @command.run
        end

        should "refresh version" do
          assert_received(@version_helper) {|version_helper| version_helper.refresh }
        end

        should "update gemspec version" do
          assert_equal '1.2.3', @gemspec.version.to_s
        end

        should "update gemspec date to the beginning of today" do
          assert_equal Time.mktime(@now.year, @now.month, @now.day, 0, 0), @gemspec.date
        end

        should "write gemspec" do
          assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.write }
        end

        should_eventually "output that the gemspec was written" do
          assert_equal @output.string, "Generated: tmp/zomg.gemspec"
        end

      end

    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
dima-jeweler-0.9.2 test/jeweler/commands/test_write_gemspec.rb
technicalpickles-jeweler-0.9.0 test/jeweler/commands/test_write_gemspec.rb
technicalpickles-jeweler-0.9.1 test/jeweler/commands/test_write_gemspec.rb