diff --git a/features/features/report/diff_spec.rb b/features/features/report/diff_spec.rb index 315db4056..63629f5af 100644 --- a/features/features/report/diff_spec.rb +++ b/features/features/report/diff_spec.rb @@ -166,12 +166,12 @@ diff = IO.read(project.project_dir.join('diff.csv')) expect(diff).to include("unchanged,bar,2.0.0,GPLv2,#{project1.project_dir}") - expect(diff).to include("removed,foo,1.0.0,MIT,\"#{project1.project_dir},#{project2.project_dir}\"") - expect(diff).to include("added,foo,2.0.0,BSD,\"#{project1.project_dir},#{project2.project_dir}\"") + expect(diff).to include("unchanged,foo,1.0.0,MIT,#{project2.project_dir}") + expect(diff).to include("added,foo,2.0.0,BSD,#{project1.project_dir}") expect(diff).to include("added,baz,3.0.0,BSD,#{project2.project_dir}") end - xspecify 'show licenses change when files do not contain exact copies of a dep' do + specify 'show licenses change when files do not contain exact copies of a dep' do project = developer.create_empty_project # First multi-project report project1 = developer.create_ruby_app('project_1') @@ -193,10 +193,7 @@ diff = IO.read(project.project_dir.join('diff.csv')) expect(diff).to include("removed,foo,1.0.0,MIT,#{project1.project_dir}") - # expect(diff).to include("removed,foo,,2.0.0,BSD,#{project2.project_dir}") - expect(diff).to include("added,foo,2.0.0,BSD,\"#{project1.project_dir},#{project2.project_dir}\"") - expect(diff).to include("removed,foo,1.0.0,BSD,\"#{project1.project_dir},#{project2.project_dir}\"") - + expect(diff).to include("unchanged,foo,2.0.0,BSD,\"#{project1.project_dir},#{project2.project_dir}\"") expect(diff).to include("unchanged,bar,2.0.0,GPLv2,#{project1.project_dir}") expect(diff).to include("added,baz,3.0.0,BSD,#{project2.project_dir}") end diff --git a/features/support/testing_dsl.rb b/features/support/testing_dsl.rb index e07d64aef..3a7aa9a95 100644 --- a/features/support/testing_dsl.rb +++ b/features/support/testing_dsl.rb @@ -74,7 +74,7 @@ def execute_command_in_path(command, path) require 'forwardable' class Project extend Forwardable - def_delegators :project_dir, :shell_out, :add_to_file, :install_fixture + def_delegators :project_dir, :shell_out, :add_to_file, :remove_lines_with_value, :install_fixture attr_reader :name @@ -499,9 +499,14 @@ def depend_on(gem, bundler_options = {}) private def add_gem_to_gemfile(gem_name, options) + remove_older_gem_from_gemfile(gem_name) add_to_gemfile("gem #{gem_name.inspect}, #{options.inspect}") end + def remove_older_gem_from_gemfile(gem_name) + remove_lines_with_value('Gemfile', gem_name) + end + def add_to_gemfile(content) add_to_file('Gemfile', content) end @@ -533,7 +538,7 @@ def add_to_gemfile(content) # lives adjacent to a BundlerProject, so has a different lifecycle from other Projects and doesn't inherit class GemProject def self.create(name, options) - result = new(name) + result = new(name, options[:version]) result.define(options) result end @@ -544,23 +549,24 @@ def self.create_in_path(name, path, options) result end - def initialize(name, path = nil) + def initialize(name, version = nil, path = nil) @name = name @path = path + @file_name = version.nil? ? name : "#{name}-#{version}" project_dir.make end def define(options) - project_dir.write_file("#{name}.gemspec", gemspec_string(options)) + project_dir.write_file("#{file_name}.gemspec", gemspec_string(options)) end - attr_reader :name, :path + attr_reader :name, :path, :file_name def project_dir if path - Paths.project(path + '/' + name) + Paths.project(path + '/' + file_name) else - Paths.project(name) + Paths.project(file_name) end end @@ -634,6 +640,11 @@ def write_file(filename, content) join(filename).open('w') { |file| file.write content } end + def remove_lines_with_value(filename, value) + updated_content = join(filename).open('r').readlines.reject { |line| line.include?(value) }.join + write_file(filename, updated_content) + end + def install_fixture(fixture_name) if RUBY_PLATFORM =~ /mswin|cygwin|mingw/ FileUtils.cp(Paths.fixtures.join(fixture_name), join(fixture_name))