From 957fa0d3a3392247b9d63f735da8f07f9115150b Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 26 May 2015 15:19:24 +0300 Subject: [PATCH] refuct --- spec/unit/generator/generator_tags_spec.rb | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/spec/unit/generator/generator_tags_spec.rb b/spec/unit/generator/generator_tags_spec.rb index ebcd866..5e6b442 100644 --- a/spec/unit/generator/generator_tags_spec.rb +++ b/spec/unit/generator/generator_tags_spec.rb @@ -1,21 +1,21 @@ describe GitHubChangelogGenerator::Generator do describe "#get_filtered_tags" do - before(:all) do - @generator = GitHubChangelogGenerator::Generator.new - end - context "when between_tags nil" do + before do + @generator = GitHubChangelogGenerator::Generator.new(between_tags: nil) + end + subject do - @generator.instance_variable_set("@options", between_tags: nil) @generator.get_filtered_tags(%w(1 2 3)) end it { is_expected.to be_a(Array) } it { is_expected.to match_array(%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.instance_variable_set("@options", between_tags: %w(1 2 3)) @generator.get_filtered_tags(%w(1 2 3)) end it { is_expected.to be_a(Array) } @@ -23,16 +23,22 @@ describe GitHubChangelogGenerator::Generator do end context "when between_tags filled with correct values" do + before do + @generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2)) + end subject do - @generator.instance_variable_set("@options", between_tags: %w(1 2)) @generator.get_filtered_tags(%w(1 2 3)) end it { is_expected.to be_a(Array) } it { is_expected.to match_array(%w(1 2)) } end + context "when between_tags filled with invalid values" do + before do + @generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 q w)) + end + subject do - @generator.instance_variable_set("@options", between_tags: %w(1 q w)) @generator.get_filtered_tags(%w(1 2 3)) end it { is_expected.to be_a(Array) }