add tests
This commit is contained in:
		
							parent
							
								
									b9e7463c3e
								
							
						
					
					
						commit
						6f82741154
					
				@ -15,7 +15,7 @@ module GitHubChangelogGenerator
 | 
			
		||||
    "This script can make only 50 requests to GitHub API per hour without token!"
 | 
			
		||||
 | 
			
		||||
    def initialize(options = {})
 | 
			
		||||
      @options = options
 | 
			
		||||
      @options = options || {}
 | 
			
		||||
 | 
			
		||||
      @logger = Logger.new(STDOUT)
 | 
			
		||||
      @logger.formatter = proc do |_severity, _datetime, _progname, msg|
 | 
			
		||||
@ -28,8 +28,8 @@ module GitHubChangelogGenerator
 | 
			
		||||
      @tag_times_hash = {}
 | 
			
		||||
      github_options = { per_page: PER_PAGE_NUMBER }
 | 
			
		||||
      github_options[:oauth_token] = @github_token unless @github_token.nil?
 | 
			
		||||
      github_options[:endpoint] = options[:github_endpoint] unless options[:github_endpoint].nil?
 | 
			
		||||
      github_options[:site] = options[:github_endpoint] unless options[:github_site].nil?
 | 
			
		||||
      github_options[:endpoint] = @options[:github_endpoint] unless @options[:github_endpoint].nil?
 | 
			
		||||
      github_options[:site] = @options[:github_endpoint] unless @options[:github_site].nil?
 | 
			
		||||
 | 
			
		||||
      @github = check_github_response { Github.new github_options }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -18,13 +18,9 @@ module GitHubChangelogGenerator
 | 
			
		||||
    #   generator = GitHubChangelogGenerator::Generator.new
 | 
			
		||||
    #   content = generator.compound_changelog
 | 
			
		||||
    def initialize(options = nil)
 | 
			
		||||
      @options = options
 | 
			
		||||
      @options = options || {}
 | 
			
		||||
 | 
			
		||||
      @fetcher = GitHubChangelogGenerator::Fetcher.new @options
 | 
			
		||||
 | 
			
		||||
      fetch_and_filter_tags
 | 
			
		||||
 | 
			
		||||
      fetch_issues_and_pr
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def fetch_issues_and_pr
 | 
			
		||||
 | 
			
		||||
@ -4,6 +4,9 @@ module GitHubChangelogGenerator
 | 
			
		||||
    #
 | 
			
		||||
    # @return [String] Generated change log file
 | 
			
		||||
    def compound_changelog
 | 
			
		||||
      fetch_and_filter_tags
 | 
			
		||||
      fetch_issues_and_pr
 | 
			
		||||
 | 
			
		||||
      log = "# Change Log\n\n"
 | 
			
		||||
 | 
			
		||||
      if @options[:unreleased_only]
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										29
									
								
								spec/unit/generator/generator_tags_spec.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								spec/unit/generator/generator_tags_spec.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,29 @@
 | 
			
		||||
describe GitHubChangelogGenerator::Generator do
 | 
			
		||||
  describe "#get_filtered_tags" do
 | 
			
		||||
    before(:all) do
 | 
			
		||||
      @generator = GitHubChangelogGenerator::Generator.new
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context "when between_tags nil" do
 | 
			
		||||
      # before(:each) do
 | 
			
		||||
      #   @generator.options = {}
 | 
			
		||||
      # end
 | 
			
		||||
      subject { @generator.get_filtered_tags(%w(1 2 3)) }
 | 
			
		||||
      it { is_expected.to be_a(Array) }
 | 
			
		||||
      it { is_expected.to match_array(%w(1 2 3)) }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context "when between_tags 1" do
 | 
			
		||||
      # before(:each) do
 | 
			
		||||
      #   @generator.options = {between_tags: ["1"]}
 | 
			
		||||
      # end
 | 
			
		||||
 | 
			
		||||
      subject do
 | 
			
		||||
        @generator.instance_variable_set("@options", between_tags: ["1"])
 | 
			
		||||
        @generator.get_filtered_tags(%w(1 2 3))
 | 
			
		||||
      end
 | 
			
		||||
      it { is_expected.to be_a(Array) }
 | 
			
		||||
      it { is_expected.to match_array(%w(1)) }
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user