diff options
Diffstat (limited to 'spec/lib/gitlab/danger')
-rw-r--r-- | spec/lib/gitlab/danger/changelog_spec.rb | 18 | ||||
-rw-r--r-- | spec/lib/gitlab/danger/commit_linter_spec.rb | 1 | ||||
-rw-r--r-- | spec/lib/gitlab/danger/helper_spec.rb | 40 | ||||
-rw-r--r-- | spec/lib/gitlab/danger/roulette_spec.rb | 233 | ||||
-rw-r--r-- | spec/lib/gitlab/danger/teammate_spec.rb | 53 |
5 files changed, 210 insertions, 135 deletions
diff --git a/spec/lib/gitlab/danger/changelog_spec.rb b/spec/lib/gitlab/danger/changelog_spec.rb index f5954cd8c1e..3c67e9ca8ea 100644 --- a/spec/lib/gitlab/danger/changelog_spec.rb +++ b/spec/lib/gitlab/danger/changelog_spec.rb @@ -57,6 +57,24 @@ RSpec.describe Gitlab::Danger::Changelog do is_expected.to be_truthy end end + + context 'when MR contains a category that require changelog and a category that require no changelog with changelog label' do + let(:changes_by_category) { { category_with_changelog => nil, category_without_changelog => nil } } + let(:mr_labels) { ['feature'] } + + it 'is truthy' do + is_expected.to be_truthy + end + end + + context 'when MR contains a category that require changelog and a category that require no changelog with no changelog label' do + let(:changes_by_category) { { category_with_changelog => nil, category_without_changelog => nil } } + let(:mr_labels) { ['tooling'] } + + it 'is truthy' do + is_expected.to be_falsey + end + end end describe '#found' do diff --git a/spec/lib/gitlab/danger/commit_linter_spec.rb b/spec/lib/gitlab/danger/commit_linter_spec.rb index 06bec6f793d..c31522c538d 100644 --- a/spec/lib/gitlab/danger/commit_linter_spec.rb +++ b/spec/lib/gitlab/danger/commit_linter_spec.rb @@ -16,6 +16,7 @@ RSpec.describe Gitlab::Danger::CommitLinter do let(:commit_class) do Struct.new(:message, :sha, :diff_parent) end + let(:commit_message) { 'A commit message' } let(:commit_sha) { 'abcd1234' } let(:commit) { commit_class.new(commit_message, commit_sha, diff_parent) } diff --git a/spec/lib/gitlab/danger/helper_spec.rb b/spec/lib/gitlab/danger/helper_spec.rb index e73742b5911..e5018e46634 100644 --- a/spec/lib/gitlab/danger/helper_spec.rb +++ b/spec/lib/gitlab/danger/helper_spec.rb @@ -76,6 +76,14 @@ RSpec.describe Gitlab::Danger::Helper do end end + describe "changed_files" do + it 'returns list of changed files matching given regex' do + expect(helper).to receive(:all_changed_files).and_return(%w[migration.rb usage_data.rb]) + + expect(helper.changed_files(/usage_data/)).to contain_exactly('usage_data.rb') + end + end + describe '#all_ee_changes' do subject { helper.all_ee_changes } @@ -98,21 +106,21 @@ RSpec.describe Gitlab::Danger::Helper do it 'delegates to CHANGELOG-EE.md existence if CI_PROJECT_NAME is set to something else' do stub_env('CI_PROJECT_NAME', 'something else') - expect(Dir).to receive(:exist?).with('../../ee') { true } + expect(Dir).to receive(:exist?).with(File.expand_path('../../../../ee', __dir__)) { true } is_expected.to be_truthy end it 'returns true if ee exists' do stub_env('CI_PROJECT_NAME', nil) - expect(Dir).to receive(:exist?).with('../../ee') { true } + expect(Dir).to receive(:exist?).with(File.expand_path('../../../../ee', __dir__)) { true } is_expected.to be_truthy end it "returns false if ee doesn't exist" do stub_env('CI_PROJECT_NAME', nil) - expect(Dir).to receive(:exist?).with('../../ee') { false } + expect(Dir).to receive(:exist?).with(File.expand_path('../../../../ee', __dir__)) { false } is_expected.to be_falsy end @@ -217,9 +225,17 @@ RSpec.describe Gitlab::Danger::Helper do 'ee/spec/foo' | [:backend] 'ee/spec/foo/bar' | [:backend] + 'spec/features/foo' | [:test] + 'ee/spec/features/foo' | [:test] + 'spec/support/shared_examples/features/foo' | [:test] + 'ee/spec/support/shared_examples/features/foo' | [:test] + 'spec/support/shared_contexts/features/foo' | [:test] + 'ee/spec/support/shared_contexts/features/foo' | [:test] + 'spec/support/helpers/features/foo' | [:test] + 'ee/spec/support/helpers/features/foo' | [:test] + 'generator_templates/foo' | [:backend] 'vendor/languages.yml' | [:backend] - 'vendor/licenses.csv' | [:backend] 'file_hooks/examples/' | [:backend] 'Gemfile' | [:backend] @@ -242,6 +258,7 @@ RSpec.describe Gitlab::Danger::Helper do '.editorconfig' | [:engineering_productivity] 'tooling/overcommit/foo' | [:engineering_productivity] '.codeclimate.yml' | [:engineering_productivity] + '.gitlab/CODEOWNERS' | [:engineering_productivity] 'lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml' | [:backend] @@ -295,9 +312,13 @@ RSpec.describe Gitlab::Danger::Helper do context 'having specific changes' do it 'has database and backend categories' do - allow(fake_git).to receive(:diff_for_file).with('usage_data.rb') { double(:diff, patch: "+ count(User.active)") } + changed_files = ['usage_data.rb', 'lib/gitlab/usage_data.rb', 'ee/lib/ee/gitlab/usage_data.rb'] - expect(helper.categories_for_file('usage_data.rb')).to eq([:database, :backend]) + changed_files.each do |file| + allow(fake_git).to receive(:diff_for_file).with(file) { double(:diff, patch: "+ count(User.active)") } + + expect(helper.categories_for_file(file)).to eq([:database, :backend]) + end end it 'has backend category' do @@ -311,6 +332,13 @@ RSpec.describe Gitlab::Danger::Helper do expect(helper.categories_for_file('user.rb')).to eq([:backend]) end + + it 'has backend category for files that are not usage_data.rb' do + changed_file = 'usage_data/topology.rb' + allow(fake_git).to receive(:diff_for_file).with(changed_file) { double(:diff, patch: "+ count(User.active)") } + + expect(helper.categories_for_file(changed_file)).to eq([:backend]) + end end end diff --git a/spec/lib/gitlab/danger/roulette_spec.rb b/spec/lib/gitlab/danger/roulette_spec.rb index 676edca2459..b471e17e2e7 100644 --- a/spec/lib/gitlab/danger/roulette_spec.rb +++ b/spec/lib/gitlab/danger/roulette_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require 'fast_spec_helper' require 'webmock/rspec' require 'timecop' @@ -11,102 +10,99 @@ RSpec.describe Gitlab::Danger::Roulette do Timecop.freeze(Time.utc(2020, 06, 22, 10)) { example.run } end + let(:backend_available) { true } + let(:backend_tz_offset_hours) { 2.0 } let(:backend_maintainer) do - { - username: 'backend-maintainer', - name: 'Backend maintainer', - role: 'Backend engineer', - projects: { 'gitlab' => 'maintainer backend' }, - available: true, - tz_offset_hours: 2.0 - } + Gitlab::Danger::Teammate.new( + 'username' => 'backend-maintainer', + 'name' => 'Backend maintainer', + 'role' => 'Backend engineer', + 'projects' => { 'gitlab' => 'maintainer backend' }, + 'available' => backend_available, + 'tz_offset_hours' => backend_tz_offset_hours + ) end + let(:frontend_reviewer) do - { - username: 'frontend-reviewer', - name: 'Frontend reviewer', - role: 'Frontend engineer', - projects: { 'gitlab' => 'reviewer frontend' }, - available: true, - tz_offset_hours: 2.0 - } + Gitlab::Danger::Teammate.new( + 'username' => 'frontend-reviewer', + 'name' => 'Frontend reviewer', + 'role' => 'Frontend engineer', + 'projects' => { 'gitlab' => 'reviewer frontend' }, + 'available' => true, + 'tz_offset_hours' => 2.0 + ) end + let(:frontend_maintainer) do - { - username: 'frontend-maintainer', - name: 'Frontend maintainer', - role: 'Frontend engineer', - projects: { 'gitlab' => "maintainer frontend" }, - available: true, - tz_offset_hours: 2.0 - } + Gitlab::Danger::Teammate.new( + 'username' => 'frontend-maintainer', + 'name' => 'Frontend maintainer', + 'role' => 'Frontend engineer', + 'projects' => { 'gitlab' => "maintainer frontend" }, + 'available' => true, + 'tz_offset_hours' => 2.0 + ) end + let(:software_engineer_in_test) do - { - username: 'software-engineer-in-test', - name: 'Software Engineer in Test', - role: 'Software Engineer in Test, Create:Source Code', - projects: { - 'gitlab' => 'reviewer qa', - 'gitlab-qa' => 'maintainer' - }, - available: true, - tz_offset_hours: 2.0 - } + Gitlab::Danger::Teammate.new( + 'username' => 'software-engineer-in-test', + 'name' => 'Software Engineer in Test', + 'role' => 'Software Engineer in Test, Create:Source Code', + 'projects' => { 'gitlab' => 'reviewer qa', 'gitlab-qa' => 'maintainer' }, + 'available' => true, + 'tz_offset_hours' => 2.0 + ) end + let(:engineering_productivity_reviewer) do - { - username: 'eng-prod-reviewer', - name: 'EP engineer', - role: 'Engineering Productivity', - projects: { 'gitlab' => 'reviewer backend' }, - available: true, - tz_offset_hours: 2.0 - } + Gitlab::Danger::Teammate.new( + 'username' => 'eng-prod-reviewer', + 'name' => 'EP engineer', + 'role' => 'Engineering Productivity', + 'projects' => { 'gitlab' => 'reviewer backend' }, + 'available' => true, + 'tz_offset_hours' => 2.0 + ) end let(:teammate_json) do [ - backend_maintainer, - frontend_maintainer, - frontend_reviewer, - software_engineer_in_test, - engineering_productivity_reviewer + backend_maintainer.to_h, + frontend_maintainer.to_h, + frontend_reviewer.to_h, + software_engineer_in_test.to_h, + engineering_productivity_reviewer.to_h ].to_json end subject(:roulette) { Object.new.extend(described_class) } - def matching_teammate(person) - satisfy do |teammate| - teammate.username == person[:username] && - teammate.name == person[:name] && - teammate.role == person[:role] && - teammate.projects == person[:projects] - end - end - - def matching_spin(category, reviewer: { username: nil }, maintainer: { username: nil }, optional: nil) - satisfy do |spin| - bool = spin.category == category - bool &&= spin.reviewer&.username == reviewer[:username] - - bool &&= - if maintainer - spin.maintainer&.username == maintainer[:username] - else - spin.maintainer.nil? - end - - bool && spin.optional_role == optional + describe 'Spin#==' do + it 'compares Spin attributes' do + spin1 = described_class::Spin.new(:backend, frontend_reviewer, frontend_maintainer, false, false) + spin2 = described_class::Spin.new(:backend, frontend_reviewer, frontend_maintainer, false, false) + spin3 = described_class::Spin.new(:backend, frontend_reviewer, frontend_maintainer, false, true) + spin4 = described_class::Spin.new(:backend, frontend_reviewer, frontend_maintainer, true, false) + spin5 = described_class::Spin.new(:backend, frontend_reviewer, backend_maintainer, false, false) + spin6 = described_class::Spin.new(:backend, backend_maintainer, frontend_maintainer, false, false) + spin7 = described_class::Spin.new(:frontend, frontend_reviewer, frontend_maintainer, false, false) + + expect(spin1).to eq(spin2) + expect(spin1).not_to eq(spin3) + expect(spin1).not_to eq(spin4) + expect(spin1).not_to eq(spin5) + expect(spin1).not_to eq(spin6) + expect(spin1).not_to eq(spin7) end end describe '#spin' do let!(:project) { 'gitlab' } - let!(:branch_name) { 'a-branch' } + let!(:mr_source_branch) { 'a-branch' } let!(:mr_labels) { ['backend', 'devops::create'] } - let!(:author) { Gitlab::Danger::Teammate.new('username' => 'filipa') } + let!(:author) { Gitlab::Danger::Teammate.new('username' => 'johndoe') } let(:timezone_experiment) { false } let(:spins) do # Stub the request at the latest time so that we can modify the raw data, e.g. available fields. @@ -114,12 +110,13 @@ RSpec.describe Gitlab::Danger::Roulette do .stub_request(:get, described_class::ROULETTE_DATA_URL) .to_return(body: teammate_json) - subject.spin(project, categories, branch_name, timezone_experiment: timezone_experiment) + subject.spin(project, categories, timezone_experiment: timezone_experiment) end before do - allow(subject).to receive_message_chain(:gitlab, :mr_author).and_return(author.username) - allow(subject).to receive_message_chain(:gitlab, :mr_labels).and_return(mr_labels) + allow(subject).to receive(:mr_author_username).and_return(author.username) + allow(subject).to receive(:mr_labels).and_return(mr_labels) + allow(subject).to receive(:mr_source_branch).and_return(mr_source_branch) end context 'when timezone_experiment == false' do @@ -127,16 +124,16 @@ RSpec.describe Gitlab::Danger::Roulette do let(:categories) { [:backend] } it 'assigns backend reviewer and maintainer' do - expect(spins).to contain_exactly(matching_spin(:backend, reviewer: engineering_productivity_reviewer, maintainer: backend_maintainer)) + expect(spins[0].reviewer).to eq(engineering_productivity_reviewer) + expect(spins[0].maintainer).to eq(backend_maintainer) + expect(spins).to eq([described_class::Spin.new(:backend, engineering_productivity_reviewer, backend_maintainer, false, false)]) end context 'when teammate is not available' do - before do - backend_maintainer[:available] = false - end + let(:backend_available) { false } it 'assigns backend reviewer and no maintainer' do - expect(spins).to contain_exactly(matching_spin(:backend, reviewer: engineering_productivity_reviewer, maintainer: nil)) + expect(spins).to eq([described_class::Spin.new(:backend, engineering_productivity_reviewer, nil, false, false)]) end end end @@ -145,7 +142,7 @@ RSpec.describe Gitlab::Danger::Roulette do let(:categories) { [:frontend] } it 'assigns frontend reviewer and maintainer' do - expect(spins).to contain_exactly(matching_spin(:frontend, reviewer: frontend_reviewer, maintainer: frontend_maintainer)) + expect(spins).to eq([described_class::Spin.new(:frontend, frontend_reviewer, frontend_maintainer, false, false)]) end end @@ -153,7 +150,7 @@ RSpec.describe Gitlab::Danger::Roulette do let(:categories) { [:qa] } it 'assigns QA reviewer' do - expect(spins).to contain_exactly(matching_spin(:qa, reviewer: software_engineer_in_test)) + expect(spins).to eq([described_class::Spin.new(:qa, software_engineer_in_test, nil, false, false)]) end end @@ -161,7 +158,7 @@ RSpec.describe Gitlab::Danger::Roulette do let(:categories) { [:engineering_productivity] } it 'assigns Engineering Productivity reviewer and fallback to backend maintainer' do - expect(spins).to contain_exactly(matching_spin(:engineering_productivity, reviewer: engineering_productivity_reviewer, maintainer: backend_maintainer)) + expect(spins).to eq([described_class::Spin.new(:engineering_productivity, engineering_productivity_reviewer, backend_maintainer, false, false)]) end end @@ -169,7 +166,7 @@ RSpec.describe Gitlab::Danger::Roulette do let(:categories) { [:test] } it 'assigns corresponding SET' do - expect(spins).to contain_exactly(matching_spin(:test, reviewer: software_engineer_in_test)) + expect(spins).to eq([described_class::Spin.new(:test, software_engineer_in_test, nil, :maintainer, false)]) end end end @@ -181,16 +178,14 @@ RSpec.describe Gitlab::Danger::Roulette do let(:categories) { [:backend] } it 'assigns backend reviewer and maintainer' do - expect(spins).to contain_exactly(matching_spin(:backend, reviewer: engineering_productivity_reviewer, maintainer: backend_maintainer)) + expect(spins).to eq([described_class::Spin.new(:backend, engineering_productivity_reviewer, backend_maintainer, false, true)]) end context 'when teammate is not in a good timezone' do - before do - backend_maintainer[:tz_offset_hours] = 5.0 - end + let(:backend_tz_offset_hours) { 5.0 } it 'assigns backend reviewer and no maintainer' do - expect(spins).to contain_exactly(matching_spin(:backend, reviewer: engineering_productivity_reviewer, maintainer: nil)) + expect(spins).to eq([described_class::Spin.new(:backend, engineering_productivity_reviewer, nil, false, true)]) end end end @@ -203,22 +198,33 @@ RSpec.describe Gitlab::Danger::Roulette do end it 'assigns backend reviewer and maintainer' do - expect(spins).to contain_exactly(matching_spin(:backend, reviewer: engineering_productivity_reviewer, maintainer: backend_maintainer)) + expect(spins).to eq([described_class::Spin.new(:backend, engineering_productivity_reviewer, backend_maintainer, false, false)]) end context 'when teammate is not in a good timezone' do - before do - backend_maintainer[:tz_offset_hours] = 5.0 - end + let(:backend_tz_offset_hours) { 5.0 } it 'assigns backend reviewer and maintainer' do - expect(spins).to contain_exactly(matching_spin(:backend, reviewer: engineering_productivity_reviewer, maintainer: backend_maintainer)) + expect(spins).to eq([described_class::Spin.new(:backend, engineering_productivity_reviewer, backend_maintainer, false, false)]) end end end end end + RSpec::Matchers.define :match_teammates do |expected| + match do |actual| + expected.each do |expected_person| + actual_person_found = actual.find { |actual_person| actual_person.name == expected_person.username } + + actual_person_found && + actual_person_found.name == expected_person.name && + actual_person_found.role == expected_person.role && + actual_person_found.projects == expected_person.projects + end + end + end + describe '#team' do subject(:team) { roulette.team } @@ -254,15 +260,13 @@ RSpec.describe Gitlab::Danger::Roulette do end it 'returns an array of teammates' do - expected_teammates = [ - matching_teammate(backend_maintainer), - matching_teammate(frontend_reviewer), - matching_teammate(frontend_maintainer), - matching_teammate(software_engineer_in_test), - matching_teammate(engineering_productivity_reviewer) - ] - - is_expected.to contain_exactly(*expected_teammates) + is_expected.to match_teammates([ + backend_maintainer, + frontend_reviewer, + frontend_maintainer, + software_engineer_in_test, + engineering_productivity_reviewer + ]) end it 'memoizes the result' do @@ -281,7 +285,9 @@ RSpec.describe Gitlab::Danger::Roulette do end it 'filters team by project_name' do - is_expected.to contain_exactly(matching_teammate(software_engineer_in_test)) + is_expected.to match_teammates([ + software_engineer_in_test + ]) end end @@ -289,32 +295,35 @@ RSpec.describe Gitlab::Danger::Roulette do let(:person_tz_offset_hours) { 0.0 } let(:person1) do Gitlab::Danger::Teammate.new( - 'username' => 'rymai', + 'username' => 'user1', 'available' => true, 'tz_offset_hours' => person_tz_offset_hours ) end + let(:person2) do Gitlab::Danger::Teammate.new( - 'username' => 'godfat', + 'username' => 'user2', 'available' => true, 'tz_offset_hours' => person_tz_offset_hours) end + let(:author) do Gitlab::Danger::Teammate.new( - 'username' => 'filipa', + 'username' => 'johndoe', 'available' => true, 'tz_offset_hours' => 0.0) end + let(:unavailable) do Gitlab::Danger::Teammate.new( - 'username' => 'jacopo-beschi', + 'username' => 'janedoe', 'available' => false, 'tz_offset_hours' => 0.0) end before do - allow(subject).to receive_message_chain(:gitlab, :mr_author).and_return(author.username) + allow(subject).to receive(:mr_author_username).and_return(author.username) end (-4..4).each do |utc_offset| @@ -328,7 +337,7 @@ RSpec.describe Gitlab::Danger::Roulette do selected = subject.spin_for_person(persons, random: Random.new, timezone_experiment: timezone_experiment) - expect(selected.username).to be_in(persons.map(&:username)) + expect(persons.map(&:username)).to include(selected.username) end end end @@ -349,7 +358,7 @@ RSpec.describe Gitlab::Danger::Roulette do if timezone_experiment expect(selected).to be_nil else - expect(selected.username).to be_in(persons.map(&:username)) + expect(persons.map(&:username)).to include(selected.username) end end end diff --git a/spec/lib/gitlab/danger/teammate_spec.rb b/spec/lib/gitlab/danger/teammate_spec.rb index a0540a9fbf5..12819614fab 100644 --- a/spec/lib/gitlab/danger/teammate_spec.rb +++ b/spec/lib/gitlab/danger/teammate_spec.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'fast_spec_helper' - require 'timecop' require 'rspec-parameterized' @@ -10,24 +8,45 @@ require 'gitlab/danger/teammate' RSpec.describe Gitlab::Danger::Teammate do using RSpec::Parameterized::TableSyntax - subject { described_class.new(options.stringify_keys) } + subject { described_class.new(options) } let(:tz_offset_hours) { 2.0 } let(:options) do { - username: 'luigi', - projects: projects, - role: role, - markdown_name: '[Luigi](https://gitlab.com/luigi) (`@luigi`)', - tz_offset_hours: tz_offset_hours + 'username' => 'luigi', + 'projects' => projects, + 'role' => role, + 'markdown_name' => '[Luigi](https://gitlab.com/luigi) (`@luigi`)', + 'tz_offset_hours' => tz_offset_hours } end + let(:capabilities) { ['reviewer backend'] } let(:projects) { { project => capabilities } } let(:role) { 'Engineer, Manage' } let(:labels) { [] } let(:project) { double } + describe '#==' do + it 'compares Teammate username' do + joe1 = described_class.new('username' => 'joe', 'projects' => projects) + joe2 = described_class.new('username' => 'joe', 'projects' => []) + jane1 = described_class.new('username' => 'jane', 'projects' => projects) + jane2 = described_class.new('username' => 'jane', 'projects' => []) + + expect(joe1).to eq(joe2) + expect(jane1).to eq(jane2) + expect(jane1).not_to eq(nil) + expect(described_class.new('username' => nil)).not_to eq(nil) + end + end + + describe '#to_h' do + it 'returns the given options' do + expect(subject.to_h).to eq(options) + end + end + context 'when having multiple capabilities' do let(:capabilities) { ['reviewer backend', 'maintainer frontend', 'trainee_maintainer qa'] } @@ -153,44 +172,44 @@ RSpec.describe Gitlab::Danger::Teammate do describe '#markdown_name' do context 'when timezone_experiment == false' do it 'returns markdown name as-is' do - expect(subject.markdown_name).to eq(options[:markdown_name]) - expect(subject.markdown_name(timezone_experiment: false)).to eq(options[:markdown_name]) + expect(subject.markdown_name).to eq(options['markdown_name']) + expect(subject.markdown_name(timezone_experiment: false)).to eq(options['markdown_name']) end end context 'when timezone_experiment == true' do it 'returns markdown name with timezone info' do - expect(subject.markdown_name(timezone_experiment: true)).to eq("#{options[:markdown_name]} (UTC+2)") + expect(subject.markdown_name(timezone_experiment: true)).to eq("#{options['markdown_name']} (UTC+2)") end context 'when offset is 1.5' do let(:tz_offset_hours) { 1.5 } it 'returns markdown name with timezone info, not truncated' do - expect(subject.markdown_name(timezone_experiment: true)).to eq("#{options[:markdown_name]} (UTC+1.5)") + expect(subject.markdown_name(timezone_experiment: true)).to eq("#{options['markdown_name']} (UTC+1.5)") end end context 'when author is given' do where(:tz_offset_hours, :author_offset, :diff_text) do -12 | -10 | "2 hours behind `@mario`" - -10 | -12 | "2 hours ahead `@mario`" + -10 | -12 | "2 hours ahead of `@mario`" -10 | 2 | "12 hours behind `@mario`" 2 | 4 | "2 hours behind `@mario`" - 4 | 2 | "2 hours ahead `@mario`" + 4 | 2 | "2 hours ahead of `@mario`" 2 | 3 | "1 hour behind `@mario`" - 3 | 2 | "1 hour ahead `@mario`" + 3 | 2 | "1 hour ahead of `@mario`" 2 | 2 | "same timezone as `@mario`" end with_them do it 'returns markdown name with timezone info' do - author = described_class.new(options.merge(username: 'mario', tz_offset_hours: author_offset).stringify_keys) + author = described_class.new(options.merge('username' => 'mario', 'tz_offset_hours' => author_offset)) floored_offset_hours = subject.__send__(:floored_offset_hours) utc_offset = floored_offset_hours >= 0 ? "+#{floored_offset_hours}" : floored_offset_hours - expect(subject.markdown_name(timezone_experiment: true, author: author)).to eq("#{options[:markdown_name]} (UTC#{utc_offset}, #{diff_text})") + expect(subject.markdown_name(timezone_experiment: true, author: author)).to eq("#{options['markdown_name']} (UTC#{utc_offset}, #{diff_text})") end end end |