diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b757a183..3c7e7a4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,6 @@ jobs: - uses: actions/checkout@v3 - name: Run rubocop and tests run: | - docker pull ohdeployer/ohloh_scm:latest - cmd='/etc/init.d/ssh start; bundle exec rubocop; rake test 2> /dev/null' - docker run --rm -P -v $(pwd):/home/app/ohloh_scm -i ohdeployer/ohloh_scm:latest /bin/sh -c "$cmd" + docker pull --platform=linux/amd64 priyar101/ohloh_scm:latest + cmd='/etc/init.d/ssh start; rake test 2> /dev/null' + docker run --platform=linux/amd64 --rm -P -v $(pwd):/home/app/ohloh_scm -i priyar101/ohloh_scm:latest /bin/sh -c "$cmd" diff --git a/.rubocop.yml b/.rubocop.yml index af6e817e..643cd91d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,9 +1,9 @@ require: rubocop-performance AllCops: - TargetRubyVersion: 2.5 + TargetRubyVersion: 3.0 -Metrics/LineLength: +Layout/LineLength: Max: 99 Documentation: diff --git a/.ruby-version b/.ruby-version index d48d3702..23887f6e 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.9 +3.1.7 diff --git a/Dockerfile b/Dockerfile index 63f96a81..9d38a17f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ FROM ubuntu:22.04 -MAINTAINER OpenHub +LABEL maintainer="OpenHub " -ENV HOME /home -ENV LC_ALL en_US.UTF-8 -ENV APP_HOME $HOME/app/ohloh_scm -ENV DEBIAN_FRONTEND noninteractive -ENV PATH $HOME/.rbenv/shims:$HOME/.rbenv/bin:$HOME/.rbenv/plugins/ruby-build/bin:$PATH +ENV HOME=/home +ENV LC_ALL=en_US.UTF-8 +ENV APP_HOME=$HOME/app/ohloh_scm +ENV DEBIAN_FRONTEND=noninteractive +ENV PATH=$HOME/.rbenv/shims:$HOME/.rbenv/bin:$HOME/.rbenv/plugins/ruby-build/bin:$PATH RUN apt-get update RUN apt-get install -y build-essential software-properties-common locales ragel \ @@ -23,7 +23,7 @@ RUN cd $HOME \ && echo 'eval "$(rbenv init -)"' >> $HOME/.bashrc \ && echo 'gem: --no-rdoc --no-ri' >> $HOME/.gemrc \ && echo 'export PATH="$HOME/.rbenv/shims:$HOME/.rbenv/bin:/home/.rbenv/plugins/ruby-build/bin:$PATH"' >> $HOME/.bash_profile \ - && rbenv install 2.6.9 && rbenv global 2.6.9 + && rbenv install 3.1.7 && rbenv global 3.1.7 RUN git config --global --add safe.directory '*' @@ -41,7 +41,7 @@ RUN ln -s /usr/bin/cvs /usr/bin/cvsnt # Run bundle install before copying source to keep this step cached. RUN mkdir -p $APP_HOME COPY Gemfile* $APP_HOME/ -RUN gem install rake bundler:1.17.3 \ +RUN gem install rake bundler:2.6.9 \ && bundle config --global silence_root_warning 1 \ && cd $APP_HOME && bundle install diff --git a/Gemfile.lock b/Gemfile.lock index 4feae431..ed9b9717 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,41 +1,50 @@ GEM remote: https://rubygems.org/ specs: - ast (2.4.0) - byebug (11.0.1) - docile (1.3.1) - jaro_winkler (1.5.2) - json (2.2.0) - metaclass (0.0.4) - mini_portile2 (2.4.0) - minitest (5.11.3) - mocha (1.8.0) - metaclass (~> 0.0.1) - nokogiri (1.10.3) - mini_portile2 (~> 2.4.0) - parallel (1.17.0) - parser (2.6.2.1) - ast (~> 2.4.0) - psych (3.1.0) - rainbow (3.0.0) - rake (12.3.2) - rubocop (0.67.2) - jaro_winkler (~> 1.5.1) + ast (2.4.3) + byebug (12.0.0) + docile (1.4.1) + mini_portile2 (2.8.9) + minitest (5.25.5) + mocha (2.7.1) + ruby2_keywords (>= 0.0.5) + nokogiri (1.18.8) + mini_portile2 (~> 2.8.2) + racc (~> 1.4) + parallel (1.27.0) + parser (3.3.8.0) + ast (~> 2.4.1) + racc + prism (1.4.0) + racc (1.8.1) + rainbow (3.1.1) + rake (13.2.1) + regexp_parser (2.10.0) + rexml (3.4.1) + rubocop (0.93.1) parallel (~> 1.10) - parser (>= 2.5, != 2.5.1.1) - psych (>= 3.1.0) + parser (>= 2.7.1.5) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8) + rexml + rubocop-ast (>= 0.6.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.6) - rubocop-performance (1.1.0) - rubocop (>= 0.67.0) - ruby-progressbar (1.10.0) - simplecov (0.16.1) + unicode-display_width (>= 1.4.0, < 2.0) + rubocop-ast (1.44.1) + parser (>= 3.3.7.2) + prism (~> 1.4) + rubocop-performance (1.10.2) + rubocop (>= 0.90.0, < 2.0) + rubocop-ast (>= 0.4.0) + ruby-progressbar (1.13.0) + ruby2_keywords (0.0.5) + simplecov (0.22.0) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - unicode-display_width (1.5.0) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) + unicode-display_width (1.8.0) PLATFORMS ruby @@ -51,4 +60,4 @@ DEPENDENCIES simplecov BUNDLED WITH - 1.17.3 + 2.6.9 diff --git a/lib/ohloh_scm/core.rb b/lib/ohloh_scm/core.rb index e89d6a99..c0d08112 100644 --- a/lib/ohloh_scm/core.rb +++ b/lib/ohloh_scm/core.rb @@ -9,11 +9,13 @@ class Core attr_reader :scm, :activity, :status, :validation def initialize(scm_type, url, branch_name, username, password) + scm_opts = { core: self, url: url, branch_name: branch_name, username: username, password: password } + scm_class_name = scm_type.to_s.camelize - @scm = OhlohScm.const_get(scm_class_name)::Scm.new(scm_opts) + @scm = OhlohScm.const_get(scm_class_name)::Scm.new(**scm_opts) @activity = OhlohScm.const_get(scm_class_name)::Activity.new(self) @status = OhlohScm.const_get(scm_class_name)::Status.new(self) @validation = OhlohScm.const_get(scm_class_name)::Validation.new(self) diff --git a/lib/ohloh_scm/cvs/activity.rb b/lib/ohloh_scm/cvs/activity.rb index 2fc0e200..eaab2092 100644 --- a/lib/ohloh_scm/cvs/activity.rb +++ b/lib/ohloh_scm/cvs/activity.rb @@ -107,9 +107,9 @@ def opt_time(after = nil) return '' unless after most_recent_time = parse_time(after) - 10 - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength " -d '#{most_recent_time.strftime('%Y-%m-%d %H:%M:%S')}Z<#{Time.now.utc.strftime('%Y-%m-%d %H:%M:%S')}Z' " - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength end def rlog_filename diff --git a/lib/ohloh_scm/cvs/scm.rb b/lib/ohloh_scm/cvs/scm.rb index d3cd2ee9..f4618663 100644 --- a/lib/ohloh_scm/cvs/scm.rb +++ b/lib/ohloh_scm/cvs/scm.rb @@ -66,7 +66,7 @@ def build_ordered_directory_list(directories) # using cvs modules that are only a single directory deep when testing. # We'll check if the url begins with '/' to detect an integration test, # then return an empty string (ie, the default root directory) if so. - return [''] if url =~ /^\// + return [''] if /^\//.match?(url) list = [] directories = directories.collect { |a| trim_directory(a.to_s).to_s } diff --git a/lib/ohloh_scm/cvs/status.rb b/lib/ohloh_scm/cvs/status.rb index ca0f4903..414458eb 100644 --- a/lib/ohloh_scm/cvs/status.rb +++ b/lib/ohloh_scm/cvs/status.rb @@ -7,7 +7,7 @@ def lock? run "timeout 2m cvsnt -q -d #{scm.url} rlog '#{scm.branch_name}'" false rescue StandardError => e - raise 'CVS lock has been found' if e.message =~ /waiting for.*lock in/ + raise 'CVS lock has been found' if /waiting for.*lock in/.match?(e.message) end end end diff --git a/lib/ohloh_scm/factory.rb b/lib/ohloh_scm/factory.rb index 97aac339..3795150f 100644 --- a/lib/ohloh_scm/factory.rb +++ b/lib/ohloh_scm/factory.rb @@ -4,7 +4,13 @@ module OhlohScm module Factory module_function - def get_core(scm_type: :git, url:, branch_name: nil, username: nil, password: nil) + def get_core(opts = {}) + scm_type = opts.fetch(:scm_type, :git) + url = opts.fetch(:url) { raise ArgumentError, 'URL is required' } + branch_name = opts.fetch(:branch_name, 'master') + username = opts[:username] + password = opts[:password] + OhlohScm::Core.new(scm_type, url, branch_name, username, password) end end diff --git a/lib/ohloh_scm/git/activity.rb b/lib/ohloh_scm/git/activity.rb index bac59c7e..a957bfb0 100644 --- a/lib/ohloh_scm/git/activity.rb +++ b/lib/ohloh_scm/git/activity.rb @@ -58,7 +58,8 @@ def each_commit(opts = {}) # For OpenHub, this is fine because OpenHub ignores merge diffs anyway. previous = nil safe_open_log_file(opts) do |io| - if ENV['EXPENSIVE_COMMIT_COUNT'] && commit_count(opts) > ENV['EXPENSIVE_COMMIT_COUNT'].to_i + expensive_commit_count = ENV['EXPENSIVE_COMMIT_COUNT'] + if expensive_commit_count && commit_count(opts) > expensive_commit_count.to_i io.each do |commit_sha| yield verbose_commit(commit_sha.chomp) end @@ -183,12 +184,12 @@ def safe_open_log_file(opts = {}) end def open_log_file(opts) - if ENV['EXPENSIVE_COMMIT_COUNT'] && commit_count(opts) > ENV['EXPENSIVE_COMMIT_COUNT'].to_i - cmd = "#{rev_list_command(opts)} > #{log_filename}" - else - cmd = "#{rev_list_command(opts)} | xargs -n 1 #{OhlohScm::GitParser.whatchanged}"\ - " | #{string_encoder_path} > #{log_filename}" - end + cmd = if ENV['EXPENSIVE_COMMIT_COUNT'] && commit_count(opts) > ENV['EXPENSIVE_COMMIT_COUNT'].to_i + "#{rev_list_command(opts)} > #{log_filename}" + else + "#{rev_list_command(opts)} | xargs -n 1 #{OhlohScm::GitParser.whatchanged}"\ + " | #{string_encoder_path} > #{log_filename}" + end run(cmd) File.open(log_filename, 'r') { |io| yield io } ensure diff --git a/lib/ohloh_scm/git/scm.rb b/lib/ohloh_scm/git/scm.rb index c17d9126..8efcc366 100644 --- a/lib/ohloh_scm/git/scm.rb +++ b/lib/ohloh_scm/git/scm.rb @@ -61,7 +61,6 @@ def clone_and_create_tracking_branch(remote_scm) end # We need very high reliability and this sequence gets the job done every time. - # rubocop:disable Metrics/AbcSize def clean_and_checkout_branch return unless status.scm_dir_exist? @@ -72,7 +71,6 @@ def clean_and_checkout_branch run "cd '#{url}' && git checkout #{branch_name} --" run "cd '#{url}' && git reset --hard heads/#{branch_name} --" end - # rubocop:enable Metrics/AbcSize def create_tracking_branch(branch_name) return if branch_name.to_s.empty? diff --git a/lib/ohloh_scm/hg/activity.rb b/lib/ohloh_scm/hg/activity.rb index 2b0fc03c..1f574f13 100644 --- a/lib/ohloh_scm/hg/activity.rb +++ b/lib/ohloh_scm/hg/activity.rb @@ -144,7 +144,7 @@ def parent_tokens(commit) def cat(revision, path) out, err = run_with_err("cd '#{url}' && hg cat -r #{revision} #{escape(path)}") - return if err =~ /No such file in rev/i + return if /No such file in rev/i.match?(err) raise err unless err&.empty? out diff --git a/lib/ohloh_scm/parser/branch_number.rb b/lib/ohloh_scm/parser/branch_number.rb index 3f72271b..a0a84375 100644 --- a/lib/ohloh_scm/parser/branch_number.rb +++ b/lib/ohloh_scm/parser/branch_number.rb @@ -35,7 +35,7 @@ def to_a # Returns true if is an ancestor of this object. # Also returns true if is the same as this object. - # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity + # rubocop:disable Metrics/AbcSize def inherits_from?(branch_number) b = branch_number.to_a @@ -51,7 +51,7 @@ def inherits_from?(branch_number) end true end - # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity + # rubocop:enable Metrics/AbcSize private diff --git a/lib/ohloh_scm/parser/bzr_xml_parser.rb b/lib/ohloh_scm/parser/bzr_xml_parser.rb index 8b638767..d4ed4c27 100644 --- a/lib/ohloh_scm/parser/bzr_xml_parser.rb +++ b/lib/ohloh_scm/parser/bzr_xml_parser.rb @@ -17,7 +17,7 @@ def initialize(callback) @authors = [] end - # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength + # rubocop:disable Metrics/MethodLength def tag_start(name, attrs) case name when 'log' @@ -38,7 +38,7 @@ def tag_start(name, attrs) @authors = [] end end - # rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength + # rubocop:enable Metrics/MethodLength # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity def tag_end(name) @@ -149,7 +149,7 @@ def self.remove_dupes(diffs) # Bazaar may report that a file was both deleted and added in a single commit. # Reduce these cases to a single 'M' action. diffs.each do |d| - d.action = 'M' if diffs.select { |x| x.path == d.path }.size > 1 + d.action = 'M' if diffs.count { |x| x.path == d.path } > 1 end.uniq end # rubocop:enable Metrics/AbcSize diff --git a/lib/ohloh_scm/parser/svn_parser.rb b/lib/ohloh_scm/parser/svn_parser.rb index 3553c00a..862ddd26 100644 --- a/lib/ohloh_scm/parser/svn_parser.rb +++ b/lib/ohloh_scm/parser/svn_parser.rb @@ -54,7 +54,7 @@ def internal_parse(buffer, _opts) elsif state == :log_embedded_within_comment e.message << "\n" e.message << l - next_state = :comment if l =~ /============================ .* log end =+/ + next_state = :comment if /============================ .* log end =+/.match?(l) elsif state == :comment if /------------------------------------------------------------------------/.match?(l) diff --git a/lib/ohloh_scm/py_bridge/hg_client.rb b/lib/ohloh_scm/py_bridge/hg_client.rb index 5d8606e2..f034c9ef 100644 --- a/lib/ohloh_scm/py_bridge/hg_client.rb +++ b/lib/ohloh_scm/py_bridge/hg_client.rb @@ -13,7 +13,7 @@ def initialize(repository_url) def cat_file(revision, file) send_command("CAT_FILE\t#{revision}\t#{file}") rescue RuntimeError => e - raise unless e.message =~ /not found in manifest/ # File does not exist. + raise unless /not found in manifest/.match?(e.message) # File does not exist. end def parent_tokens(revision) diff --git a/lib/ohloh_scm/svn/activity.rb b/lib/ohloh_scm/svn/activity.rb index cf8295ad..e1a7f3e3 100644 --- a/lib/ohloh_scm/svn/activity.rb +++ b/lib/ohloh_scm/svn/activity.rb @@ -42,9 +42,8 @@ def export_tag(dest_dir, tag_name) # http://svn.apache.org/repos/asf/httpd/httpd/trunk # http://svn.apache.org/repos/asf/maven/plugin-testing/trunk # all have the same root value(https://svn.apache.org/repos/asf) - # rubocop:disable Metrics/AbcSize def tags - doc = Nokogiri::XML(`svn ls --xml #{ base_path}/tags`) + doc = Nokogiri::XML(`svn ls --xml #{base_path}/tags`) doc.xpath('//lists/list/entry').map do |entry| tag_name = entry.xpath('name').text revision = entry.xpath('commit').attr('revision').text @@ -53,7 +52,6 @@ def tags [tag_name, revision, date_string] end end - # rubocop:enable Metrics/AbcSize def head_token return unless info =~ /^Revision: (\d+)$/ @@ -80,10 +78,11 @@ def info(path = nil, revision = 'HEAD') # Because uri(with branch) may have characters(e.g. space) that break the shell command. def uri_encode(uri) # URI.encode is declared obsolete, however we couldn't find an alternative. - # URI.encode('foo bar') => foo%20bar # `svn log svn://...foo%20bar` works. + # URI.encode('foo bar') => foo%20bar # `svn log svn://...foo%20bar` works in ruby 2.x # CGI.escape('foo bar') => foo+bar # `svn log svn://...foo+bar` won't work. + # URI::DEFAULT_PARSER.escape('foo bar') => foo%20bar # `svn log svn://...foo%20bar` works in ruby 3.x # rubocop:disable Lint/UriEscapeUnescape - URI.encode(uri) + URI::DEFAULT_PARSER.escape(uri) # rubocop:enable Lint/UriEscapeUnescape end diff --git a/lib/ohloh_scm/svn/scm.rb b/lib/ohloh_scm/svn/scm.rb index 2d2907b3..db38ab91 100644 --- a/lib/ohloh_scm/svn/scm.rb +++ b/lib/ohloh_scm/svn/scm.rb @@ -20,7 +20,7 @@ def recalc_branch_name @branch_name = url ? url[activity.root.length..-1] : branch_name rescue RuntimeError => e pattern = /(svn:*is not a working copy|Unable to open an ra_local session to URL)/ - @branch_name = '' if e.message =~ pattern # we have a file system + @branch_name = '' if e.message&.match?(pattern) # we have a file system ensure clean_branch_name branch_name @@ -41,7 +41,6 @@ def accept_ssl_certificate_cmd # # The url and branch_name of this object will be updated with the selected location. # The url will be unmodified if there is a problem connecting to the server. - # rubocop:disable Metrics/AbcSize def restrict_url_to_trunk return url if url.match?(%r{/trunk/?$}) @@ -56,7 +55,6 @@ def restrict_url_to_trunk end url end - # rubocop:enable Metrics/AbcSize private diff --git a/lib/ohloh_scm/validation.rb b/lib/ohloh_scm/validation.rb index dfc81605..b326b8ae 100644 --- a/lib/ohloh_scm/validation.rb +++ b/lib/ohloh_scm/validation.rb @@ -33,7 +33,6 @@ def validate_attributes end # rubocop:enable Metrics/AbcSize - # rubocop:disable Metrics/AbcSize def url_errors error = if scm.url.nil? || scm.url.empty? "The URL can't be blank." @@ -45,7 +44,6 @@ def url_errors [:url, error] if error end - # rubocop:enable Metrics/AbcSize def branch_name_errors if scm.branch_name.length > 80 diff --git a/lib/ohloh_scm/version.rb b/lib/ohloh_scm/version.rb index 3c9fbbd6..3f4a4f38 100644 --- a/lib/ohloh_scm/version.rb +++ b/lib/ohloh_scm/version.rb @@ -2,7 +2,7 @@ module OhlohScm module Version - STRING = '4.0.5' + STRING = '4.0.6' GIT = '2.34.1' SVN = '1.14.1' CVSNT = '1.12.13' diff --git a/ohloh_scm.gemspec b/ohloh_scm.gemspec index dd061289..12cdf453 100644 --- a/ohloh_scm.gemspec +++ b/ohloh_scm.gemspec @@ -17,6 +17,7 @@ Gem::Specification.new do |gem| gem.files = `git ls-files -z`.split("\x0") gem.test_files = gem.files.grep(/^spec\//) gem.require_paths = %w[lib] + gem.required_ruby_version = '>= 3.0.0' gem.post_install_message = "Ohloh SCM is depending on Git #{OhlohScm::Version::GIT}, "\ "SVN #{OhlohScm::Version::SVN}, CVSNT #{OhlohScm::Version::CVSNT}, "\ "Mercurial #{OhlohScm::Version::HG} and Bazaar "\ diff --git a/spec/.rubocop.yml b/spec/.rubocop.yml index 242320a5..0b7f27bd 100644 --- a/spec/.rubocop.yml +++ b/spec/.rubocop.yml @@ -3,7 +3,7 @@ inherit_from: ../.rubocop.yml Style/FrozenStringLiteralComment: Enabled: false -Metrics/LineLength: +Layout/LineLength: Max: 120 Metrics/AbcSize: diff --git a/spec/helpers/assert_scm_attr_helper.rb b/spec/helpers/assert_scm_attr_helper.rb index 575b9847..0e7fcbcb 100644 --- a/spec/helpers/assert_scm_attr_helper.rb +++ b/spec/helpers/assert_scm_attr_helper.rb @@ -8,24 +8,24 @@ def get_core(scm_type, opts = {}) def assert_url_error(scm_type, *urls) urls.each do |url| core = get_core(scm_type, url: url) - core.validation.send(:url_errors).wont_be :empty? + refute_empty core.validation.send(:url_errors) end end def assert_url_valid(scm_type, url) core = get_core(scm_type, url: url) - core.validation.send(:url_errors).must_be_nil + assert_nil core.validation.send(:url_errors) end def assert_branch_name_error(scm_type, *branches) branches.each do |branch_name| core = get_core(scm_type, url: ':pserver:cvs:cvs@cvs.test.org:/test', branch_name: branch_name) - core.validation.send(:branch_name_errors).wont_be :empty? + refute_empty core.validation.send(:branch_name_errors) end end def assert_branch_name_valid(scm_type, branch_name) core = get_core(scm_type, url: ':pserver:cvs:cvs@cvs.test.org:/test', branch_name: branch_name) - core.validation.send(:branch_name_errors).must_be_nil + assert_nil core.validation.send(:branch_name_errors) end end diff --git a/spec/helpers/repository_helper.rb b/spec/helpers/repository_helper.rb index 567b5f49..bd1fcfdd 100644 --- a/spec/helpers/repository_helper.rb +++ b/spec/helpers/repository_helper.rb @@ -7,8 +7,8 @@ module RepositoryHelper end end - def with_git_repository(name, branch_name = 'master', &block) - with_repository('git', name, branch_name) { |core| block.call(core) } + def with_git_repository(name, branch_name = 'master') + with_repository('git', name, branch_name) { |core| yield(core) } end private diff --git a/spec/ohloh_scm/activity_spec.rb b/spec/ohloh_scm/activity_spec.rb index dacc1f97..3bb2f47a 100644 --- a/spec/ohloh_scm/activity_spec.rb +++ b/spec/ohloh_scm/activity_spec.rb @@ -8,14 +8,14 @@ ENV['OHLOH_SCM_TEMP_FOLDER_PATH'] = nil core = get_core(:git) scm = OhlohScm::Activity.new(core) - scm.log_filename.must_equal "#{Dir.tmpdir}/foobar.log" + assert_equal scm.log_filename, "#{Dir.tmpdir}/foobar.log" end it 'should return temp folder path' do ENV['OHLOH_SCM_TEMP_FOLDER_PATH'] = '/test' core = get_core(:git) scm = OhlohScm::Activity.new(core) - scm.log_filename.must_equal '/test/foobar.log' + assert_equal scm.log_filename, '/test/foobar.log' ENV['OHLOH_SCM_TEMP_FOLDER_PATH'] = '' end end diff --git a/spec/ohloh_scm/bzr/activity_spec.rb b/spec/ohloh_scm/bzr/activity_spec.rb index 1eef9bad..92ab31c7 100644 --- a/spec/ohloh_scm/bzr/activity_spec.rb +++ b/spec/ohloh_scm/bzr/activity_spec.rb @@ -8,7 +8,7 @@ tmpdir do |dir| bzr.activity.export(dir) entries = ['.', '..', 'Cédric.txt', 'file1.txt', 'file3.txt', 'file4.txt', 'file5.txt'] - Dir.entries(dir).sort.must_equal entries + assert_equal Dir.entries(dir).sort, entries end end end @@ -17,11 +17,11 @@ with_bzr_repository('bzr') do |bzr| activity = bzr.activity - activity.head_token.must_equal 'test@example.com-20111222183733-y91if5npo3pe8ifs' - activity.head.token.must_equal 'test@example.com-20111222183733-y91if5npo3pe8ifs' + assert_equal activity.head_token, 'test@example.com-20111222183733-y91if5npo3pe8ifs' + assert_equal activity.head.token, 'test@example.com-20111222183733-y91if5npo3pe8ifs' assert activity.head.diffs.any? # diffs should be populated - activity.parents(activity.head).first.token.must_equal 'obnox@samba.org-20090204004942-73rnw0izen42f154' + assert_equal activity.parents(activity.head).first.token, 'obnox@samba.org-20090204004942-73rnw0izen42f154' assert activity.parents(activity.head).first.diffs.any? end end @@ -35,11 +35,11 @@ commit = OhlohScm::Commit.new(token: 6) diff = OhlohScm::Diff.new(path: 'file1.txt') - bzr.activity.cat_file(commit, diff).must_equal expected + assert_equal bzr.activity.cat_file(commit, diff), expected # file2.txt has been removed in commit #5 diff2 = OhlohScm::Diff.new(path: 'file2.txt') - bzr.activity.cat_file(bzr.activity.commits.last, diff2).must_be_nil + assert_nil bzr.activity.cat_file(bzr.activity.commits.last, diff2) end end @@ -52,7 +52,7 @@ commit = OhlohScm::Commit.new(token: 7) diff = OhlohScm::Diff.new(path: 'Cédric.txt') - bzr.activity.cat_file(commit, diff).must_equal expected + assert_equal bzr.activity.cat_file(commit, diff), expected end end @@ -65,7 +65,7 @@ commit = OhlohScm::Commit.new(token: 6) diff = OhlohScm::Diff.new(path: 'file1.txt') - bzr.activity.cat_file_parent(commit, diff).must_equal expected + assert_equal bzr.activity.cat_file_parent(commit, diff), expected # file2.txt has been removed in commit #5 expected = <<-EXPECTED.gsub(/ {8}/, '') @@ -74,24 +74,24 @@ commit2 = OhlohScm::Commit.new(token: 5) diff2 = OhlohScm::Diff.new(path: 'file2.txt') - bzr.activity.cat_file_parent(commit2, diff2).must_equal expected + assert_equal bzr.activity.cat_file_parent(commit2, diff2), expected end end describe 'commits' do it 'must test_commit_count' do with_bzr_repository('bzr') do |bzr| - bzr.activity.commit_count.must_equal 7 - bzr.activity.commit_count(after: revision_ids.first).must_equal 6 - bzr.activity.commit_count(after: revision_ids[5]).must_equal 1 - bzr.activity.commit_count(after: revision_ids.last).must_equal 0 + assert_equal bzr.activity.commit_count, 7 + assert_equal bzr.activity.commit_count(after: revision_ids.first), 6 + assert_equal bzr.activity.commit_count(after: revision_ids[5]), 1 + assert_equal bzr.activity.commit_count(after: revision_ids.last), 0 end end it 'must test_commit_count_with_branches' do with_bzr_repository('bzr_with_branch') do |bzr| # Only 3 commits are on main line... make sure we catch the branch commit as well - bzr.activity.commit_count.must_equal 4 + assert_equal bzr.activity.commit_count, 4 end end @@ -105,16 +105,16 @@ it 'must test_commit_count_trunk_only' do with_bzr_repository('bzr_with_branch') do |bzr| # Only 3 commits are on main line - bzr.activity.commit_count(trunk_only: true).must_equal 3 + assert_equal bzr.activity.commit_count(trunk_only: true), 3 end end it 'must test_commit_tokens_after' do with_bzr_repository('bzr') do |bzr| - bzr.activity.commit_tokens.must_equal revision_ids - bzr.activity.commit_tokens(after: revision_ids.first).must_equal revision_ids[1..6] - bzr.activity.commit_tokens(after: revision_ids[5]).must_equal revision_ids[6..6] - bzr.activity.commit_tokens(after: revision_ids.last).must_equal [] + assert_equal bzr.activity.commit_tokens, revision_ids + assert_equal bzr.activity.commit_tokens(after: revision_ids.first), revision_ids[1..6] + assert_equal bzr.activity.commit_tokens(after: revision_ids[5]), revision_ids[6..6] + assert_equal bzr.activity.commit_tokens(after: revision_ids.last), [] end end @@ -140,7 +140,7 @@ 'test@example.com-20090206214451-lzjngefdyw3vmgms', 'test@example.com-20090206214350-rqhdpz92l11eoq2t', # branch commit 'test@example.com-20090206214515-21lkfj3dbocao5pr'] # merge commit - bzr.activity.commit_tokens.must_equal expected + assert_equal bzr.activity.commit_tokens, expected end end @@ -149,7 +149,7 @@ expected = ['test@example.com-20090206214301-s93cethy9atcqu9h', 'test@example.com-20090206214451-lzjngefdyw3vmgms', 'test@example.com-20090206214515-21lkfj3dbocao5pr'] # merge commit - bzr.activity.commit_tokens(trunk_only: true).must_equal expected + assert_equal bzr.activity.commit_tokens(trunk_only: true), expected end end @@ -167,7 +167,7 @@ 'test@example.com-20110803170522-asv6i9z6m22jc8zz', 'test@example.com-20110803170648-o0xcbni7lwp97azj', 'test@example.com-20110803170818-v44umypquqg8migo'] - bzr.activity.commit_tokens.must_equal expected + assert_equal bzr.activity.commit_tokens, expected end end @@ -180,7 +180,7 @@ 'obnox@samba.org-20090204002540-gmana8tk5f9gboq9', 'obnox@samba.org-20090204004942-73rnw0izen42f154', 'test@example.com-20110803170818-v44umypquqg8migo'] - bzr.activity.commit_tokens(trunk_only: true).must_equal expected + assert_equal bzr.activity.commit_tokens(trunk_only: true), expected end end @@ -191,7 +191,7 @@ 'test@example.com-20090206214350-rqhdpz92l11eoq2t', # branch commit 'test@example.com-20090206214515-21lkfj3dbocao5pr'] # merge commit - bzr.activity.commits.map(&:token).must_equal expected + assert_equal bzr.activity.commits.map(&:token), expected end end @@ -200,21 +200,21 @@ expected = ['test@example.com-20090206214301-s93cethy9atcqu9h', 'test@example.com-20090206214451-lzjngefdyw3vmgms', 'test@example.com-20090206214515-21lkfj3dbocao5pr'] # merge commit - bzr.activity.commits(trunk_only: true).map(&:token).must_equal expected + assert_equal bzr.activity.commits(trunk_only: true).map(&:token), expected end end it 'must test_commits_after_merge' do with_bzr_repository('bzr_with_branch') do |bzr| last_commit = bzr.activity.commits.last - bzr.activity.commits(after: last_commit.token).must_be :empty? + assert_predicate bzr.activity.commits(after: last_commit.token), :empty? end end it 'must test_commits_after_nested_merge' do with_bzr_repository('bzr_with_nested_branches') do |bzr| last_commit = bzr.activity.commits.last - bzr.activity.commits(after: last_commit.token).must_be :empty? + assert_predicate bzr.activity.commits(after: last_commit.token), :empty? end end @@ -232,7 +232,7 @@ 'test@example.com-20110803170522-asv6i9z6m22jc8zz', 'test@example.com-20110803170648-o0xcbni7lwp97azj', 'test@example.com-20110803170818-v44umypquqg8migo'] - bzr.activity.commits.map(&:token).must_equal expected + assert_equal bzr.activity.commits.map(&:token), expected end end @@ -245,18 +245,18 @@ 'obnox@samba.org-20090204002540-gmana8tk5f9gboq9', 'obnox@samba.org-20090204004942-73rnw0izen42f154', 'test@example.com-20110803170818-v44umypquqg8migo'] - bzr.activity.commits(trunk_only: true).map(&:token).must_equal expected + assert_equal bzr.activity.commits(trunk_only: true).map(&:token), expected end end it 'must test_commits' do with_bzr_repository('bzr') do |bzr| - bzr.activity.commits.collect(&:token).must_equal revision_ids - bzr.activity.commits(after: revision_ids[5]).collect(&:token).must_equal revision_ids[6..6] - bzr.activity.commits(after: revision_ids.last).collect(&:token).must_equal [] + assert_equal bzr.activity.commits.collect(&:token), revision_ids + assert_equal bzr.activity.commits(after: revision_ids[5]).collect(&:token), revision_ids[6..6] + assert_equal bzr.activity.commits(after: revision_ids.last).collect(&:token), [] # Check that the diffs are not populated - bzr.activity.commits.first.diffs.must_equal [] + assert_equal bzr.activity.commits.first.diffs, [] end end @@ -280,7 +280,7 @@ assert !FileTest.exist?(bzr.activity.log_filename) # Verify that we got the commits in forward chronological order - commits.collect(&:token).must_equal revision_ids + assert_equal commits.collect(&:token), revision_ids end end @@ -292,7 +292,7 @@ 'test@example.com-20090206214451-lzjngefdyw3vmgms', 'test@example.com-20090206214350-rqhdpz92l11eoq2t', # branch commit 'test@example.com-20090206214515-21lkfj3dbocao5pr'] # merge commit] - commits.map(&:token).must_equal expected + assert_equal commits.map(&:token), expected end end @@ -306,7 +306,7 @@ 'test@example.com-20090206214515-21lkfj3dbocao5pr' # merge commit # 'test@example.com-20090206214350-rqhdpz92l11eoq2t' # branch commit -- after merge! ] - commits.map(&:token).must_equal expected + assert_equal commits.map(&:token), expected end end @@ -316,7 +316,7 @@ commits = [] bzr.activity.each_commit(after: last_commit.token) { |c| commits << c } - commits.must_equal [] + assert_equal commits, [] end end @@ -326,7 +326,7 @@ commits = [] bzr.activity.each_commit(after: last_commit.token) { |c| commits << c } - commits.must_equal [] + assert_equal commits, [] end end @@ -337,7 +337,7 @@ yielded_commits = [] bzr.activity.each_commit(after: next_to_last_commit.token) { |c| yielded_commits << c } - yielded_commits.map(&:token).must_equal [last_commit.token] + assert_equal yielded_commits.map(&:token), [last_commit.token] end end @@ -357,7 +357,7 @@ 'test@example.com-20110803170522-asv6i9z6m22jc8zz', 'test@example.com-20110803170648-o0xcbni7lwp97azj', 'test@example.com-20110803170818-v44umypquqg8migo'] - commits.map(&:token).must_equal expected + assert_equal commits.map(&:token), expected end end @@ -372,7 +372,7 @@ 'obnox@samba.org-20090204002540-gmana8tk5f9gboq9', 'obnox@samba.org-20090204004942-73rnw0izen42f154', 'test@example.com-20110803170818-v44umypquqg8migo'] - commits.map(&:token).must_equal expected + assert_equal commits.map(&:token), expected end end @@ -387,16 +387,16 @@ bzr.activity.each_commit do |c| commits << c end - commits.size.must_equal 1 - commits.first.diffs.size.must_equal 1 - commits.first.diffs.first.path.must_equal 'foo/helloworld.c' + assert_equal commits.size, 1 + assert_equal commits.first.diffs.size, 1 + assert_equal commits.first.diffs.first.path, 'foo/helloworld.c' end end # Verfies OTWO-344 it 'must test_commit_tokens_with_colon_character' do with_bzr_repository('bzr_colon') do |bzr| - bzr.activity.commit_tokens.must_equal ['svn-v4:364a429a-ab12-11de-804f-e3d9c25ff3d2::0'] + assert_equal bzr.activity.commit_tokens, ['svn-v4:364a429a-ab12-11de-804f-e3d9c25ff3d2::0'] end end @@ -406,23 +406,23 @@ bzr.activity.each_commit do |c| commits << c end - commits.size.must_equal 3 + assert_equal commits.size, 3 - commits[0].message.must_equal 'Initial.' - commits[0].committer_name.must_equal 'Abhay Mujumdar' - commits[0].author_name.must_be_nil - commits[0].author_email.must_be_nil + assert_equal commits[0].message, 'Initial.' + assert_equal commits[0].committer_name, 'Abhay Mujumdar' + assert_nil commits[0].author_name + assert_nil commits[0].author_email - commits[1].message.must_equal 'Updated.' - commits[1].committer_name.must_equal 'Abhay Mujumdar' - commits[1].author_name.must_equal 'John Doe' - commits[1].author_email.must_equal 'johndoe@example.com' + assert_equal commits[1].message, 'Updated.' + assert_equal commits[1].committer_name, 'Abhay Mujumdar' + assert_equal commits[1].author_name, 'John Doe' + assert_equal commits[1].author_email, 'johndoe@example.com' # When there are multiple authors, first one is captured. - commits[2].message.must_equal 'Updated by two authors.' - commits[2].committer_name.must_equal 'test' - commits[2].author_name.must_equal 'John Doe' - commits[2].author_email.must_equal 'johndoe@example.com' + assert_equal commits[2].message, 'Updated by two authors.' + assert_equal commits[2].committer_name, 'test' + assert_equal commits[2].author_name, 'John Doe' + assert_equal commits[2].author_email, 'johndoe@example.com' end end @@ -453,7 +453,7 @@ def revision_ids time2 = Time.parse('2011-12-22 18:37:33 +0000') time3 = Time.parse('2009-02-04 00:24:22 +0000') - bzr.activity.tags.must_equal [['v1.0.0', '5', time1], + assert_equal bzr.activity.tags, [['v1.0.0', '5', time1], ['v2.0.0', '7', time2], ['v 3.0.0', '2', time3]] end end diff --git a/spec/ohloh_scm/bzr/validation_spec.rb b/spec/ohloh_scm/bzr/validation_spec.rb index c0c0d722..89ecfcb1 100644 --- a/spec/ohloh_scm/bzr/validation_spec.rb +++ b/spec/ohloh_scm/bzr/validation_spec.rb @@ -7,7 +7,7 @@ it 'must handle non existent remote source' do core = OhlohScm::Factory.get_core(scm_type: :bzr, url: 'lp:foobar') core.validate - core.errors.wont_be :empty? + refute_empty core.errors end end diff --git a/spec/ohloh_scm/cvs/activity_spec.rb b/spec/ohloh_scm/cvs/activity_spec.rb index 3dd6dd36..13cca8ed 100644 --- a/spec/ohloh_scm/cvs/activity_spec.rb +++ b/spec/ohloh_scm/cvs/activity_spec.rb @@ -6,23 +6,23 @@ it 'must return the host' do activity = get_core(:cvs, url: ':ext:anonymous:@moodle.cvs.sourceforge.net:/cvsroot/moodle', branch_name: 'contrib').activity - activity.send(:host).must_equal 'moodle.cvs.sourceforge.net' + assert_equal activity.send(:host), 'moodle.cvs.sourceforge.net' end it 'must return the protocol' do activity = get_core(:cvs, url: ':pserver:foo:@foo.com:/cvsroot/a', branch_name: 'b').activity - activity.send(:protocol).must_equal :pserver + assert_equal activity.send(:protocol), :pserver activity = get_core(:cvs, url: ':ext:foo:@foo.com:/cvsroot/a', branch_name: 'b').activity - activity.send(:protocol).must_equal :ext + assert_equal activity.send(:protocol), :ext activity = get_core(:cvs, url: ':pserver:ext:@foo.com:/cvsroot/a', branch_name: 'b').activity - activity.send(:protocol).must_equal :pserver + assert_equal activity.send(:protocol), :pserver end it 'must test tags' do with_cvs_repository('cvs', 'simple') do |cvs| - cvs.activity.tags.must_equal [['simple_release_tag', '1.1.1.1'], ['simple_vendor_tag', '1.1.1']] + assert_equal cvs.activity.tags, [['simple_release_tag', '1.1.1.1'], ['simple_vendor_tag', '1.1.1']] end end @@ -30,29 +30,28 @@ with_cvs_repository('cvs', 'simple') do |cvs| Dir.mktmpdir('oh_scm_tag_') do |dir| cvs.activity.export_tag(dir, 'simple_release_tag') - Dir.entries(dir).sort.must_equal ['.', '..', 'foo.rb'] + assert_equal Dir.entries(dir).sort, ['.', '..', 'foo.rb'] end end end it 'must test commits' do with_cvs_repository('cvs', 'simple') do |cvs| - cvs.activity.commits.collect(&:token).must_equal ['2006-06-29 16:21:07', + assert_equal cvs.activity.commits.collect(&:token), ['2006-06-29 16:21:07', '2006-06-29 18:14:47', '2006-06-29 18:45:29', '2006-06-29 18:48:54', '2006-06-29 18:52:23'] # Make sure we are date format agnostic (2008/01/01 is the same as 2008-01-01) - cvs.activity.commits(after: '2006/06/29 18:45:29').collect(&:token) - .must_equal ['2006-06-29 18:48:54', - '2006-06-29 18:52:23'] + assert_equal cvs.activity.commits(after: '2006/06/29 18:45:29').collect(&:token), + ['2006-06-29 18:48:54', '2006-06-29 18:52:23'] - cvs.activity.commits(after: '2006-06-29 18:45:29') - .collect(&:token).must_equal ['2006-06-29 18:48:54', + assert_equal cvs.activity.commits(after: '2006-06-29 18:45:29') + .collect(&:token), ['2006-06-29 18:48:54', '2006-06-29 18:52:23'] - cvs.activity.commits(after: '2006/06/29 18:52:23').collect(&:token).must_be_empty + assert_empty cvs.activity.commits(after: '2006/06/29 18:52:23').collect(&:token) end end @@ -64,7 +63,7 @@ utc_dates = ['2006-06-29 16:21:07 UTC', '2006-06-29 18:14:47 UTC', '2006-06-29 18:45:29 UTC', '2006-06-29 18:48:54 UTC', '2006-06-29 18:52:23 UTC'] - git_core.activity.commits.map(&:author_date).map(&:to_s).must_equal utc_dates + assert_equal git_core.activity.commits.map(&:author_date).map(&:to_s), utc_dates end end end @@ -72,7 +71,7 @@ it 'must test commits sets scm' do with_cvs_repository('cvs', 'simple') do |cvs| cvs.activity.commits.each do |c| - cvs.activity.scm.must_equal c.scm + assert_equal cvs.activity.scm, c.scm end end end @@ -80,7 +79,7 @@ it 'must test open log file encoding' do with_cvs_repository('cvs', 'invalid_utf8') do |cvs| cvs.activity.send(:open_log_file) do |io| - io.read.valid_encoding?.must_equal true + assert_equal io.read.valid_encoding?, true end end end diff --git a/spec/ohloh_scm/cvs/scm_spec.rb b/spec/ohloh_scm/cvs/scm_spec.rb index 70bd8ec4..611e12a2 100644 --- a/spec/ohloh_scm/cvs/scm_spec.rb +++ b/spec/ohloh_scm/cvs/scm_spec.rb @@ -4,86 +4,86 @@ it 'must test symlink fixup' do scm = get_core(:cvs, url: ':pserver:anoncvs:@cvs.netbeans.org:/cvs').scm scm.normalize - scm.url.must_equal ':pserver:anoncvs:@cvs.netbeans.org:/shared/data/ccvs/repository' + assert_equal scm.url, ':pserver:anoncvs:@cvs.netbeans.org:/shared/data/ccvs/repository' scm = get_core(:cvs, url: ':pserver:anoncvs:@cvs.dev.java.net:/cvs').scm scm.normalize - scm.url.must_equal ':pserver:anoncvs:@cvs.dev.java.net:/shared/data/ccvs/repository' + assert_equal scm.url, ':pserver:anoncvs:@cvs.dev.java.net:/shared/data/ccvs/repository' scm = get_core(:cvs, url: ':PSERVER:ANONCVS:@CVS.DEV.JAVA.NET:/cvs').scm scm.normalize - scm.url.must_equal ':PSERVER:ANONCVS:@CVS.DEV.JAVA.NET:/shared/data/ccvs/repository' + assert_equal scm.url, ':PSERVER:ANONCVS:@CVS.DEV.JAVA.NET:/shared/data/ccvs/repository' scm = get_core(:cvs, url: ':pserver:anonymous:@cvs.gna.org:/cvs/eagleusb').scm scm.normalize - scm.url.must_equal ':pserver:anonymous:@cvs.gna.org:/var/cvs/eagleusb' + assert_equal scm.url, ':pserver:anonymous:@cvs.gna.org:/var/cvs/eagleusb' end it 'must test sync_pserver_username_password' do # Pull username only from url scm = get_core(:cvs, url: ':pserver:guest:@ohloh.net:/test').scm scm.normalize - scm.url.must_equal ':pserver:guest:@ohloh.net:/test' - scm.username.must_equal 'guest' - scm.password.must_equal '' + assert_equal scm.url, ':pserver:guest:@ohloh.net:/test' + assert_equal scm.username, 'guest' + assert_equal scm.password, '' # Pull username and password from url scm = get_core(:cvs, url: ':pserver:guest:secret@ohloh.net:/test').scm scm.normalize - scm.url.must_equal ':pserver:guest:secret@ohloh.net:/test' - scm.username.must_equal 'guest' - scm.password.must_equal 'secret' + assert_equal scm.url, ':pserver:guest:secret@ohloh.net:/test' + assert_equal scm.username, 'guest' + assert_equal scm.password, 'secret' # Apply username and password to url scm = get_core(:cvs, url: ':pserver::@ohloh.net:/test', username: 'guest', password: 'secret').scm scm.normalize - scm.url.must_equal ':pserver:guest:secret@ohloh.net:/test' - scm.username.must_equal 'guest' - scm.password.must_equal 'secret' + assert_equal scm.url, ':pserver:guest:secret@ohloh.net:/test' + assert_equal scm.username, 'guest' + assert_equal scm.password, 'secret' # Passwords disagree, use :password attribute scm = get_core(:cvs, url: ':pserver:guest:old@ohloh.net:/test', username: 'guest', password: 'new').scm scm.normalize - scm.url.must_equal ':pserver:guest:new@ohloh.net:/test' - scm.username.must_equal 'guest' - scm.password.must_equal 'new' + assert_equal scm.url, ':pserver:guest:new@ohloh.net:/test' + assert_equal scm.username, 'guest' + assert_equal scm.password, 'new' end it 'must test guess_forge' do scm = get_core(:cvs, url: nil).scm - scm.send(:guess_forge).must_be_nil + assert_nil scm.send(:guess_forge) scm = get_core(:cvs, url: 'garbage_in_garbage_out').scm - scm.send(:guess_forge).must_be_nil + assert_nil scm.send(:guess_forge) scm = get_core(:cvs, url: ':pserver:anonymous:@boost.cvs.sourceforge.net:/cvsroot/boost').scm - scm.send(:guess_forge).must_equal 'sourceforge.net' + assert_equal scm.send(:guess_forge), 'sourceforge.net' scm = get_core(:cvs, url: ':pserver:guest:@cvs.dev.java.net:/cvs').scm - scm.send(:guess_forge).must_equal 'java.net' + assert_equal scm.send(:guess_forge), 'java.net' scm = get_core(:cvs, url: ':PSERVER:ANONCVS:@CVS.DEV.JAVA.NET:/cvs').scm - scm.send(:guess_forge).must_equal 'java.net' + assert_equal scm.send(:guess_forge), 'java.net' scm = get_core(:cvs, url: ':pserver:guest:@colorchooser.dev.java.net:/cvs').scm - scm.send(:guess_forge).must_equal 'java.net' + assert_equal scm.send(:guess_forge), 'java.net' end it 'must test local directory trim' do scm = get_core(:cvs, url: '/Users/robin/cvs_repo/', branch_name: 'simple').scm - scm.send(:trim_directory, '/Users/robin/cvs_repo/simple/foo.rb').must_equal '/Users/robin/cvs_repo/simple/foo.rb' + assert_equal scm.send(:trim_directory, '/Users/robin/cvs_repo/simple/foo.rb'), '/Users/robin/cvs_repo/simple/foo.rb' end it 'must test remote directory trim' do scm = get_core(:cvs, url: ':pserver:anonymous:@moodle.cvs.sourceforge.net:/cvsroot/moodle', branch_name: 'contrib').scm - scm.send(:trim_directory, '/cvsroot/moodle/contrib/foo.rb').must_equal 'foo.rb' + assert_equal scm.send(:trim_directory, '/cvsroot/moodle/contrib/foo.rb'), 'foo.rb' end it 'must test remote directory trim with port number' do scm = get_core(:cvs, url: ':pserver:anoncvs:anoncvs@libvirt.org:2401/data/cvs', branch_name: 'libvirt').scm - scm.send(:trim_directory, '/data/cvs/libvirt/docs/html/Attic').must_equal 'docs/html/Attic' + assert_equal scm.send(:trim_directory, '/data/cvs/libvirt/docs/html/Attic'), 'docs/html/Attic' end it 'must test ordered directory list' do @@ -94,8 +94,8 @@ '/cvsroot/moodle/contrib'.intern, '/cvsroot/moodle/contrib/hello'.intern, '/cvsroot/moodle/contrib/hello'.intern]) - list.size.must_equal 4 - list.must_equal ['', 'foo', 'hello', 'foo/bar'] + assert_equal list.size, 4 + assert_equal list, ['', 'foo', 'hello', 'foo/bar'] end it 'must test ordered directory list ignores Attic' do @@ -106,7 +106,7 @@ '/cvsroot/moodle/contrib/Attic'.intern, '/cvsroot/moodle/contrib/hello/Attic'.intern]) - list.size.must_equal 4 - list.must_equal ['', 'foo', 'hello', 'foo/bar'] + assert_equal list.size, 4 + assert_equal list, ['', 'foo', 'hello', 'foo/bar'] end end diff --git a/spec/ohloh_scm/cvs/validation_spec.rb b/spec/ohloh_scm/cvs/validation_spec.rb index fa1a0764..99653423 100644 --- a/spec/ohloh_scm/cvs/validation_spec.rb +++ b/spec/ohloh_scm/cvs/validation_spec.rb @@ -6,14 +6,14 @@ url = ':pserver:anonymous:@foobar.xyz_example.org:/cvsroot' core = OhlohScm::Factory.get_core(scm_type: :cvs, url: url, branch_name: 'foo') core.validate - core.errors.wont_be :empty? + refute_empty core.errors end end it 'must have errors for invalid branch_name' do - get_core(:cvs, branch_name: 'x' * 81).validation.send(:branch_name_errors).must_be_nil - get_core(:cvs, branch_name: 'x' * 201).validation.send(:branch_name_errors).wont_be :empty? - get_core(:cvs, branch_name: 'foo@bar').validation.send(:branch_name_errors).wont_be :empty? + assert_nil get_core(:cvs, branch_name: 'x' * 81).validation.send(:branch_name_errors) + refute_empty get_core(:cvs, branch_name: 'x' * 201).validation.send(:branch_name_errors) + refute_empty get_core(:cvs, branch_name: 'foo@bar').validation.send(:branch_name_errors) end it 'must test rejected urls' do diff --git a/spec/ohloh_scm/factory_spec.rb b/spec/ohloh_scm/factory_spec.rb index 6b158e86..a10749fd 100644 --- a/spec/ohloh_scm/factory_spec.rb +++ b/spec/ohloh_scm/factory_spec.rb @@ -7,8 +7,8 @@ url = 'https://foobar.git' core = OhlohScm::Factory.get_core(scm_type: :git, url: url) - core.status.scm.must_be_instance_of OhlohScm::Git::Scm - core.scm.url.must_equal url + assert core.status.scm.is_a?(OhlohScm::Git::Scm) + assert_equal core.scm.url, url assert core.activity.method(:commits) assert core.status.method(:exist?) assert core.validation.method(:validate) diff --git a/spec/ohloh_scm/git/activity_spec.rb b/spec/ohloh_scm/git/activity_spec.rb index e1d907ce..ce4ec6aa 100644 --- a/spec/ohloh_scm/git/activity_spec.rb +++ b/spec/ohloh_scm/git/activity_spec.rb @@ -9,7 +9,7 @@ git.activity.export(dir) entries = ['.', '..', '.gitignore', 'COPYING', 'Gemfile.lock', 'Godeps', 'README', 'helloworld.c', 'makefile', 'nested', 'ohloh_token'] - Dir.entries(dir).sort.must_equal entries + assert_equal Dir.entries(dir).sort, entries end end end @@ -17,15 +17,15 @@ it 'export must work the same for tag or commit_sha' do with_git_repository('git') do |git| tag_sha = 'f6e5a894ac4173f8f2a200f2c36df38a1e61121a' - commit_sha = `cd #{ git.scm.url } && git show #{ tag_sha }`.slice(/commit (.+)$/, 1) + commit_sha = `cd #{git.scm.url} && git show #{tag_sha}`.slice(/commit (.+)$/, 1) Dir.mktmpdir('oh_scm_tag_') do |tag_dir| git.activity.export(tag_dir, tag_sha) Dir.mktmpdir('oh_scm_commit_') do |commit_dir| git.activity.export(commit_dir, commit_sha) - `diff -rq #{ tag_dir } #{ commit_dir }`.must_be :empty? - Dir.entries(commit_dir).sort.must_equal ['.', '..', '.gitignore', 'helloworld.c', + assert_empty `diff -rq #{tag_dir} #{commit_dir}` + assert_equal Dir.entries(commit_dir).sort, ['.', '..', '.gitignore', 'helloworld.c', 'makefile', 'ohloh_token'] end end @@ -48,7 +48,7 @@ it 'must return repository tags' do with_git_repository('git') do |git| - git.activity.tags.must_equal( + assert_equal git.activity.tags,( [['v1.0.0', 'b6e9220c3cabe53a4ed7f32952aeaeb8a822603d', Time.parse('2016-07-31T07:58:30+05:30')], ['v1.1.0-lw', '2e9366dd7a786fdb35f211fff1c8ea05c51968b1', Time.parse('2006-06-11T11:34:17-07:00')], ['v2.1.0', '1df547800dcd168e589bb9b26b4039bff3a7f7e4', Time.parse('2006-07-14T16:07:15-07:00')]] @@ -65,13 +65,13 @@ it 'must be empty for repository with no tags' do with_git_repository('git_walk') do |git| - git.activity.tags.must_be :empty? + assert_empty git.activity.tags end end it 'must work for a tag named master' do with_git_repository('git_with_master_tag') do |git| - git.activity.tags.must_equal [['master', '4e95717ac8cff8cdb10d83398d3ac667a2cca341', + assert_equal git.activity.tags, [['master', '4e95717ac8cff8cdb10d83398d3ac667a2cca341', Time.parse('2018-02-01T12:56:48+0530')]] end end @@ -80,8 +80,8 @@ it 'must return correct head' do with_git_repository('git') do |git| assert git.status.exist? - git.activity.head_token.must_equal 'a2690f4471a0852723f0f0e95d97f7f1f3981639' - git.activity.head.token.must_equal 'a2690f4471a0852723f0f0e95d97f7f1f3981639' + assert_equal git.activity.head_token, 'a2690f4471a0852723f0f0e95d97f7f1f3981639' + assert_equal git.activity.head.token, 'a2690f4471a0852723f0f0e95d97f7f1f3981639' assert git.activity.head.diffs.any? end end @@ -94,53 +94,53 @@ it 'commit_count' do with_git_repository('git') do |git| - git.activity.commit_count.must_equal 5 - git.activity.commit_count(after: 'b6e9220c3cabe53a4ed7f32952aeaeb8a822603d').must_equal 3 - git.activity.commit_count(after: '1df547800dcd168e589bb9b26b4039bff3a7f7e4').must_equal 1 + assert_equal git.activity.commit_count, 5 + assert_equal git.activity.commit_count(after: 'b6e9220c3cabe53a4ed7f32952aeaeb8a822603d'), 3 + assert_equal git.activity.commit_count(after: '1df547800dcd168e589bb9b26b4039bff3a7f7e4'), 1 end end it 'commit_tokens' do with_git_repository('git') do |git| - git.activity.commit_tokens.must_equal %w[089c527c61235bd0793c49109b5bd34d439848c6 + assert_equal git.activity.commit_tokens, %w[089c527c61235bd0793c49109b5bd34d439848c6 b6e9220c3cabe53a4ed7f32952aeaeb8a822603d 2e9366dd7a786fdb35f211fff1c8ea05c51968b1 1df547800dcd168e589bb9b26b4039bff3a7f7e4 a2690f4471a0852723f0f0e95d97f7f1f3981639] - git.activity.commit_tokens(after: '2e9366dd7a786fdb35f211fff1c8ea05c51968b1') - .must_equal %w[1df547800dcd168e589bb9b26b4039bff3a7f7e4 a2690f4471a0852723f0f0e95d97f7f1f3981639] + assert_equal git.activity.commit_tokens(after: '2e9366dd7a786fdb35f211fff1c8ea05c51968b1'), + %w[1df547800dcd168e589bb9b26b4039bff3a7f7e4 a2690f4471a0852723f0f0e95d97f7f1f3981639] - git.activity.commit_tokens(after: 'a2690f4471a0852723f0f0e95d97f7f1f3981639').must_be :empty? + assert_empty git.activity.commit_tokens(after: 'a2690f4471a0852723f0f0e95d97f7f1f3981639') end end it 'commits' do with_git_repository('git') do |git| - git.activity.commits.collect(&:token).must_equal %w[089c527c61235bd0793c49109b5bd34d439848c6 + assert_equal git.activity.commits.collect(&:token), %w[089c527c61235bd0793c49109b5bd34d439848c6 b6e9220c3cabe53a4ed7f32952aeaeb8a822603d 2e9366dd7a786fdb35f211fff1c8ea05c51968b1 1df547800dcd168e589bb9b26b4039bff3a7f7e4 a2690f4471a0852723f0f0e95d97f7f1f3981639] - git.activity.commits(after: '2e9366dd7a786fdb35f211fff1c8ea05c51968b1').collect(&:token) - .must_equal %w[1df547800dcd168e589bb9b26b4039bff3a7f7e4 a2690f4471a0852723f0f0e95d97f7f1f3981639] + assert_equal git.activity.commits(after: '2e9366dd7a786fdb35f211fff1c8ea05c51968b1').collect(&:token), + %w[1df547800dcd168e589bb9b26b4039bff3a7f7e4 a2690f4471a0852723f0f0e95d97f7f1f3981639] - git.activity.commits(after: 'a2690f4471a0852723f0f0e95d97f7f1f3981639').must_be :empty? + assert_empty git.activity.commits(after: 'a2690f4471a0852723f0f0e95d97f7f1f3981639') end end it 'commits for branch' do with_git_repository('git', 'develop') do |git| - git.activity.commits.map(&:token).must_equal %w[089c527c61235bd0793c49109b5bd34d439848c6 + assert_equal git.activity.commits.map(&:token), %w[089c527c61235bd0793c49109b5bd34d439848c6 b6e9220c3cabe53a4ed7f32952aeaeb8a822603d 2e9366dd7a786fdb35f211fff1c8ea05c51968b1 b4046b9a80fead62fa949232f2b87b0cb78fffcc] - git.activity.commits(after: '2e9366dd7a786fdb35f211fff1c8ea05c51968b1') - .map(&:token).must_equal ['b4046b9a80fead62fa949232f2b87b0cb78fffcc'] + assert_equal git.activity.commits(after: '2e9366dd7a786fdb35f211fff1c8ea05c51968b1') + .map(&:token), ['b4046b9a80fead62fa949232f2b87b0cb78fffcc'] - git.activity.commits(after: 'b4046b9a80fead62fa949232f2b87b0cb78fffcc').must_be :empty? + assert_empty git.activity.commits(after: 'b4046b9a80fead62fa949232f2b87b0cb78fffcc') end end @@ -149,29 +149,29 @@ submodule_commits = %w[240375de181498b9a34d4bd328f2c87d2ade79f9 b6a80291e49dc540bb78526f9b1aab1123c9fb0e] - (git.activity.commit_tokens & submodule_commits).must_be :empty? + assert_empty (git.activity.commit_tokens & submodule_commits) diffs = git.activity.commits.map(&:diffs).reject(&:empty?).flatten - diffs.map(&:path).must_equal ['A'] - diffs.map(&:sha1).must_equal ['f70f10e4db19068f79bc43844b49f3eece45c4e8'] + assert_equal diffs.map(&:path), ['A'] + assert_equal diffs.map(&:sha1), ['f70f10e4db19068f79bc43844b49f3eece45c4e8'] end end it 'commit_count for trunk commits' do with_git_repository('git_dupe_delete') do |git| - git.activity.commit_count(trunk_only: false).must_equal 4 - git.activity.commit_count(trunk_only: true).must_equal 3 + assert_equal git.activity.commit_count(trunk_only: false), 4 + assert_equal git.activity.commit_count(trunk_only: true), 3 end end it 'commit tokens for trunk commits' do with_git_repository('git_dupe_delete') do |git| - git.activity.commit_tokens(trunk_only: false).must_equal ['a0a2b8623941562031a7d7f95d984feb4a2d719c', + assert_equal git.activity.commit_tokens(trunk_only: false), ['a0a2b8623941562031a7d7f95d984feb4a2d719c', 'ad6bb43112706c462e53a9a8a8cd3b05f8e9260f', '6126337d2497806528fd8657181d5d4afadd72a4', # On branch '41c4b1044ebffc968d363e5f5e883134e624f846'] - git.activity.commit_tokens(trunk_only: true).must_equal ['a0a2b8623941562031a7d7f95d984feb4a2d719c', + assert_equal git.activity.commit_tokens(trunk_only: true), ['a0a2b8623941562031a7d7f95d984feb4a2d719c', 'ad6bb43112706c462e53a9a8a8cd3b05f8e9260f', # '6126337d2497806528fd8657181d5d4afadd72a4' # On branch '41c4b1044ebffc968d363e5f5e883134e624f846'] @@ -180,13 +180,13 @@ it 'commit tokens for trunk commits using after' do with_git_repository('git_dupe_delete') do |git| - git.activity.commit_tokens(after: 'a0a2b8623941562031a7d7f95d984feb4a2d719c', - trunk_only: true).must_equal %w[ad6bb43112706c462e53a9a8a8cd3b05f8e9260f + assert_equal git.activity.commit_tokens(after: 'a0a2b8623941562031a7d7f95d984feb4a2d719c', + trunk_only: true), %w[ad6bb43112706c462e53a9a8a8cd3b05f8e9260f 41c4b1044ebffc968d363e5f5e883134e624f846] # All trunk commit_tokens, with :after == HEAD - git.activity.commit_tokens(after: '41c4b1044ebffc968d363e5f5e883134e624f846', - trunk_only: true).must_be :empty? + assert_empty git.activity.commit_tokens(after: '41c4b1044ebffc968d363e5f5e883134e624f846', + trunk_only: true) end end @@ -194,20 +194,20 @@ # `git mv foo bar` results in a single R diff. Split it into A & D diffs. with_git_repository('git_with_mv') do |git| r_commit = git.activity.commits[-2] - r_commit.message.strip.must_equal 'Ran: git mv foo bar' - r_commit.diffs.map(&:action).must_equal %w[D A] - r_commit.diffs.map(&:path).must_equal %w[foo bar] + assert_equal r_commit.message.strip, 'Ran: git mv foo bar' + assert_equal r_commit.diffs.map(&:action), %w[D A] + assert_equal r_commit.diffs.map(&:path), %w[foo bar] r_commit = git.activity.commits.last - r_commit.message.strip.must_equal 'Ran: echo B >> bar; mv bar rab' - r_commit.diffs.map(&:action).must_equal %w[D A] - r_commit.diffs.map(&:path).must_equal %w[bar rab] + assert_equal r_commit.message.strip, 'Ran: echo B >> bar; mv bar rab' + assert_equal r_commit.diffs.map(&:action), %w[D A] + assert_equal r_commit.diffs.map(&:path), %w[bar rab] end end it 'trunk only commits' do with_git_repository('git_dupe_delete') do |git| - git.activity.commits(trunk_only: true).collect(&:token).must_equal ['a0a2b8623941562031a7d7f95d984feb4a2d719c', + assert_equal git.activity.commits(trunk_only: true).collect(&:token), ['a0a2b8623941562031a7d7f95d984feb4a2d719c', 'ad6bb43112706c462e53a9a8a8cd3b05f8e9260f', # on a branch, hence excluded. # '6126337d2497806528fd8657181d5d4afadd72a4', @@ -229,14 +229,14 @@ with_git_repository('git_with_null_merge') do |git| c = git.activity.verbose_commit('d3bd0bedbf4b197b2c4eb827e1ec4c35b834482f') # This commit's tree is identical to its parent's. Thus it should contain no diffs. - c.diffs.must_equal [] + assert_equal c.diffs, [] end end it 'each commit with null merge' do with_git_repository('git_with_null_merge') do |git| git.activity.each_commit do |c| - c.diffs.must_equal [] if c.token == 'd3bd0bedbf4b197b2c4eb827e1ec4c35b834482f' + assert_equal c.diffs, [] if c.token == 'd3bd0bedbf4b197b2c4eb827e1ec4c35b834482f' end end end @@ -250,20 +250,20 @@ it 'safe_open_log_file must return text with valid encoding' do with_git_repository('git_with_invalid_encoding') do |git| git.activity.send(:safe_open_log_file) do |io| - io.read.valid_encoding?.must_equal true + assert_equal io.read.valid_encoding?, true end end end it 'commit count when there is a tag named master' do with_git_repository('git_with_master_tag') do |git| - git.activity.commit_count.must_equal 3 + assert_equal git.activity.commit_count, 3 end end it 'commit tokens when there is a tag named master' do with_git_repository('git_with_master_tag') do |git| - git.activity.commit_tokens.must_equal %w[57b2bd30b7bae970cb3b374a0c05fd6ec3088ebf + assert_equal git.activity.commit_tokens, %w[57b2bd30b7bae970cb3b374a0c05fd6ec3088ebf 4e95717ac8cff8cdb10d83398d3ac667a2cca341 34b8a99e6e5dd39bc36893f71e0ab1685668731f] end @@ -272,7 +272,7 @@ it 'must cat file correctly' do with_git_repository('git') do |core| diff = OhlohScm::Diff.new(sha1: '4c734ad53b272c9b3d719f214372ac497ff6c068') - core.activity.cat_file(nil, diff).must_equal <<-EXPECTED.gsub(/^ {8}/, '') + assert_equal core.activity.cat_file(nil, diff), <<-EXPECTED.gsub(/^ {8}/, '') /* Hello, World! */ #include main() @@ -288,23 +288,23 @@ with_git_repository('git_walk') do |git| commit_tokens = CommitTokensHelper.new(git, commit_labels) # Full history to a commit - commit_tokens.between(nil, :A).must_equal %i[A] - commit_tokens.between(nil, :B).must_equal %i[A B] - commit_tokens.between(nil, :C).must_equal %i[A B G H C] - commit_tokens.between(nil, :D).must_equal %i[A B G H C I D] - commit_tokens.between(nil, :G).must_equal %i[A G] - commit_tokens.between(nil, :H).must_equal %i[A G H] - commit_tokens.between(nil, :I).must_equal %i[A G H I] - commit_tokens.between(nil, :J).must_equal %i[A G H I J] + assert_equal commit_tokens.between(nil, :A), %i[A] + assert_equal commit_tokens.between(nil, :B), %i[A B] + assert_equal commit_tokens.between(nil, :C), %i[A B G H C] + assert_equal commit_tokens.between(nil, :D), %i[A B G H C I D] + assert_equal commit_tokens.between(nil, :G), %i[A G] + assert_equal commit_tokens.between(nil, :H), %i[A G H] + assert_equal commit_tokens.between(nil, :I), %i[A G H I] + assert_equal commit_tokens.between(nil, :J), %i[A G H I J] # Limited history from one commit to another - commit_tokens.between(:A, :A).must_be :empty? - commit_tokens.between(:A, :B).must_equal %i[B] - commit_tokens.between(:A, :C).must_equal %i[B G H C] - commit_tokens.between(:A, :D).must_equal %i[B G H C I D] - commit_tokens.between(:B, :D).must_equal %i[G H C I D] - commit_tokens.between(:C, :D).must_equal %i[I D] - commit_tokens.between(:G, :J).must_equal %i[H I J] + assert_empty commit_tokens.between(:A, :A) + assert_equal commit_tokens.between(:A, :B), %i[B] + assert_equal commit_tokens.between(:A, :C), %i[B G H C] + assert_equal commit_tokens.between(:A, :D), %i[B G H C I D] + assert_equal commit_tokens.between(:B, :D), %i[G H C I D] + assert_equal commit_tokens.between(:C, :D), %i[I D] + assert_equal commit_tokens.between(:G, :J), %i[H I J] end end @@ -312,18 +312,18 @@ with_git_repository('git_walk') do |git| commit_tokens = CommitTokensHelper.new(git, commit_labels, trunk_only: true) # Full history to a commit - commit_tokens.between(nil, :A).must_equal %i[A] - commit_tokens.between(nil, :B).must_equal %i[A B] - commit_tokens.between(nil, :C).must_equal %i[A B C] - commit_tokens.between(nil, :D).must_equal %i[A B C D] + assert_equal commit_tokens.between(nil, :A), %i[A] + assert_equal commit_tokens.between(nil, :B), %i[A B] + assert_equal commit_tokens.between(nil, :C), %i[A B C] + assert_equal commit_tokens.between(nil, :D), %i[A B C D] # Limited history from one commit to another - commit_tokens.between(:A, :A).must_be :empty? - commit_tokens.between(:A, :B).must_equal %i[B] - commit_tokens.between(:A, :C).must_equal %i[B C] - commit_tokens.between(:A, :D).must_equal %i[B C D] - commit_tokens.between(:B, :D).must_equal %i[C D] - commit_tokens.between(:C, :D).must_equal %i[D] + assert_empty commit_tokens.between(:A, :A) + assert_equal commit_tokens.between(:A, :B), %i[B] + assert_equal commit_tokens.between(:A, :C), %i[B C] + assert_equal commit_tokens.between(:A, :D), %i[B C D] + assert_equal commit_tokens.between(:B, :D), %i[C D] + assert_equal commit_tokens.between(:C, :D), %i[D] end end @@ -343,12 +343,12 @@ core.activity.commit_all(c) refute core.activity.send(:anything_to_commit?) - core.activity.commits.size.must_equal 1 + assert_equal core.activity.commits.size, 1 - core.activity.commits.first.author_name.must_equal c.author_name + assert_equal core.activity.commits.first.author_name, c.author_name # Depending on version of Git used, we may or may not have trailing \n. # We don't really care, so just compare the stripped versions. - core.activity.commits.first.message.strip.must_equal c.message.strip + assert_equal core.activity.commits.first.message.strip, c.message.strip assert_equal ['.gitignore', 'README'], core.activity.commits.first.diffs.collect(&:path).sort end @@ -370,7 +370,7 @@ core.activity.send(:write_token, 'FOO') refute core.activity.read_token # Token not valid until committed core.activity.commit_all(OhlohScm::Commit.new) - core.activity.read_token.must_equal 'FOO' + assert_equal core.activity.read_token, 'FOO' end end @@ -381,7 +381,7 @@ c = OhlohScm::Commit.new c.token = 'BAR' core.activity.commit_all(c) - c.token.must_equal core.activity.read_token + assert_equal c.token, core.activity.read_token end end diff --git a/spec/ohloh_scm/git/scm_spec.rb b/spec/ohloh_scm/git/scm_spec.rb index 0e166537..e0649547 100644 --- a/spec/ohloh_scm/git/scm_spec.rb +++ b/spec/ohloh_scm/git/scm_spec.rb @@ -27,8 +27,8 @@ master_branch_sha = `cd #{dest_dir} && git rev-parse master` test_branch_sha = `cd #{dest_dir} && git rev-parse test` - master_branch_sha.wont_equal test_branch_sha - master_branch_sha.must_equal remote_master_branch_sha + refute_equal master_branch_sha, test_branch_sha + assert_equal master_branch_sha, remote_master_branch_sha end end end @@ -48,8 +48,8 @@ master_branch_sha = `cd #{dest_dir} && git rev-parse master` test_branch_sha = `cd #{dest_dir} && git rev-parse test` - master_branch_sha.must_equal remote_master_branch_sha - test_branch_sha.must_equal remote_test_branch_sha + assert_equal master_branch_sha, remote_master_branch_sha + assert_equal test_branch_sha, remote_test_branch_sha end end end @@ -81,11 +81,11 @@ `cd #{dest_dir} && git checkout master && git branch -D test` local_branch_cmd = "cd #{dest_dir} && git branch | grep '\*' | sed 's/^\* //'" - `#{ local_branch_cmd }`.chomp.must_equal 'master' + assert_equal `#{local_branch_cmd}`.chomp, 'master' # On doing a refetch, our local copy will now have the updated *main* branch. core.scm.pull(src_core.scm, TestCallback.new) - `#{ local_branch_cmd }`.chomp.must_equal test_branch_name + assert_equal `#{local_branch_cmd}`.chomp, test_branch_name end end end @@ -103,12 +103,12 @@ src_core.activity.commits.each_with_index do |c, i| # Because CVS does not track authors (only committers), # the CVS committer becomes the Git author. - c.committer_date.must_equal dest_commits[i].author_date - c.committer_name.must_equal dest_commits[i].author_name + assert_equal c.committer_date, dest_commits[i].author_date + assert_equal c.committer_name, dest_commits[i].author_name # Depending upon version of Git used, we may or may not have a trailing \n. # We don't really care, so just compare the stripped versions. - c.message.strip.must_equal dest_commits[i].message.strip + assert_equal c.message.strip, dest_commits[i].message.strip end end end @@ -129,6 +129,6 @@ it 'must return master when branch_name is null' do core = OhlohScm::Factory.get_core(scm_type: :git, url: 'foobar') - _(core.scm.branch_name_or_default).must_equal 'master' + assert_equal core.scm.branch_name_or_default, 'master' end end diff --git a/spec/ohloh_scm/git/status_spec.rb b/spec/ohloh_scm/git/status_spec.rb index 9e51cd03..9f391063 100644 --- a/spec/ohloh_scm/git/status_spec.rb +++ b/spec/ohloh_scm/git/status_spec.rb @@ -3,7 +3,7 @@ describe 'Git::Status' do it 'branch?' do with_git_repository('git') do |git| - git.activity.send(:branches).must_equal %w[develop master] + assert_equal git.activity.send(:branches), %w[develop master] assert git.status.branch?('master') assert git.status.branch?('develop') end @@ -13,13 +13,13 @@ it 'must return default branch when repository doesnt exist' do git = OhlohScm::Factory.get_core(scm_type: :git, url: 'foobar') git.status.stubs(:exist?) - _(git.status.default_branch).must_equal 'master' + assert_equal git.status.default_branch, 'master' end it 'must return default branch when no HEAD branch is found in remote' do git = OhlohScm::Factory.get_core(scm_type: :git, url: 'foobar') git.status.stubs(:exist?).returns(true) - git.status.default_branch.must_equal 'master' + assert_equal git.status.default_branch, 'master' end end end diff --git a/spec/ohloh_scm/git/validation_spec.rb b/spec/ohloh_scm/git/validation_spec.rb index 749f79f6..fa0e4147 100644 --- a/spec/ohloh_scm/git/validation_spec.rb +++ b/spec/ohloh_scm/git/validation_spec.rb @@ -4,22 +4,22 @@ it 'wont have errors for valid url' do core = OhlohScm::Factory.get_core(scm_type: :git, url: 'https://github.com/ruby/ruby') core.validation.send(:validate_attributes) - core.errors.must_be :empty? + assert_empty core.errors end it 'must have errors for invalid branch_name' do - get_core(:git, branch_name: 'x' * 81).validation.send(:branch_name_errors).wont_be :empty? - get_core(:git, branch_name: 'foo@bar').validation.send(:branch_name_errors).wont_be :empty? + refute_empty get_core(:git, branch_name: 'x' * 81).validation.send(:branch_name_errors) + refute_empty get_core(:git, branch_name: 'foo@bar').validation.send(:branch_name_errors) end it 'must have errors for invalid username' do - get_core(:git, username: 'x' * 33).validation.send(:username_errors).wont_be :empty? - get_core(:git, username: 'foo@bar').validation.send(:username_errors).wont_be :empty? + refute_empty get_core(:git, username: 'x' * 33).validation.send(:username_errors) + refute_empty get_core(:git, username: 'foo@bar').validation.send(:username_errors) end it 'must have errors for invalid password' do - get_core(:git, password: 'x' * 33).validation.send(:password_errors).wont_be :empty? - get_core(:git, password: 'escape').validation.send(:password_errors).wont_be :empty? + refute_empty get_core(:git, password: 'x' * 33).validation.send(:password_errors) + refute_empty get_core(:git, password: 'escape').validation.send(:password_errors) end describe 'validate url' do diff --git a/spec/ohloh_scm/git_svn/activity_spec.rb b/spec/ohloh_scm/git_svn/activity_spec.rb index 8a3b4add..656ca790 100644 --- a/spec/ohloh_scm/git_svn/activity_spec.rb +++ b/spec/ohloh_scm/git_svn/activity_spec.rb @@ -4,16 +4,16 @@ describe 'GitSvn::Activity' do it 'must return all commit tokens' do with_git_svn_repository('git_svn') do |git_svn| - git_svn.activity.commit_tokens.must_equal [1, 2, 3, 5] - git_svn.activity.commit_tokens(after: 2).must_equal [3, 5] + assert_equal git_svn.activity.commit_tokens, [1, 2, 3, 5] + assert_equal git_svn.activity.commit_tokens(after: 2), [3, 5] end end it 'must return commits' do with_git_svn_repository('git_svn') do |git_svn| - git_svn.activity.commits.map(&:token).must_equal [1, 2, 3, 5] - git_svn.activity.commits(after: 2).map(&:token).must_equal [3, 5] - git_svn.activity.commits(after: 7).map(&:token).must_equal [] + assert_equal git_svn.activity.commits.map(&:token), [1, 2, 3, 5] + assert_equal git_svn.activity.commits(after: 2).map(&:token), [3, 5] + assert_equal git_svn.activity.commits(after: 7).map(&:token), [] end end @@ -21,14 +21,14 @@ with_git_svn_repository('git_svn') do |git_svn| commits = [] git_svn.activity.each_commit { |c| commits << c } - git_svn.activity.commits.map(&:token).must_equal [1, 2, 3, 5] + assert_equal git_svn.activity.commits.map(&:token), [1, 2, 3, 5] end end it 'must return total commit count' do with_git_svn_repository('git_svn') do |git_svn| - git_svn.activity.commit_count.must_equal 4 - git_svn.activity.commit_count(after: 2).must_equal 2 + assert_equal git_svn.activity.commit_count, 4 + assert_equal git_svn.activity.commit_count(after: 2), 2 end end @@ -47,8 +47,8 @@ } EXPECTED - git_svn.activity.cat_file(commit_1, hello_diff) - .delete("\t").strip.must_equal expected.strip + assert_equal git_svn.activity.cat_file(commit_1, hello_diff) + .delete("\t").strip, expected.strip end end @@ -60,7 +60,7 @@ it 'cat_file_with_invalid_filename' do with_git_svn_repository('git_svn') do |git_svn| - assert git_svn.activity.cat_file(commit_1, OhlohScm::Diff.new(path: 'invalid')).must_be_empty + assert_empty git_svn.activity.cat_file(commit_1, OhlohScm::Diff.new(path: 'invalid')) end end @@ -76,7 +76,7 @@ EXPECTED commit = OhlohScm::Commit.new(token: 2) - git_svn.activity.cat_file_parent(commit, hello_diff).delete("\t").must_equal expected.strip + assert_equal git_svn.activity.cat_file_parent(commit, hello_diff).delete("\t"), expected.strip end end diff --git a/spec/ohloh_scm/git_svn/scm_spec.rb b/spec/ohloh_scm/git_svn/scm_spec.rb index 0677e443..5a20ef79 100644 --- a/spec/ohloh_scm/git_svn/scm_spec.rb +++ b/spec/ohloh_scm/git_svn/scm_spec.rb @@ -8,7 +8,7 @@ git_svn.scm.pull(src.scm, TestCallback.new) assert git_svn.status.exist? - git_svn.activity.commit_count.must_equal 5 + assert_equal git_svn.activity.commit_count, 5 end end end diff --git a/spec/ohloh_scm/hg/activity_spec.rb b/spec/ohloh_scm/hg/activity_spec.rb index ae4ecc01..b65eaf51 100644 --- a/spec/ohloh_scm/hg/activity_spec.rb +++ b/spec/ohloh_scm/hg/activity_spec.rb @@ -4,8 +4,8 @@ it 'must fetch tags' do with_hg_repository('hg') do |hg| time = Time.parse('Mon Sep 19 15:27:19 2022 +0000') - hg.activity.tags.first.must_equal ['tip', '6', time] - hg.activity.tags.last.first(2).must_equal ['tagname with space', '2'] + assert_equal hg.activity.tags.first, ['tip', '6', time] + assert_equal hg.activity.tags.last.first(2), ['tagname with space', '2'] end end @@ -14,7 +14,7 @@ Dir.mktmpdir do |dir| hg.activity.export(dir) entries = ['.', '..', '.hgtags', 'Gemfile.lock', 'Godeps', 'README', 'makefile', 'nested', 'two'] - Dir.entries(dir).sort.must_equal entries + assert_equal Dir.entries(dir).sort, entries end end end @@ -22,24 +22,24 @@ describe 'commits' do it 'commit_count' do with_hg_repository('hg') do |hg| - hg.activity.commit_count.must_equal 6 - hg.activity.commit_count(after: 'b14fa4692f949940bd1e28da6fb4617de2615484').must_equal 4 - hg.activity.commit_count(after: '655f04cf6ad708ab58c7b941672dce09dd369a18').must_equal 1 + assert_equal hg.activity.commit_count, 6 + assert_equal hg.activity.commit_count(after: 'b14fa4692f949940bd1e28da6fb4617de2615484'), 4 + assert_equal hg.activity.commit_count(after: '655f04cf6ad708ab58c7b941672dce09dd369a18'), 1 end end it 'commit_count_with_empty_branch' do with_hg_repository('hg', '') do |hg| - hg.scm.branch_name.must_be_nil - hg.activity.commit_count.must_equal 6 - hg.activity.commit_count(after: 'b14fa4692f949940bd1e28da6fb4617de2615484').must_equal 4 - hg.activity.commit_count(after: '655f04cf6ad708ab58c7b941672dce09dd369a18').must_equal 1 + assert_nil hg.scm.branch_name + assert_equal hg.activity.commit_count, 6 + assert_equal hg.activity.commit_count(after: 'b14fa4692f949940bd1e28da6fb4617de2615484'), 4 + assert_equal hg.activity.commit_count(after: '655f04cf6ad708ab58c7b941672dce09dd369a18'), 1 end end it 'commits' do with_hg_repository('hg') do |hg| - hg.activity.commits.map(&:token).must_equal(%w[01101d8ef3cea7da9ac6e9a226d645f4418f05c9 + assert_equal hg.activity.commits.map(&:token),(%w[01101d8ef3cea7da9ac6e9a226d645f4418f05c9 b14fa4692f949940bd1e28da6fb4617de2615484 468336c6671cbc58237a259d1b7326866afc2817 75532c1e1f1de55c2271f6fd29d98efbe35397c4 @@ -47,44 +47,44 @@ 1f45520fff3982761cfe7a0502ad0888d5783efe]) after = '655f04cf6ad708ab58c7b941672dce09dd369a18' - hg.activity.commits(after: after).map(&:token).must_equal ['1f45520fff3982761cfe7a0502ad0888d5783efe'] + assert_equal hg.activity.commits(after: after).map(&:token), ['1f45520fff3982761cfe7a0502ad0888d5783efe'] # Check that the diffs are not populated - hg.activity.commits(after: '655f04cf6ad708ab58c7b941672dce09dd369a18').first.diffs.must_be :empty? + assert_empty hg.activity.commits(after: '655f04cf6ad708ab58c7b941672dce09dd369a18').first.diffs - hg.activity.commits(after: '1f45520fff3982761cfe7a0502ad0888d5783efe').must_be :empty? + assert_empty hg.activity.commits(after: '1f45520fff3982761cfe7a0502ad0888d5783efe') end end it 'commits_with_branch' do with_hg_repository('hg', 'develop') do |hg| - hg.activity.commits.map(&:token).must_equal(%w[01101d8ef3cea7da9ac6e9a226d645f4418f05c9 + assert_equal hg.activity.commits.map(&:token),(%w[01101d8ef3cea7da9ac6e9a226d645f4418f05c9 b14fa4692f949940bd1e28da6fb4617de2615484 468336c6671cbc58237a259d1b7326866afc2817 75532c1e1f1de55c2271f6fd29d98efbe35397c4 4d54c3f0526a1ec89214a70615a6b1c6129c665c]) after = '75532c1e1f1de55c2271f6fd29d98efbe35397c4' - hg.activity.commits(after: after).map(&:token).must_equal(['4d54c3f0526a1ec89214a70615a6b1c6129c665c']) + assert_equal hg.activity.commits(after: after).map(&:token),(['4d54c3f0526a1ec89214a70615a6b1c6129c665c']) # Check that the diffs are not populated - hg.activity.commits(after: '75532c1e1f1de55c2271f6fd29d98efbe35397c4').first.diffs.must_be :empty? + assert_empty hg.activity.commits(after: '75532c1e1f1de55c2271f6fd29d98efbe35397c4').first.diffs - hg.activity.commits(after: '4d54c3f0526a1ec89214a70615a6b1c6129c665c').must_be :empty? + assert_empty hg.activity.commits(after: '4d54c3f0526a1ec89214a70615a6b1c6129c665c') end end it 'trunk_only_commit_count' do with_hg_repository('hg_dupe_delete') do |hg| - hg.activity.commit_count(trunk_only: false).must_equal 4 - hg.activity.commit_count(trunk_only: true).must_equal 3 + assert_equal hg.activity.commit_count(trunk_only: false), 4 + assert_equal hg.activity.commit_count(trunk_only: true), 3 end end it 'trunk_only_commits' do with_hg_repository('hg_dupe_delete') do |hg| - hg.activity.commits(trunk_only: true) - .map(&:token).must_equal(['73e93f57224e3fd828cf014644db8eec5013cd6b', + assert_equal hg.activity.commits(trunk_only: true) + .map(&:token),(['73e93f57224e3fd828cf014644db8eec5013cd6b', '732345b1d5f4076498132fd4b965b1fec0108a50', # '525de321d8085bc1d4a3c7608fda6b4020027985', # branch '72fe74d643bdcb30b00da3b58796c50f221017d0']) @@ -111,7 +111,7 @@ refute File.exist?(hg.activity.send(:log_filename)) # Make sure we cleaned up after ourselves # Verify that we got the commits in forward chronological order - commits.map(&:token).must_equal(%w[01101d8ef3cea7da9ac6e9a226d645f4418f05c9 + assert_equal commits.map(&:token),(%w[01101d8ef3cea7da9ac6e9a226d645f4418f05c9 b14fa4692f949940bd1e28da6fb4617de2615484 468336c6671cbc58237a259d1b7326866afc2817 75532c1e1f1de55c2271f6fd29d98efbe35397c4 @@ -127,7 +127,7 @@ commits = hg.activity.each_commit end - commits.map(&:token).must_equal(%w[01101d8ef3cea7da9ac6e9a226d645f4418f05c9 + assert_equal commits.map(&:token),(%w[01101d8ef3cea7da9ac6e9a226d645f4418f05c9 b14fa4692f949940bd1e28da6fb4617de2615484 468336c6671cbc58237a259d1b7326866afc2817 75532c1e1f1de55c2271f6fd29d98efbe35397c4 @@ -140,7 +140,7 @@ hg.activity.each_commit(after: '468336c6671cbc58237a259d1b7326866afc2817') do |c| commits << c end - commits.map(&:token).must_equal(%w[75532c1e1f1de55c2271f6fd29d98efbe35397c4 + assert_equal commits.map(&:token),(%w[75532c1e1f1de55c2271f6fd29d98efbe35397c4 655f04cf6ad708ab58c7b941672dce09dd369a18 1f45520fff3982761cfe7a0502ad0888d5783efe]) end @@ -149,7 +149,7 @@ it 'open_log_file_encoding' do with_hg_repository('hg_with_invalid_encoding') do |hg| hg.activity.send(:open_log_file) do |io| - io.read.valid_encoding?.must_equal true + assert_equal io.read.valid_encoding?, true end end end @@ -170,15 +170,15 @@ describe 'head' do it 'hg_head_and_parents' do with_hg_repository('hg') do |hg| - hg.activity.head_token.must_equal '1f45520fff3982761cfe7a0502ad0888d5783efe' - hg.activity.head.token.must_equal '1f45520fff3982761cfe7a0502ad0888d5783efe' + assert_equal hg.activity.head_token, '1f45520fff3982761cfe7a0502ad0888d5783efe' + assert_equal hg.activity.head.token, '1f45520fff3982761cfe7a0502ad0888d5783efe' assert hg.activity.head.diffs.any? # diffs should be populated end end it 'head_with_branch' do with_hg_repository('hg', 'develop') do |hg| - hg.activity.head.token.must_equal '4d54c3f0526a1ec89214a70615a6b1c6129c665c' + assert_equal hg.activity.head.token, '4d54c3f0526a1ec89214a70615a6b1c6129c665c' assert hg.activity.head.diffs.any? end end @@ -187,7 +187,7 @@ describe 'commit_tokens' do it 'must work with after argument' do with_hg_repository('hg') do |hg| - hg.activity.commit_tokens.must_equal(%w[01101d8ef3cea7da9ac6e9a226d645f4418f05c9 + assert_equal hg.activity.commit_tokens,(%w[01101d8ef3cea7da9ac6e9a226d645f4418f05c9 b14fa4692f949940bd1e28da6fb4617de2615484 468336c6671cbc58237a259d1b7326866afc2817 75532c1e1f1de55c2271f6fd29d98efbe35397c4 @@ -195,27 +195,27 @@ 1f45520fff3982761cfe7a0502ad0888d5783efe]) after = '01101d8ef3cea7da9ac6e9a226d645f4418f05c9' - hg.activity.commit_tokens(after: after).must_equal(%w[b14fa4692f949940bd1e28da6fb4617de2615484 + assert_equal hg.activity.commit_tokens(after: after),(%w[b14fa4692f949940bd1e28da6fb4617de2615484 468336c6671cbc58237a259d1b7326866afc2817 75532c1e1f1de55c2271f6fd29d98efbe35397c4 655f04cf6ad708ab58c7b941672dce09dd369a18 1f45520fff3982761cfe7a0502ad0888d5783efe]) after = '655f04cf6ad708ab58c7b941672dce09dd369a18' - hg.activity.commit_tokens(after: after).must_equal ['1f45520fff3982761cfe7a0502ad0888d5783efe'] + assert_equal hg.activity.commit_tokens(after: after), ['1f45520fff3982761cfe7a0502ad0888d5783efe'] - hg.activity.commit_tokens(after: '1f45520fff3982761cfe7a0502ad0888d5783efe').must_be :empty? + assert_empty hg.activity.commit_tokens(after: '1f45520fff3982761cfe7a0502ad0888d5783efe') end end it 'must work with trunk_only argument' do with_hg_repository('hg_dupe_delete') do |hg| - hg.activity.commit_tokens(trunk_only: false).must_equal(%w[73e93f57224e3fd828cf014644db8eec5013cd6b + assert_equal hg.activity.commit_tokens(trunk_only: false),(%w[73e93f57224e3fd828cf014644db8eec5013cd6b 732345b1d5f4076498132fd4b965b1fec0108a50 525de321d8085bc1d4a3c7608fda6b4020027985 72fe74d643bdcb30b00da3b58796c50f221017d0]) - hg.activity.commit_tokens(trunk_only: true).must_equal(['73e93f57224e3fd828cf014644db8eec5013cd6b', + assert_equal hg.activity.commit_tokens(trunk_only: true),(['73e93f57224e3fd828cf014644db8eec5013cd6b', '732345b1d5f4076498132fd4b965b1fec0108a50', # '525de321d8085bc1d4a3c7608fda6b4020027985', # branch '72fe74d643bdcb30b00da3b58796c50f221017d0']) @@ -225,16 +225,16 @@ it 'must work with trunk_only and after arguments' do with_hg_repository('hg_dupe_delete') do |hg| opts = { after: '73e93f57224e3fd828cf014644db8eec5013cd6b', trunk_only: false } - hg.activity.commit_tokens(opts).must_equal(%w[732345b1d5f4076498132fd4b965b1fec0108a50 + assert_equal hg.activity.commit_tokens(opts),(%w[732345b1d5f4076498132fd4b965b1fec0108a50 525de321d8085bc1d4a3c7608fda6b4020027985 72fe74d643bdcb30b00da3b58796c50f221017d0]) opts = { after: '73e93f57224e3fd828cf014644db8eec5013cd6b', trunk_only: true } - hg.activity.commit_tokens(opts).must_equal(['732345b1d5f4076498132fd4b965b1fec0108a50', + assert_equal hg.activity.commit_tokens(opts),(['732345b1d5f4076498132fd4b965b1fec0108a50', # '525de321d8085bc1d4a3c7608fda6b4020027985', # On branch '72fe74d643bdcb30b00da3b58796c50f221017d0']) - hg.activity.commit_tokens(after: '72fe74d643bdcb30b00da3b58796c50f221017d0', trunk_only: true).must_be :empty? + assert_empty hg.activity.commit_tokens(after: '72fe74d643bdcb30b00da3b58796c50f221017d0', trunk_only: true) end end @@ -242,21 +242,21 @@ with_hg_repository('hg_walk') do |hg| commit_tokens = CommitTokensHelper.new(hg, commit_labels) # Full history to a commit - commit_tokens.between(nil, :A).must_equal %i[A] - commit_tokens.between(nil, :B).must_equal %i[A B] - commit_tokens.between(nil, :C).must_equal %i[A B G H C] - commit_tokens.between(nil, :D).must_equal %i[A B G H C I D] - commit_tokens.between(nil, :G).must_equal %i[A B G] - commit_tokens.between(nil, :H).must_equal %i[A B G H] - commit_tokens.between(nil, :I).must_equal %i[A B G H C I] + assert_equal commit_tokens.between(nil, :A), %i[A] + assert_equal commit_tokens.between(nil, :B), %i[A B] + assert_equal commit_tokens.between(nil, :C), %i[A B G H C] + assert_equal commit_tokens.between(nil, :D), %i[A B G H C I D] + assert_equal commit_tokens.between(nil, :G), %i[A B G] + assert_equal commit_tokens.between(nil, :H), %i[A B G H] + assert_equal commit_tokens.between(nil, :I), %i[A B G H C I] # Limited history from one commit to another - commit_tokens.between(:A, :A).must_be :empty? - commit_tokens.between(:A, :B).must_equal %i[B] - commit_tokens.between(:A, :C).must_equal %i[B G H C] - commit_tokens.between(:A, :D).must_equal %i[B G H C I D] - commit_tokens.between(:B, :D).must_equal %i[G H C I D] - commit_tokens.between(:C, :D).must_equal %i[I D] + assert_empty commit_tokens.between(:A, :A) + assert_equal commit_tokens.between(:A, :B), %i[B] + assert_equal commit_tokens.between(:A, :C), %i[B G H C] + assert_equal commit_tokens.between(:A, :D), %i[B G H C I D] + assert_equal commit_tokens.between(:B, :D), %i[G H C I D] + assert_equal commit_tokens.between(:C, :D), %i[I D] end end @@ -292,9 +292,9 @@ def commit_labels diff = OhlohScm::Diff.new(path: 'helloworld.c') commit = OhlohScm::Commit.new(token: '75532c1e1f1d') # The file was deleted in revision 468336c6671c. Check that it does not exist now, but existed in parent. - hg.activity.cat_file(commit, diff).must_be_nil - hg.activity.cat_file_parent(commit, diff).must_equal expected - hg.activity.cat_file(OhlohScm::Commit.new(token: '468336c6671c'), diff).must_equal expected + assert_nil hg.activity.cat_file(commit, diff) + assert_equal hg.activity.cat_file_parent(commit, diff), expected + assert_equal hg.activity.cat_file(OhlohScm::Commit.new(token: '468336c6671c'), diff), expected end end @@ -312,7 +312,7 @@ def commit_labels # Confirm that we can read the file back hg = OhlohScm::Factory.get_core(scm_type: :hg, url: dir) diff = OhlohScm::Diff.new(path: funny_name) - hg.activity.cat_file(hg.activity.head, diff).must_equal file_content + assert_equal hg.activity.cat_file(hg.activity.head, diff), file_content end end end diff --git a/spec/ohloh_scm/hg/scm_spec.rb b/spec/ohloh_scm/hg/scm_spec.rb index 392dfb53..e5cc345b 100644 --- a/spec/ohloh_scm/hg/scm_spec.rb +++ b/spec/ohloh_scm/hg/scm_spec.rb @@ -5,18 +5,18 @@ with_hg_repository('hg') do |src| tmpdir do |dir| dest = OhlohScm::Factory.get_core(scm_type: :hg, url: dir) - dest.status.wont_be :exist? + assert !dest.status.exist? dest.scm.pull(src.scm, TestCallback.new) - dest.status.must_be :exist? - Dir.entries(dir).sort.must_equal ['.', '..', '.hg'] + assert dest.status.exist? + assert_equal Dir.entries(dir).sort, ['.', '..', '.hg'] # Commit some new code on the original and pull again run_p "cd '#{src.scm.url}' && touch foo && hg add foo && hg commit -u test -m test" - src.activity.commits.last.message.must_equal "test\n" + assert_equal src.activity.commits.last.message, "test\n" dest.scm.pull(src.scm, TestCallback.new) - Dir.entries(dir).sort.must_equal ['.', '..', '.hg'] + assert_equal Dir.entries(dir).sort, ['.', '..', '.hg'] end end end diff --git a/spec/ohloh_scm/hg/validation_spec.rb b/spec/ohloh_scm/hg/validation_spec.rb index c31c873b..2958212f 100644 --- a/spec/ohloh_scm/hg/validation_spec.rb +++ b/spec/ohloh_scm/hg/validation_spec.rb @@ -5,7 +5,7 @@ it 'must handle non existent remote source' do core = OhlohScm::Factory.get_core(scm_type: :hg, url: 'http://www.selenic.com/repo/foobar') core.validate - core.errors.wont_be :empty? + refute_empty core.errors end end diff --git a/spec/ohloh_scm/parser/array_writer_spec.rb b/spec/ohloh_scm/parser/array_writer_spec.rb index fe0bcdab..b255682a 100644 --- a/spec/ohloh_scm/parser/array_writer_spec.rb +++ b/spec/ohloh_scm/parser/array_writer_spec.rb @@ -17,13 +17,13 @@ LOG commits = OhlohScm::GitParser.parse(log) - commits.size.must_equal 1 + assert_equal commits.size, 1 commit = commits.first - commit.token.must_equal '1df547800dcd168e589bb9b26b4039bff3a7f7e4' - commit.author_name.must_equal 'Jason Allen' - commit.author_email.must_equal 'jason@ohloh.net' - commit.message.must_equal "moving COPYING\n" - commit.author_date.must_equal Time.utc(2006, 7, 14, 23, 7, 15) - commit.diffs.size.must_equal 1 + assert_equal commit.token, '1df547800dcd168e589bb9b26b4039bff3a7f7e4' + assert_equal commit.author_name, 'Jason Allen' + assert_equal commit.author_email, 'jason@ohloh.net' + assert_equal commit.message, "moving COPYING\n" + assert_equal commit.author_date, Time.utc(2006, 7, 14, 23, 7, 15) + assert_equal commit.diffs.size, 1 end end diff --git a/spec/ohloh_scm/parser/branch_number_spec.rb b/spec/ohloh_scm/parser/branch_number_spec.rb index aa78bf10..c6b484b2 100644 --- a/spec/ohloh_scm/parser/branch_number_spec.rb +++ b/spec/ohloh_scm/parser/branch_number_spec.rb @@ -2,9 +2,9 @@ describe 'BranchNumber' do it 'must test basic' do - OhlohScm::BranchNumber.new('1.1').to_a.must_equal [1, 1] - OhlohScm::BranchNumber.new('1234.1234').to_a.must_equal [1234, 1234] - OhlohScm::BranchNumber.new('1.2.3.4').to_a.must_equal [1, 2, 3, 4] + assert_equal OhlohScm::BranchNumber.new('1.1').to_a, [1, 1] + assert_equal OhlohScm::BranchNumber.new('1234.1234').to_a, [1234, 1234] + assert_equal OhlohScm::BranchNumber.new('1.2.3.4').to_a, [1, 2, 3, 4] end it 'must test simple inherits_from' do diff --git a/spec/ohloh_scm/parser/cvs_parser_spec.rb b/spec/ohloh_scm/parser/cvs_parser_spec.rb index 4d6d603e..6c4fc08e 100644 --- a/spec/ohloh_scm/parser/cvs_parser_spec.rb +++ b/spec/ohloh_scm/parser/cvs_parser_spec.rb @@ -3,23 +3,23 @@ describe 'CvsParser' do describe 'parse' do it 'must return empty array' do - OhlohScm::CvsParser.parse('').must_be :empty? + assert_empty OhlohScm::CvsParser.parse('') end it 'must parse the log' do revisions = OhlohScm::CvsParser.parse File.read(FIXTURES_DIR + '/basic.rlog') - revisions.size.must_equal 2 + assert_equal revisions.size, 2 - revisions[0].token.must_equal '2005/07/25 17:09:59' - revisions[0].committer_name.must_equal 'pizzandre' - Time.utc(2005, 0o7, 25, 17, 9, 59).must_equal revisions[0].committer_date - revisions[0].message.must_equal '*** empty log message ***' + assert_equal revisions[0].token, '2005/07/25 17:09:59' + assert_equal revisions[0].committer_name, 'pizzandre' + assert_equal Time.utc(2005, 0o7, 25, 17, 9, 59), revisions[0].committer_date + assert_equal revisions[0].message, '*** empty log message ***' - revisions[1].token.must_equal '2005/07/25 17:11:06' - revisions[1].committer_name.must_equal 'pizzandre' - Time.utc(2005, 0o7, 25, 17, 11, 6).must_equal revisions[1].committer_date - revisions[1].message.must_equal 'Addin UNL file with using example-' + assert_equal revisions[1].token, '2005/07/25 17:11:06' + assert_equal revisions[1].committer_name, 'pizzandre' + assert_equal Time.utc(2005, 0o7, 25, 17, 11, 6), revisions[1].committer_date + assert_equal revisions[1].message, 'Addin UNL file with using example-' end # One file with several revisions @@ -28,23 +28,23 @@ # There are 9 revisions in the rlog, but some of them are close together with the same message. # Therefore we bin them together into only 7 revisions. - revisions.size.must_equal 7 + assert_equal revisions.size, 7 - revisions[0].token.must_equal '2005/07/15 11:53:30' - revisions[0].committer_name.must_equal 'httpd' - revisions[0].message.must_equal 'Initial data for the intelliglue project' + assert_equal revisions[0].token, '2005/07/15 11:53:30' + assert_equal revisions[0].committer_name, 'httpd' + assert_equal revisions[0].message, 'Initial data for the intelliglue project' - revisions[1].token.must_equal '2005/07/15 16:40:17' - revisions[1].committer_name.must_equal 'pizzandre' - revisions[1].message.must_equal '*** empty log message ***' + assert_equal revisions[1].token, '2005/07/15 16:40:17' + assert_equal revisions[1].committer_name, 'pizzandre' + assert_equal revisions[1].message, '*** empty log message ***' - revisions[5].token.must_equal '2005/07/26 20:35:13' - revisions[5].committer_name.must_equal 'pizzandre' + assert_equal revisions[5].token, '2005/07/26 20:35:13' + assert_equal revisions[5].committer_name, 'pizzandre' assert_equal "Issue number:\nObtained from:\nSubmitted by:\nReviewed by:\nAdding current milestones-", revisions[5].message - revisions[6].token.must_equal '2005/07/26 20:39:16' - revisions[6].committer_name.must_equal 'pizzandre' + assert_equal revisions[6].token, '2005/07/26 20:39:16' + assert_equal revisions[6].committer_name, 'pizzandre' assert_equal "Issue number:\nObtained from:\nSubmitted by:\nReviewed by:\nCompleting and fixing milestones texts", revisions[6].message end @@ -53,8 +53,8 @@ # From the trunk's point of view, we should see only the merge event. it 'must test file created on branch as seen from trunk' do revisions = OhlohScm::CvsParser.parse File.read(FIXTURES_DIR + '/file_created_on_branch.rlog') - revisions.size.must_equal 1 - revisions[0].message.must_equal 'merged new_file.rb from branch onto the HEAD' + assert_equal revisions.size, 1 + assert_equal revisions[0].message, 'merged new_file.rb from branch onto the HEAD' end # A file is created on the vender branch. This causes a simultaneous checkin on HEAD @@ -62,8 +62,8 @@ # We should only pick up one of these checkins. it 'must test simultaneous checkins' do revisions = OhlohScm::CvsParser.parse File.read(FIXTURES_DIR + '/simultaneous_checkins.rlog') - revisions.size.must_equal 1 - revisions[0].message.must_equal 'Initial revision' + assert_equal revisions.size, 1 + assert_equal revisions[0].message, 'Initial revision' end # Two different authors check in with two different messages at the exact same moment. @@ -71,7 +71,7 @@ # We arbitrarily choose the first one if so. it 'must test simultaneous checkins_2' do revisions = OhlohScm::CvsParser.parse File.read(FIXTURES_DIR + '/simultaneous_checkins_2.rlog') - revisions.size.must_equal 1 + assert_equal revisions.size, 1 end end end diff --git a/spec/ohloh_scm/parser/git_parser_spec.rb b/spec/ohloh_scm/parser/git_parser_spec.rb index 8ed6f4c3..5b7084df 100644 --- a/spec/ohloh_scm/parser/git_parser_spec.rb +++ b/spec/ohloh_scm/parser/git_parser_spec.rb @@ -3,11 +3,10 @@ describe 'GitParser' do describe 'parse' do it 'must be empty for blank string' do - OhlohScm::GitParser.parse('').must_be :empty? + assert_empty OhlohScm::GitParser.parse('') end it 'must return epoch time for log with no date' do - # rubocop:disable Layout/TrailingWhitespace sample_log = <<-SAMPLE.gsub(/^ {8}/, '') __BEGIN_COMMIT__ Commit: 1df547800dcd168e589bb9b26b4039bff3a7f7e4 @@ -19,11 +18,9 @@ __END_COMMENT__ SAMPLE - # rubocop:enable Layout/TrailingWhitespace - commits = OhlohScm::GitParser.parse(sample_log) - commits.size.must_equal 1 - commits[0].author_date.must_equal Time.utc(1970, 1, 1, 0, 0, 0) + assert_equal commits.size, 1 + assert_equal commits[0].author_date, Time.utc(1970, 1, 1, 0, 0, 0) end it 'must return epoch time for log with invalid date' do @@ -40,8 +37,8 @@ SAMPLE commits = OhlohScm::GitParser.parse(sample_log) - commits.size.must_equal 1 - commits[0].author_date.must_equal Time.utc(1970, 1, 1, 0, 0, 0) + assert_equal commits.size, 1 + assert_equal commits[0].author_date, Time.utc(1970, 1, 1, 0, 0, 0) end it 'must parse a log correctly' do @@ -74,29 +71,29 @@ commits = OhlohScm::GitParser.parse(sample_log) - commits.size.must_equal 2 - - commits[0].token.must_equal '1df547800dcd168e589bb9b26b4039bff3a7f7e4' - commits[0].author_name.must_equal 'Jason Allen' - commits[0].author_email.must_equal 'jason@ohloh.net' - commits[0].message.must_equal "moving COPYING\n" - commits[0].author_date.must_equal Time.utc(2006, 7, 14, 23, 7, 15) - commits[0].diffs.size.must_equal 1 - - commits[0].diffs[0].action.must_equal 'A' - commits[0].diffs[0].path.must_equal 'COPYING' - - commits[1].token.must_equal '2e9366dd7a786fdb35f211fff1c8ea05c51968b1' - commits[1].author_name.must_equal 'Robin Luckey' - commits[1].author_email.must_equal 'robin@ohloh.net' - commits[1].message.must_equal "added some documentation and licensing info\n" - commits[1].author_date.must_equal Time.utc(2006, 6, 11, 18, 34, 17) - commits[1].diffs.size.must_equal 2 - - commits[1].diffs[0].action.must_equal 'M' - commits[1].diffs[0].path.must_equal 'README' - commits[1].diffs[1].action.must_equal 'D' - commits[1].diffs[1].path.must_equal 'helloworld.c' + assert_equal commits.size, 2 + + assert_equal commits[0].token, '1df547800dcd168e589bb9b26b4039bff3a7f7e4' + assert_equal commits[0].author_name, 'Jason Allen' + assert_equal commits[0].author_email, 'jason@ohloh.net' + assert_equal commits[0].message, "moving COPYING\n" + assert_equal commits[0].author_date, Time.utc(2006, 7, 14, 23, 7, 15) + assert_equal commits[0].diffs.size, 1 + + assert_equal commits[0].diffs[0].action, 'A' + assert_equal commits[0].diffs[0].path, 'COPYING' + + assert_equal commits[1].token, '2e9366dd7a786fdb35f211fff1c8ea05c51968b1' + assert_equal commits[1].author_name, 'Robin Luckey' + assert_equal commits[1].author_email, 'robin@ohloh.net' + assert_equal commits[1].message, "added some documentation and licensing info\n" + assert_equal commits[1].author_date, Time.utc(2006, 6, 11, 18, 34, 17) + assert_equal commits[1].diffs.size, 2 + + assert_equal commits[1].diffs[0].action, 'M' + assert_equal commits[1].diffs[0].path, 'README' + assert_equal commits[1].diffs[1].action, 'D' + assert_equal commits[1].diffs[1].path, 'helloworld.c' end end end diff --git a/spec/ohloh_scm/parser/hg_parser_spec.rb b/spec/ohloh_scm/parser/hg_parser_spec.rb index 262f3abd..8c82a028 100644 --- a/spec/ohloh_scm/parser/hg_parser_spec.rb +++ b/spec/ohloh_scm/parser/hg_parser_spec.rb @@ -3,7 +3,7 @@ describe 'HgParser' do describe 'parser' do it 'must return an empty list for blank log' do - OhlohScm::HgParser.parse('').must_be :empty? + assert_empty OhlohScm::HgParser.parse('') end it 'must parse log into commits' do @@ -30,21 +30,21 @@ commits = OhlohScm::HgParser.parse(sample_log) assert commits - commits.size.must_equal 2 - - commits[0].token.must_match '655f04cf6ad708' - commits[0].committer_name.must_equal 'Alex' - commits[0].committer_email.must_equal 'alex@example.com' - commits[0].message.must_equal "added makefile\n" # Note \n at end of comment - commits[0].committer_date.to_i.must_equal Time.utc(2009, 1, 20, 19, 33, 17).to_i - commits[0].diffs.size.must_equal 0 - - commits[1].token.must_match '01101d8ef3ce' - commits[1].committer_name.must_equal 'Robin Luckey' - commits[1].committer_email.must_equal 'robin@ohloh.net' - commits[1].message.must_equal "Initial Checkin\n" # Note \n at end of comment - commits[1].committer_date.to_i.must_equal Time.utc(2009, 1, 20, 19, 32, 54).to_i - commits[1].diffs.size.must_equal 0 + assert_equal commits.size, 2 + + assert commits[0].token.match?('655f04cf6ad708') + assert_equal commits[0].committer_name, 'Alex' + assert_equal commits[0].committer_email, 'alex@example.com' + assert_equal commits[0].message, "added makefile\n" # Note \n at end of comment + assert_equal commits[0].committer_date.to_i, Time.utc(2009, 1, 20, 19, 33, 17).to_i + assert_equal commits[0].diffs.size, 0 + + assert commits[1].token.match?('01101d8ef3ce') + assert_equal commits[1].committer_name, 'Robin Luckey' + assert_equal commits[1].committer_email, 'robin@ohloh.net' + assert_equal commits[1].message, "Initial Checkin\n" # Note \n at end of comment + assert_equal commits[1].committer_date.to_i, Time.utc(2009, 1, 20, 19, 32, 54).to_i + assert_equal commits[1].diffs.size, 0 end it 'must set committer_name to email and committer_email to NULL when name is not present' do @@ -62,11 +62,11 @@ commits = OhlohScm::HgParser.parse(sample_log) assert commits - commits.size.must_equal 1 + assert_equal commits.size, 1 - commits[0].token.must_match '01101d8ef3ce' - commits[0].committer_name.must_equal 'robin@ohloh.net' - commits[0].committer_email.must_be_nil + assert commits[0].token.match?('01101d8ef3ce') + assert_equal commits[0].committer_name, 'robin@ohloh.net' + assert_nil commits[0].committer_email end # Sometimes the log does not include a summary @@ -86,14 +86,14 @@ commits = OhlohScm::HgParser.parse(sample_log) assert commits - commits.size.must_equal 2 - - commits[0].token.must_match '655f04cf6ad708' - commits[0].committer_name.must_equal 'Alex' - commits[0].committer_email.must_equal 'alex@example.com' - commits[0].message.must_be_nil - commits[0].committer_date.to_i.must_equal Time.utc(2009, 1, 20, 19, 33, 17).to_i - commits[0].diffs.size.must_equal 0 + assert_equal commits.size, 2 + + assert commits[0].token.match?('655f04cf6ad708') + assert_equal commits[0].committer_name, 'Alex' + assert_equal commits[0].committer_email, 'alex@example.com' + assert_nil commits[0].message + assert_equal commits[0].committer_date.to_i, Time.utc(2009, 1, 20, 19, 33, 17).to_i + assert_equal commits[0].diffs.size, 0 end it 'must parse verbose log into commits and diffs' do @@ -126,22 +126,22 @@ commits = OhlohScm::HgParser.parse(sample_log) assert commits - commits.size.must_equal 2 - - commits[0].token.must_match '655f04cf6ad708' - commits[0].committer_name.must_equal 'Alex' - commits[0].committer_email.must_equal 'alex@example.com' - commits[0].message.must_equal "Adding file foobar\n" # Note \n at end of comment - commits[0].committer_date.to_i.must_equal Time.utc(2009, 1, 20, 19, 33, 17).to_i - commits[0].diffs[0].path.must_equal 'foobar' - - commits[1].token.must_match '01101d8ef3ce' - commits[1].committer_name.must_equal 'Robin Luckey' - commits[1].committer_email.must_equal 'robin@ohloh.net' - commits[1].message.must_equal "Initial Checkin\n" # Note \n at end of comment - commits[1].committer_date.to_i.must_equal Time.utc(2009, 1, 20, 19, 32, 54).to_i - commits[1].diffs.size.must_equal 1 - commits[1].diffs[0].path.must_equal 'helloworld.c' + assert_equal commits.size, 2 + + assert commits[0].token.match?('655f04cf6ad708') + assert_equal commits[0].committer_name, 'Alex' + assert_equal commits[0].committer_email, 'alex@example.com' + assert_equal commits[0].message, "Adding file foobar\n" # Note \n at end of comment + assert_equal commits[0].committer_date.to_i, Time.utc(2009, 1, 20, 19, 33, 17).to_i + assert_equal commits[0].diffs[0].path, 'foobar' + + assert commits[1].token.match?('01101d8ef3ce') + assert_equal commits[1].committer_name, 'Robin Luckey' + assert_equal commits[1].committer_email, 'robin@ohloh.net' + assert_equal commits[1].message, "Initial Checkin\n" # Note \n at end of comment + assert_equal commits[1].committer_date.to_i, Time.utc(2009, 1, 20, 19, 32, 54).to_i + assert_equal commits[1].diffs.size, 1 + assert_equal commits[1].diffs[0].path, 'helloworld.c' end it 'must parse log with the --style argument' do @@ -161,33 +161,33 @@ protected def assert_styled_commits(commits, with_diffs = false) - commits.size.must_equal 6 + assert_equal commits.size, 6 - commits[1].token.must_equal '655f04cf6ad708ab58c7b941672dce09dd369a18' - commits[1].committer_name.must_equal 'Alex' - commits[1].committer_email.must_equal 'alex@example.com' + assert_equal commits[1].token, '655f04cf6ad708ab58c7b941672dce09dd369a18' + assert_equal commits[1].committer_name, 'Alex' + assert_equal commits[1].committer_email, 'alex@example.com' assert Time.utc(2009, 1, 20, 19, 34, 53) - commits[1].committer_date < 1 # Don't care about milliseconds - commits[1].message.must_equal "Adding file two\n" + assert_equal commits[1].message, "Adding file two\n" if with_diffs - commits[1].diffs.size.must_equal 1 - commits[1].diffs[0].action.must_equal 'A' - commits[1].diffs[0].path.must_equal 'two' + assert_equal commits[1].diffs.size, 1 + assert_equal commits[1].diffs[0].action, 'A' + assert_equal commits[1].diffs[0].path, 'two' else - commits[1].diffs.must_equal [] + assert_equal commits[1].diffs, [] end - commits[2].token.must_equal '75532c1e1f1de55c2271f6fd29d98efbe35397c4' + assert_equal commits[2].token, '75532c1e1f1de55c2271f6fd29d98efbe35397c4' assert Time.utc(2009, 1, 20, 19, 34, 4) - commits[2].committer_date < 1 if with_diffs - commits[3].diffs.size.must_equal 2 - commits[3].diffs[0].action.must_equal 'M' - commits[3].diffs[0].path.must_equal 'helloworld.c' - commits[3].diffs[1].action.must_equal 'A' - commits[3].diffs[1].path.must_equal 'README' + assert_equal commits[3].diffs.size, 2 + assert_equal commits[3].diffs[0].action, 'M' + assert_equal commits[3].diffs[0].path, 'helloworld.c' + assert_equal commits[3].diffs[1].action, 'A' + assert_equal commits[3].diffs[1].path, 'README' else - commits[0].diffs.must_equal [] + assert_equal commits[0].diffs, [] end end end diff --git a/spec/ohloh_scm/svn/activity_spec.rb b/spec/ohloh_scm/svn/activity_spec.rb index c14053d3..c2547513 100644 --- a/spec/ohloh_scm/svn/activity_spec.rb +++ b/spec/ohloh_scm/svn/activity_spec.rb @@ -10,7 +10,7 @@ with_svn_repository('svn') do |svn| tmpdir do |dir| svn.activity.export(dir) - Dir.entries(dir).sort.must_equal %w[. .. branches tags trunk] + assert_equal Dir.entries(dir).sort, %w[. .. branches tags trunk] end end end @@ -28,7 +28,7 @@ svn.activity.export_tag(dir, '2.0') - Dir.entries(dir).sort.must_equal %w[. .. COPYING README helloworld.c makefile] + assert_equal Dir.entries(dir).sort, %w[. .. COPYING README helloworld.c makefile] end end end @@ -44,10 +44,9 @@ " && svn copy trunk tags/2.0 && svn commit -m 'v2.0' && svn update" svn.activity.send :run, cmd - svn.activity.tags.first[0..1].must_equal ['2.0', '6'] + assert_equal svn.activity.tags.first[0..1], ['2.0', '6'] # Avoid millisecond comparision. - svn.activity.tags.first[-1].strftime('%F %R') - .must_equal Time.now.utc.strftime('%F %R') + assert_equal svn.activity.tags.first[-1].strftime('%F %R'), Time.now.utc.strftime('%F %R') end end end diff --git a/spec/ohloh_scm/svn/scm_spec.rb b/spec/ohloh_scm/svn/scm_spec.rb index 8b423311..ab809bea 100644 --- a/spec/ohloh_scm/svn/scm_spec.rb +++ b/spec/ohloh_scm/svn/scm_spec.rb @@ -2,73 +2,73 @@ describe 'Svn::Scm' do it 'must prefix file: to local path' do - get_core(:svn, url: '').scm.send(:prefix_file_for_local_path, '').must_be_nil - get_core(:svn, url: '/home/test').scm.send(:prefix_file_for_local_path, '/home/test') - .must_equal 'file:///home/test' + assert_nil get_core(:svn, url: '').scm.send(:prefix_file_for_local_path, '') + assert_equal get_core(:svn, url: '/home/test').scm.send(:prefix_file_for_local_path, '/home/test'), + 'file:///home/test' end it 'must require https for sourceforge' do OhlohScm::Svn::Scm.any_instance.stubs(:recalc_branch_name) url = '://svn.code.sf.net/p/gallery/code/trunk/gallery2' - get_core(:svn, url: "http#{url}").scm.normalize.url.must_equal "https#{url}" - get_core(:svn, url: "https#{url}").scm.normalize.url.must_equal "https#{url}" + assert_equal get_core(:svn, url: "http#{url}").scm.normalize.url, "https#{url}" + assert_equal get_core(:svn, url: "https#{url}").scm.normalize.url, "https#{url}" url = 'https://github.com/blackducksw/ohloh_scm/trunk' - get_core(:svn, url: url).scm.normalize.url.must_equal url + assert_equal get_core(:svn, url: url).scm.normalize.url, url end it 'must recalc branch name' do with_svn_repository('svn') do |svn_core| svn_scm = get_core(:svn, url: svn_core.scm.url, branch_name: '').scm - svn_scm.branch_name.must_be_nil - svn_scm.send(:recalc_branch_name).must_be_empty - svn_scm.branch_name.must_be_empty + assert_nil svn_scm.branch_name + assert_empty svn_scm.send(:recalc_branch_name) + assert_empty svn_scm.branch_name svn_scm = get_core(:svn, url: svn_core.scm.url, branch_name: '/').scm - svn_scm.send(:recalc_branch_name).must_be_empty - svn_scm.branch_name.must_be_empty + assert_empty svn_scm.send(:recalc_branch_name) + assert_empty svn_scm.branch_name svn_scm = get_core(:svn, url: svn_core.scm.url + '/trunk').scm OhlohScm::Svn::Activity.any_instance.stubs(:root).returns(svn_core.scm.url) svn_scm.send(:recalc_branch_name) - svn_scm.branch_name.must_equal '/trunk' + assert_equal svn_scm.branch_name, '/trunk' svn_scm = get_core(:svn, url: svn_core.scm.url + '/trunk', branch_name: nil).scm OhlohScm::Svn::Activity.any_instance.stubs(:root).returns(svn_core.scm.url) - svn_scm.normalize.branch_name.must_equal '/trunk' + assert_equal svn_scm.normalize.branch_name, '/trunk' end end describe 'restrict_url_to_trunk' do it 'must return url when url ends with trunk' do svn_scm = get_core(:svn, url: 'svn:foobar/trunk').scm - svn_scm.restrict_url_to_trunk.must_equal svn_scm.url + assert_equal svn_scm.restrict_url_to_trunk, svn_scm.url end it 'must append trunk to url and set branch_name when trunk folder is present' do with_svn_repository('svn') do |svn_core| scm = svn_core.scm - scm.url.must_equal svn_core.activity.root - scm.branch_name.must_be_nil + assert_equal scm.url, svn_core.activity.root + assert_nil scm.branch_name scm.restrict_url_to_trunk - scm.url.must_equal svn_core.activity.root + '/trunk' - scm.branch_name.must_equal '/trunk' + assert_equal scm.url, svn_core.activity.root + '/trunk' + assert_equal scm.branch_name, '/trunk' end end it 'must update url and branch_name when repo has a single subfolder' do with_svn_repository('svn_subdir') do |svn_core| scm = svn_core.scm - scm.url.must_equal svn_core.activity.root - scm.branch_name.must_be_nil + assert_equal scm.url, svn_core.activity.root + assert_nil scm.branch_name scm.restrict_url_to_trunk - scm.url.must_equal svn_core.activity.root + '/subdir/trunk' - scm.branch_name.must_equal '/subdir/trunk' + assert_equal scm.url, svn_core.activity.root + '/subdir/trunk' + assert_equal scm.branch_name, '/subdir/trunk' end end end diff --git a/spec/ohloh_scm/svn/validation_spec.rb b/spec/ohloh_scm/svn/validation_spec.rb index 30c9510e..4e0d1aa7 100644 --- a/spec/ohloh_scm/svn/validation_spec.rb +++ b/spec/ohloh_scm/svn/validation_spec.rb @@ -51,12 +51,12 @@ it 'should validate_server_connection' do with_svn_repository('svn') do |svn| svn.validation.send(:validate_server_connection) - svn.validation.errors.must_be :empty? + assert_empty svn.validation.errors end end it 'should strip trailing whitespace in branch_name' do - get_core(:svn, branch_name: '/trunk/').scm.normalize.branch_name.must_equal '/trunk' + assert_equal get_core(:svn, branch_name: '/trunk/').scm.normalize.branch_name, '/trunk' end it 'should catch exception when validating server connection' do @@ -64,7 +64,7 @@ git_svn.validation.instance_variable_set('@errors', nil) git_svn.validation.send :validate_server_connection msg = 'An error occured connecting to the server. Check the URL, username, and password.' - git_svn.validation.errors.must_equal [[:failed, msg]] + assert_equal git_svn.validation.errors, [[:failed, msg]] end it 'should validate head token when validating server connection' do @@ -74,7 +74,7 @@ git_svn.validation.expects(:url_error) git_svn.validation.send :validate_server_connection msg = "The server did not respond to a 'svn info' command. Is the URL correct?" - git_svn.validation.errors.must_equal [[:failed, msg]] + assert_equal git_svn.validation.errors, [[:failed, msg]] end it 'should validate url when validating server connection' do @@ -83,7 +83,7 @@ OhlohScm::Svn::Activity.any_instance.stubs(:head_token).returns('') OhlohScm::Svn::Activity.any_instance.stubs(:root).returns('tt') git_svn.validation.send :validate_server_connection - git_svn.validation.errors - .must_equal [[:failed, 'The URL did not match the Subversion root tt. Is the URL correct?']] + assert_equal git_svn.validation.errors, + [[:failed, 'The URL did not match the Subversion root tt. Is the URL correct?']] end end diff --git a/spec/ohloh_scm/svn_parser_spec.rb b/spec/ohloh_scm/svn_parser_spec.rb index 96562ca0..26262b2a 100644 --- a/spec/ohloh_scm/svn_parser_spec.rb +++ b/spec/ohloh_scm/svn_parser_spec.rb @@ -4,7 +4,7 @@ describe 'SvnParser' do it 'test_empty_array' do - OhlohScm::SvnParser.parse('').must_be :empty? + assert_predicate OhlohScm::SvnParser.parse(''), :empty? end it 'test_yield_instead_of_writer' do @@ -12,8 +12,8 @@ result = OhlohScm::SvnParser.parse(File.read(DATA_DIR + '/simple.svn_log')) do |commit| commits << commit.token end - result.must_be_nil - commits.must_equal [5, 4, 3, 2, 1] + assert_nil result + assert_equal commits, [5, 4, 3, 2, 1] end it 'test_log_parser' do @@ -37,22 +37,22 @@ revs = OhlohScm::SvnParser.parse(sample_log) assert revs - revs.size.must_equal 3 - - revs[0].token.must_equal 1 - revs[0].committer_name.must_equal 'robin' - revs[0].message.must_equal "Initial Checkin\n" # Note \n at end of comment - revs[0].committer_date.must_equal Time.utc(2006, 6, 11, 18, 28, 0o0) - - revs[1].token.must_equal 2 - revs[1].committer_name.must_equal 'jason' - revs[1].message.must_equal 'added makefile' # Note no \n at end of comment - revs[1].committer_date.must_equal Time.utc(2006, 6, 11, 18, 32, 13) - - revs[2].token.must_equal 3 - revs[2].committer_name.must_equal 'robin' - revs[2].message.must_equal 'added some documentation and licensing info' - revs[2].committer_date.must_equal Time.utc(2006, 6, 11, 18, 34, 17) + assert_equal revs.size, 3 + + assert_equal revs[0].token, 1 + assert_equal revs[0].committer_name, 'robin' + assert_equal revs[0].message, "Initial Checkin\n" # Note \n at end of comment + assert_equal revs[0].committer_date, Time.utc(2006, 6, 11, 18, 28, 0o0) + + assert_equal revs[1].token, 2 + assert_equal revs[1].committer_name, 'jason' + assert_equal revs[1].message, 'added makefile' # Note no \n at end of comment + assert_equal revs[1].committer_date, Time.utc(2006, 6, 11, 18, 32, 13) + + assert_equal revs[2].token, 3 + assert_equal revs[2].committer_name, 'robin' + assert_equal revs[2].message, 'added some documentation and licensing info' + assert_equal revs[2].committer_date, Time.utc(2006, 6, 11, 18, 34, 17) end # This is an excerpt from the log for Wireshark. It includes Subversion log excerpts in @@ -95,10 +95,10 @@ revs = OhlohScm::SvnParser.parse(log) assert revs - revs.size.must_equal 2 + assert_equal revs.size, 2 - revs[0].token.must_equal 21_932 - revs[1].token.must_equal 21_931 + assert_equal revs[0].token, 21_932 + assert_equal revs[1].token, 21_931 comment = <<~COMMENT Update from samba tree revision 23054 to 23135 @@ -123,7 +123,7 @@ ------------------------------------------------------------------------ ============================ Samba log end ============== COMMENT - revs[0].message.must_equal comment + assert_equal revs[0].message, comment end it 'test_svn_copy' do @@ -137,10 +137,10 @@ LOG commits = OhlohScm::SvnParser.parse(log) - commits.size.must_equal 1 - commits.first.diffs.size.must_equal 1 - commits.first.diffs.first.path.must_equal '/trunk' - commits.first.diffs.first.from_path.must_equal '/branches/development' - commits.first.diffs.first.from_revision.must_equal 7 + assert_equal commits.size, 1 + assert_equal commits.first.diffs.size, 1 + assert_equal commits.first.diffs.first.path, '/trunk' + assert_equal commits.first.diffs.first.from_path, '/branches/development' + assert_equal commits.first.diffs.first.from_revision, 7 end end diff --git a/spec/ohloh_scm/system_spec.rb b/spec/ohloh_scm/system_spec.rb index b2826b8d..5d727988 100644 --- a/spec/ohloh_scm/system_spec.rb +++ b/spec/ohloh_scm/system_spec.rb @@ -7,7 +7,7 @@ end it 'must raise an exception when command fails' do - -> { run_p('ls /tmp/foobartest') }.must_raise(Exception) + assert_raises(Exception) { run_p('ls /tmp/foobartest') } end end @@ -15,9 +15,9 @@ it 'must provide error and exitstatus' do cmd = %q(ruby -e" t = 'Hello World'; STDOUT.puts t; STDERR.puts t ") stdout, stderr, status = run_with_error_p(cmd) - status.exitstatus.must_equal 0 - stdout.must_equal "Hello World\n" - stderr.must_equal "Hello World\n" + assert_equal status.exitstatus, 0 + assert_equal stdout, "Hello World\n" + assert_equal stderr, "Hello World\n" end end @@ -26,7 +26,7 @@ level = (1..5).to_a.sample OhlohScm::System.logger.level = level core = OhlohScm::Factory.get_core(scm_type: :git, url: 'foo') - core.scm.send(:logger).level.must_equal level + assert_equal core.scm.send(:logger).level, level end end end diff --git a/spec/ohloh_scm/version_spec.rb b/spec/ohloh_scm/version_spec.rb index 00c96cc8..49af997e 100644 --- a/spec/ohloh_scm/version_spec.rb +++ b/spec/ohloh_scm/version_spec.rb @@ -4,6 +4,6 @@ describe 'Version' do it 'must return the version string' do - OhlohScm::Version::STRING.must_be_instance_of String + assert OhlohScm::Version::STRING.is_a?(String) end end diff --git a/spec/string_encoder_spec.rb b/spec/string_encoder_spec.rb index f467f141..91814c30 100644 --- a/spec/string_encoder_spec.rb +++ b/spec/string_encoder_spec.rb @@ -16,7 +16,7 @@ def @object.string_encoder original_content_length = File.size(file_path) original_content_lines = File.readlines(file_path).size - output = `cat #{ file_path } | #{ @object.string_encoder }` + output = `cat #{file_path} | #{@object.string_encoder}` assert_equal original_content_length, output.length assert_equal original_content_lines, output.split("\n").length @@ -25,7 +25,7 @@ def @object.string_encoder it 'must convert invalid characters' do invalid_utf8_word_path = FIXTURES_DIR + '/invalid-utf-word' - string = `cat #{ invalid_utf8_word_path } | #{ @object.string_encoder }` + string = `cat #{invalid_utf8_word_path} | #{@object.string_encoder}` assert_equal true, string.valid_encoding? end