update test, between tags.

This commit is contained in:
Petr Korolev 2015-06-10 10:14:55 +03:00
parent 160cda50bc
commit c3867a89f1
2 changed files with 23 additions and 10 deletions

View File

@ -49,7 +49,7 @@ module GitHubChangelogGenerator
puts "Warning: can't find tag #{tag}, specified with --between-tags option.".yellow
end
end
filtered_tags = all_tags.select { |tag| @options[:between_tags].include? tag }
filtered_tags = all_tags.select { |tag| @options[:between_tags].include? tag.name }
end
filtered_tags
end

View File

@ -6,20 +6,20 @@ describe GitHubChangelogGenerator::Generator do
end
subject do
@generator.get_filtered_tags(%w(1 2 3))
@generator.get_filtered_tags(tags_mash_from_strings(%w(1 2 3)))
end
it { is_expected.to be_a(Array) }
it { is_expected.to match_array(%w(1 2 3)) }
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
end
context "when between_tags same as input array" do
before do
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2 3))
end
subject do
@generator.get_filtered_tags(%w(1 2 3))
@generator.get_filtered_tags(tags_mash_from_strings(%w(1 2 3)))
end
it { is_expected.to be_a(Array) }
it { is_expected.to match_array(%w(1 2 3)) }
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
end
context "when between_tags filled with correct values" do
@ -27,10 +27,10 @@ describe GitHubChangelogGenerator::Generator do
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2))
end
subject do
@generator.get_filtered_tags(%w(1 2 3))
@generator.get_filtered_tags(tags_mash_from_strings(%w(1 2 3)))
end
it { is_expected.to be_a(Array) }
it { is_expected.to match_array(%w(1 2)) }
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2))) }
end
context "when between_tags filled with invalid values" do
@ -39,15 +39,28 @@ describe GitHubChangelogGenerator::Generator do
end
subject do
@generator.get_filtered_tags(%w(1 2 3))
@generator.get_filtered_tags(tags_mash_from_strings(%w(1 2 3)))
end
it { is_expected.to be_a(Array) }
it { is_expected.to match_array(%w(1)) }
it { is_expected.to match_array(tags_mash_from_strings(%w(1))) }
end
end
def tags_mash_from_strings(tags_strings)
mash_array = []
tags_strings.each do |tag|
mash_tag = Hashie::Mash.new
mash_tag.name = tag
mash_array << mash_tag
end
mash_array
end
describe "#get_filtered_tags" do
subject { generator.get_filtered_tags(%w(1 2 3 4 5)) }
subject do
tags_mash = tags_mash_from_strings(%w(1 2 3 4 5))
generator.get_filtered_tags(tags_mash)
end
# before { generator.get_filtered_tags(%w(1 2 3 4 5)) }
context "with excluded and between tags" do