diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 811e150e97..3130e26766 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-04-03T19:49:13+10:00 from the rspec-dev repo. +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index 167ad47153..a71e6c4187 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,8 +23,8 @@ cache: bundler bundler_args: "--binstubs --path ../bundle --retry=3 --jobs=3" before_install: - - gem update --system 2.7.8 - - gem install bundler + - script/update_rubygems_and_install_bundler + - script/downgrade_bundler_on_old_rails - script/clone_all_rspec_repos before_script: diff --git a/Changelog.md b/Changelog.md index d3643362a8..634076fc3d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,11 +1,19 @@ ### Development -[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.8.1...master) +[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.8.2...master) + +### 3.8.2 / 2019-01-13 +[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.8.1...v3.8.2) Bug Fixes: * Fix issue with generator for preview specs where `Mailer` would be duplicated in the name. (Kohei Sugi, #2037) * Fix the request spec generator to handle namespaced files. (Kohei Sugi, #2057) +* Further truncate system test filenames to handle cases when extra words are + prepended. (Takumi Kaji, #2058) +* Backport: Make the `ActiveJob` matchers fail when multiple jobs are queued + for negated matches. e.g. `expect { job; job; }.to_not have_enqueued_job + (Emric Istanful, #2069) ### 3.8.1 / 2018-10-23 [Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.8.0...v3.8.1) diff --git a/appveyor.yml b/appveyor.yml index 5b342c53af..f234a3eeb0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-04-03T19:49:13+10:00 from the rspec-dev repo. +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" @@ -33,7 +33,6 @@ test_script: environment: matrix: - - ruby_version: 193 - ruby_version: 200 - ruby_version: 21 - ruby_version: 22 diff --git a/lib/rspec/rails/example/system_example_group.rb b/lib/rspec/rails/example/system_example_group.rb index ba8b5cb7b3..e63afeec8f 100644 --- a/lib/rspec/rails/example/system_example_group.rb +++ b/lib/rspec/rails/example/system_example_group.rb @@ -37,7 +37,7 @@ def method_name @method_name ||= [ self.class.name.underscore, RSpec.current_example.description.underscore - ].join("_").tr(CHARS_TO_TRANSLATE.join, "_")[0...251] + "_#{rand(1000)}" + ].join("_").tr(CHARS_TO_TRANSLATE.join, "_")[0...200] + "_#{rand(1000)}" end # Delegates to `Rails.application`. diff --git a/lib/rspec/rails/matchers/active_job.rb b/lib/rspec/rails/matchers/active_job.rb index be8e732b4b..0555c9fda3 100644 --- a/lib/rspec/rails/matchers/active_job.rb +++ b/lib/rspec/rails/matchers/active_job.rb @@ -197,6 +197,12 @@ def matches?(proc) check(in_block_jobs) end + + def does_not_match?(proc) + set_expected_number(:at_least, 1) + + !matches?(proc) + end end # @private @@ -205,6 +211,12 @@ def matches?(job) @job = job check(queue_adapter.enqueued_jobs) end + + def does_not_match?(proc) + set_expected_number(:at_least, 1) + + !matches?(proc) + end end end diff --git a/lib/rspec/rails/version.rb b/lib/rspec/rails/version.rb index 78d6615223..18c1695dd5 100644 --- a/lib/rspec/rails/version.rb +++ b/lib/rspec/rails/version.rb @@ -3,7 +3,7 @@ module Rails # Version information for RSpec Rails. module Version # Current version of RSpec Rails, in semantic versioning format. - STRING = '3.8.1' + STRING = '3.8.2' end end end diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index 40a6822898..dcd4d914da 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2018-04-03T19:49:13+10:00 from the rspec-dev repo. +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/downgrade_bundler_on_old_rails b/script/downgrade_bundler_on_old_rails new file mode 100755 index 0000000000..36e54feea2 --- /dev/null +++ b/script/downgrade_bundler_on_old_rails @@ -0,0 +1,19 @@ +#!/bin/bash +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. +# DO NOT modify it by hand as your changes will get lost the next time it is generated. + +set -e +source script/functions.sh + +if ruby -e "exit(ENV['RAILS_VERSION'].to_f < 5)"; then + # On Rails versions less than 5, Bundler 2.0 is not supported + echo "Warning dowgrading to older version of Bundler" + gem uninstall -aIx bundler + + # this only works on Ruby 2.3 which is luckily the version we need to fix + if is_ruby_23_plus; then + rvm @global do gem uninstall -aIx bundler + fi + + gem install bundler -v '1.17.3' +fi diff --git a/script/functions.sh b/script/functions.sh index 62d1847bb1..12c1d35904 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-04-03T19:49:13+10:00 from the rspec-dev repo. +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index b165966fe8..cfdc471f79 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-04-03T19:49:13+10:00 from the rspec-dev repo. +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { @@ -57,6 +57,14 @@ function is_mri_2plus { fi } +function is_ruby_23_plus { + if ruby -e "exit(RUBY_VERSION.to_f >= 2.3)"; then + return 0 + else + return 1 + fi +} + function rspec_support_compatible { if [ "$MAINTENANCE_BRANCH" != "2-99-maintenance" ] && [ "$MAINTENANCE_BRANCH" != "2-14-maintenance" ]; then return 0 diff --git a/script/run_build b/script/run_build index 502fd6d9cf..891a05e966 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2018-04-03T19:49:13+10:00 from the rspec-dev repo. +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index 244ada938b..8b89cc8bdf 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-04-03T19:49:13+10:00 from the rspec-dev repo. +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler new file mode 100755 index 0000000000..bcf7e86db6 --- /dev/null +++ b/script/update_rubygems_and_install_bundler @@ -0,0 +1,15 @@ +#!/bin/bash +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. +# DO NOT modify it by hand as your changes will get lost the next time it is generated. + +set -e +source script/functions.sh + +if is_ruby_23_plus; then + gem update --system + gem install bundler +else + echo "Warning installing older versions of Rubygems / Bundler" + gem update --system '2.7.8' + gem install bundler -v '1.17.3' +fi diff --git a/spec/rspec/rails/matchers/active_job_spec.rb b/spec/rspec/rails/matchers/active_job_spec.rb index 18e0222171..c85b98a6b2 100644 --- a/spec/rspec/rails/matchers/active_job_spec.rb +++ b/spec/rspec/rails/matchers/active_job_spec.rb @@ -122,7 +122,16 @@ def self.name; "LoggingJob"; end it "fails when negated and job is enqueued" do expect { expect { heavy_lifting_job.perform_later }.not_to have_enqueued_job - }.to raise_error(/expected not to enqueue exactly 1 jobs, but enqueued 1/) + }.to raise_error(/expected not to enqueue at least 1 jobs, but enqueued 1/) + end + + it "fails when negated and several jobs enqueued" do + expect { + expect { + heavy_lifting_job.perform_later + heavy_lifting_job.perform_later + }.not_to have_enqueued_job + }.to raise_error(/expected not to enqueue at least 1 jobs, but enqueued 2/) end it "passes with job name" do @@ -344,5 +353,13 @@ def self.name; "LoggingJob"; end expect(heavy_lifting_job).to have_been_enqueued }.to raise_error(/expected to enqueue exactly 1 jobs, but enqueued 0/) end + + it "fails when negated and several jobs enqueued" do + heavy_lifting_job.perform_later + heavy_lifting_job.perform_later + expect { + expect(heavy_lifting_job).not_to have_been_enqueued + }.to raise_error(/expected not to enqueue at least 1 jobs, but enqueued 2/) + end end end