commit rubygem-rspec-its for openSUSE:Leap:15.2
Hello community, here is the log from the commit of package rubygem-rspec-its for openSUSE:Leap:15.2 checked in at 2020-01-30 15:46:55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/rubygem-rspec-its (Old) and /work/SRC/openSUSE:Leap:15.2/.rubygem-rspec-its.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-rspec-its" Thu Jan 30 15:46:55 2020 rev:11 rq:767697 version:1.3.0 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/rubygem-rspec-its/rubygem-rspec-its.changes 2020-01-15 15:59:42.951807656 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.rubygem-rspec-its.new.26092/rubygem-rspec-its.changes 2020-01-30 15:46:55.793290987 +0100 @@ -1,0 +2,13 @@ +Sun May 5 09:43:37 UTC 2019 - Stephan Kulow <coolo@suse.com> + +- updated to version 1.3.0 + see installed Changelog.md + + ### 1.3.0 / 2019-04-09 + [full changelog](http://github.com/rspec/rspec-its/compare/v1.2.0...v1.3.0) + + Enhancements: + * Introduced `will` and `will_not` as to allow one line block expectations. + (Russ Buchanan, #67) + +------------------------------------------------------------------- Old: ---- rspec-its-1.2.0.gem New: ---- gem2rpm.yml rspec-its-1.3.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-rspec-its.spec ++++++ --- /var/tmp/diff_new_pack.4Kfdrb/_old 2020-01-30 15:46:56.353291156 +0100 +++ /var/tmp/diff_new_pack.4Kfdrb/_new 2020-01-30 15:46:56.361291159 +0100 @@ -1,7 +1,7 @@ # # spec file for package rubygem-rspec-its # -# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,20 +12,29 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +# +# This file was generated with a gem2rpm.yml and not just plain gem2rpm. +# All sections marked as MANUAL, license headers, summaries and descriptions +# can be maintained in that file. Please consult this file before editing any +# of those fields # Name: rubygem-rspec-its -Version: 1.2.0 +Version: 1.3.0 Release: 0 %define mod_name rspec-its %define mod_full_name %{mod_name}-%{version} BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: ruby-macros >= 5 -BuildRequires: %{ruby} BuildRequires: %{rubygem gem2rpm} +BuildRequires: %{ruby} +BuildRequires: ruby-macros >= 5 Url: https://github.com/rspec/rspec-its -Source: http://rubygems.org/gems/%{mod_full_name}.gem +Source: https://rubygems.org/gems/%{mod_full_name}.gem +Source1: gem2rpm.yml Summary: Provides "its" method formerly part of rspec-core License: MIT Group: Development/Languages/Ruby ++++++ gem2rpm.yml ++++++ # --- # ## used by gem2rpm # :summary: this is a custom summary # ## used by gem2rpm # :description: |- # this is a custom description # # it can be multiline # ## used by gem2rpm # :license: MIT or Ruby # ## used by gem2rpm and gem_packages # :version_suffix: -x_y # ## used by gem2rpm and gem_packages # :disable_docs: true # ## used by gem2rpm # :disable_automatic_rdoc_dep: true # ## used by gem2rpm # :preamble: |- # BuildRequires: foobar # Requires: foobar # ## used by gem2rpm # :patches: # foo.patch: -p1 # bar.patch: # :post_patch: # if you need to fiddle with the source dir before rebuilding the gem # ## used by gem2rpm :sources: # - foo.desktop # - bar.desktop # :gem_install_args: '....' # ## used by gem2rpm # :pre_install: |- # %if 0%{?use_system_libev} # export USE_VENDORED_LIBEV="no" # %endif # ## used by gem2rpm # :post_install: |- # # delete custom files here or do other fancy stuff # install -D -m 0644 %{S:1} %{buildroot}%{_bindir}/gem2rpm-opensuse # ## used by gem2rpm # :testsuite_command: |- # (pushd %{buildroot}%{gem_base}/gems/%{mod_full_name} && rake test) # ## used by gem2rpm # :filelist: |- # /usr/bin/gem2rpm-opensuse # ## used by gem2rpm # :scripts: # :post: |- # /bin/echo foo # ## used by gem_packages # :main: # :preamble: |- # Requires: util-linux # Recommends: pwgen # :filelist: |- # /usr/bin/gem2rpm-opensuse # ## used by gem_packages # :custom_pkgs: # apache: # :preamble: |- # Requires: ..... # :filelist: |- # /etc/apache2/conf.d/passenger.conf # :summary: Custom summary is optional # :description: |- # Custom description is optional # # bar # :post: |- # /bin/echo foo # :preamble: |- # %if 0%{?suse_version} && 0%{?suse_version} < 1330 # %define rb_build_versions ruby24 ruby25 # %define rb_default_ruby_abi ruby:2.4.0 ruby:2.5.0 # %endif ++++++ rspec-its-1.2.0.gem -> rspec-its-1.3.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.travis.yml new/.travis.yml --- old/.travis.yml 2015-02-19 00:00:29.000000000 +0100 +++ new/.travis.yml 2019-04-09 12:28:10.000000000 +0200 @@ -1,24 +1,31 @@ language: ruby script: "script/test_all" +email: false +before_install: + - script/update_rubygems_and_install_bundler bundler_args: "--standalone --binstubs --without documentation" rvm: - 1.8.7 - 1.9.2 - 1.9.3 - 2.0.0 - - 2.1.0 - - 2.1.1 - - 2.1.2 - - 2.2.0 + - 2.1 + - 2.2.10 + - 2.3.8 + - 2.4.5 + - 2.5.3 + - 2.6.0 - ruby-head - ree - - jruby-18mode - - jruby + - jruby-9.2.5.0 - jruby-head - - rbx + - jruby-1.7.27 + - rbx-3 +env: + - JRUBY_OPTS='--dev' matrix: allow_failures: - rvm: jruby-head - rvm: ruby-head - - rvm: rbx - + - rvm: rbx-3 + fast_finish: true diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Changelog.md new/Changelog.md --- old/Changelog.md 2015-02-19 00:00:29.000000000 +0100 +++ new/Changelog.md 2019-04-09 12:28:10.000000000 +0200 @@ -1,3 +1,10 @@ +### 1.3.0 / 2019-04-09 +[full changelog](http://github.com/rspec/rspec-its/compare/v1.2.0...v1.3.0) + +Enhancements: +* Introduced `will` and `will_not` as to allow one line block expectations. + (Russ Buchanan, #67) + ### 1.2.0 / 2015-02-06 [full changelog](http://github.com/rspec/rspec-its/compare/v1.1.0...v1.2.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Gemfile new/Gemfile --- old/Gemfile 2015-02-19 00:00:29.000000000 +0100 +++ new/Gemfile 2019-04-09 12:28:10.000000000 +0200 @@ -6,7 +6,7 @@ %w[rspec rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib| branch = ENV.fetch('BRANCH','3-1-maintenance') library_path = File.expand_path("../../#{lib}", __FILE__) - if File.exist?(library_path) + if File.exist?(library_path) && !ENV['USE_GIT_REPOS'] gem lib, :path => library_path else gem lib, :git => "git://github.com/rspec/#{lib}.git", @@ -14,6 +14,14 @@ end end +if RUBY_VERSION < '2.0.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/) + gem 'ffi', '< 1.9.15' # allow ffi to be installed on older rubies on windows +elsif RUBY_VERSION < '1.9' + gem 'ffi', '< 1.9.19' # ffi dropped Ruby 1.8 support in 1.9.19 +else + gem 'ffi', '~> 1.9.25' +end + # test coverage # gem 'simplecov', :require => false diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2015-02-19 00:00:29.000000000 +0100 +++ new/README.md 2019-04-09 12:28:10.000000000 +0200 @@ -6,7 +6,9 @@ Add this line to your application's Gemfile: - gem 'rspec-its' +```ruby +gem 'rspec-its' +``` And then execute: @@ -18,50 +20,82 @@ And require it as: - require 'rspec/its' +```ruby +require 'rspec/its' +``` ## Usage Use the `its` method to generate a nested example group with a single example that specifies the expected value of an attribute of the subject using `should`, `should_not` or `is_expected`. +The `its` method can also specify the block expectations of an attribute of the +subject using `will` or `will_not`. `its` accepts a symbol or a string, and a block representing the example. - its(:size) { should eq(1) } - its("length") { should eq(1) } +```ruby +its(:size) { should eq(1) } +its("length") { should eq(1) } +``` You can use a string with dots to specify a nested attribute (i.e. an attribute of the attribute of the subject). - its("phone_numbers.size") { should_not eq(0) } +```ruby +its("phone_numbers.size") { should_not eq(0) } +``` The following expect-style method is also available: - its(:size) { is_expected.to eq(1) } - +```ruby +its(:size) { is_expected.to eq(1) } +``` + as is this alias for pluralized use: - its(:keys) { are_expected.to eq([:key1, :key2]) - +```ruby +its(:keys) { are_expected.to eq([:key1, :key2]) } +``` + +The following block expect-style method is also available: + +```ruby +its(:size) { will_not raise_error } +``` + +as is this alias for pluralized use: + +```ruby +its(:keys) { will raise_error(NoMethodError) } +``` + When the subject implements the `[]` operator, you can pass in an array with a single key to refer to the value returned by that operator when passed that key as an argument. - its([:key]) { is_expected.to eq(value) } +```ruby +its([:key]) { is_expected.to eq(value) } +``` For hashes, multiple keys within the array will result in successive accesses into the hash. For example: - subject { {key1: {key2: 3} } } - its([:key1, :key2]) { is_expected.to eq(3) +```ruby +subject { {key1: {key2: 3} } } +its([:key1, :key2]) { is_expected.to eq(3) } +``` For other objects, multiple keys within the array will be passed as separate arguments in a single method call to [], as in: - subject { Matrix[ [:a, :b], [:c, :d] ] } - its([1,1]) { should eq(:d) } +```ruby +subject { Matrix[ [:a, :b], [:c, :d] ] } +its([1,1]) { should eq(:d) } +``` Metadata arguments are supported. - its(:size, focus: true) { should eq(1) } +```ruby +its(:size, focus: true) { should eq(1) } +``` ## Contributing Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cucumber.yml new/cucumber.yml --- old/cucumber.yml 2015-02-19 00:00:29.000000000 +0100 +++ new/cucumber.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,2 +0,0 @@ -default: --require features --strict --format progress --tags ~@wip features -wip: --require features --tags @wip:3 --wip features diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/features/its.feature new/features/its.feature --- old/features/its.feature 2015-02-19 00:00:29.000000000 +0100 +++ new/features/its.feature 2019-04-09 12:28:10.000000000 +0200 @@ -123,3 +123,54 @@ """ When I run rspec specifying line number 2 Then the examples should all pass + + Scenario: specify a method throws an expection + Given a file named "example_spec.rb" with: + """ruby + class Klass + def foo + true + end + end + + describe Klass do + subject { Klass.new } + its(:foo) { will_not raise_error } + its(:bar) { will raise_error(NoMethodError) } + end + """ + When I run rspec + Then the examples should all pass + + Scenario: specify a method does not throw an expection + Given a file named "example_spec.rb" with: + """ruby + class Klass; end + + describe Klass do + subject { Klass.new } + its(:foo) { will_not raise_error } + end + """ + When I run rspec + Then the example should fail + And the output should contain "Failure/Error: its(:foo) { will_not raise_error }" + And the output should contain "expected no Exception, got #<NoMethodError: undefined method `foo'" + + Scenario: examples will warn when using non block expectations + Given a file named "example_spec.rb" with: + """ruby + class Klass + def terminator + "back" + end + end + + describe Klass do + subject { Klass.new } + its(:terminator) { will be("back") } + end + """ + When I run rspec + Then the example should fail + And the output should contain "ArgumentError:" and "`will` only supports block expectations" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/features/step_definitions/additional_cli_steps.rb new/features/step_definitions/additional_cli_steps.rb --- old/features/step_definitions/additional_cli_steps.rb 2015-02-19 00:00:29.000000000 +0100 +++ new/features/step_definitions/additional_cli_steps.rb 2019-04-09 12:28:10.000000000 +0200 @@ -19,3 +19,14 @@ step %q{the output should not contain "0 examples"} step %q{the exit status should be 0} end + +Then(/^the example should fail$/) do + step %q{the output should contain "1 failure"} + step %q{the exit status should not be 0} +end + +Then(/^the output should contain "(.*?)" and "(.*?)"$/) do |string1, string2| + unless [string1, string2].all? { |s| all_output.include?(s) } + fail %Q{Both "#{string1}" and "#{string2}" were found in:\n#{all_output}} + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rspec/its/version.rb new/lib/rspec/its/version.rb --- old/lib/rspec/its/version.rb 2015-02-19 00:00:29.000000000 +0100 +++ new/lib/rspec/its/version.rb 2019-04-09 12:28:10.000000000 +0200 @@ -1,5 +1,5 @@ module RSpec module Its - VERSION = "1.2.0" + VERSION = "1.3.0" end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rspec/its.rb new/lib/rspec/its.rb --- old/lib/rspec/its.rb 2015-02-19 00:00:29.000000000 +0100 +++ new/lib/rspec/its.rb 2019-04-09 12:28:10.000000000 +0200 @@ -55,13 +55,14 @@ # its(['admin']) { should eq(:all_permissions) } # its(['john_doe', :permissions]) { should eq([:read, :write]) } # - # # You can still access to its regular methods this way: + # # You can still access its regular methods this way: # its(:keys) { should include(:max_users) } # its(:count) { should eq(2) } # end # # With an implicit subject, `is_expected` can be used as an alternative - # to `should` (e.g. for one-liner use) + # to `should` (e.g. for one-liner use). An `are_expected` alias is also + # supplied. # # @example # @@ -69,8 +70,26 @@ # its(:size) { is_expected.to eq(0) } # end # - # You can pass more than one arguments on the `its` block to add - # some options to the generated example + # With an implicit subject, `will` can be used as an alternative + # to `expect { subject.attribute }.to matcher` (e.g. for one-liner use). + # + # @example + # + # describe Array do + # its(:foo) { will raise_error(NoMethodError) } + # end + # + # With an implicit subject, `will_not` can be used as an alternative + # to `expect { subject.attribute }.to_not matcher` (e.g. for one-liner use). + # + # @example + # + # describe Array do + # its(:size) { will_not raise_error } + # end + # + # You can pass more than one argument on the `its` block to add + # some metadata to the generated example # # @example # @@ -122,6 +141,20 @@ end alias_method :are_expected, :is_expected + def will(matcher=nil, message=nil) + unless matcher.supports_block_expectations? + raise ArgumentError, "`will` only supports block expectations" + end + expect { __its_subject }.to matcher, message + end + + def will_not(matcher=nil, message=nil) + unless matcher.supports_block_expectations? + raise ArgumentError, "`will_not` only supports block expectations" + end + expect { __its_subject }.to_not matcher, message + end + def should(matcher=nil, message=nil) RSpec::Expectations::PositiveExpectationHandler.handle_matcher(__its_subject, matcher, message) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2015-02-19 00:00:29.000000000 +0100 +++ new/metadata 2019-04-09 12:28:10.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: rspec-its version: !ruby/object:Gem::Version - version: 1.2.0 + version: 1.3.0 platform: ruby authors: - Peter Alfvin autorequire: bindir: bin cert_chain: [] -date: 2015-02-18 00:00:00.000000000 Z +date: 2019-04-09 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rspec-core @@ -42,16 +42,16 @@ name: bundler requirement: !ruby/object:Gem::Requirement requirements: - - - "~>" + - - ">" - !ruby/object:Gem::Version - version: '1.3' + version: 1.3.0 type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - "~>" + - - ">" - !ruby/object:Gem::Version - version: '1.3' + version: 1.3.0 - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement @@ -86,14 +86,14 @@ requirements: - - "~>" - !ruby/object:Gem::Version - version: '0.5' + version: 0.6.2 type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: '0.5' + version: 0.6.2 description: RSpec extension gem for attribute matching email: - palfvin@gmail.com @@ -109,7 +109,6 @@ - LICENSE.txt - README.md - Rakefile -- cucumber.yml - features/its.feature - features/step_definitions/additional_cli_steps.rb - features/support/env.rb @@ -117,12 +116,18 @@ - lib/rspec/its/version.rb - rspec-its.gemspec - script/test_all +- script/update_rubygems_and_install_bundler - spec/rspec/its_spec.rb - spec/spec_helper.rb homepage: https://github.com/rspec/rspec-its licenses: - MIT -metadata: {} +metadata: + bug_tracker_uri: https://github.com/rspec/rspec-its/issues + changelog_uri: https://github.com/rspec/rspec-its/blob/v1.3.0/Changelog.md + documentation_uri: https://www.rubydoc.info/gems/rspec-its/1.3.0 + mailing_list_uri: https://groups.google.com/forum/#!forum/rspec + source_code_uri: https://github.com/rspec/rspec-its post_install_message: rdoc_options: [] require_paths: @@ -138,8 +143,7 @@ - !ruby/object:Gem::Version version: '0' requirements: [] -rubyforge_project: -rubygems_version: 2.4.3 +rubygems_version: 3.0.3 signing_key: specification_version: 4 summary: Provides "its" method formerly part of rspec-core diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rspec-its.gemspec new/rspec-its.gemspec --- old/rspec-its.gemspec 2015-02-19 00:00:29.000000000 +0100 +++ new/rspec-its.gemspec 2019-04-09 12:28:10.000000000 +0200 @@ -13,16 +13,24 @@ spec.homepage = "https://github.com/rspec/rspec-its" spec.license = "MIT" - spec.files = `git ls-files`.split($/) + spec.metadata = { + 'bug_tracker_uri' => 'https://github.com/rspec/rspec-its/issues', + 'changelog_uri' => "https://github.com/rspec/rspec-its/blob/v#{spec.version}/Changelog.md", + 'documentation_uri' => "https://www.rubydoc.info/gems/rspec-its/#{spec.version}", + 'mailing_list_uri' => 'https://groups.google.com/forum/#!forum/rspec', + 'source_code_uri' => 'https://github.com/rspec/rspec-its', + } + + spec.files = `git ls-files`.split($/) - %w[cucumber.yml] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] spec.add_runtime_dependency 'rspec-core', '>= 3.0.0' spec.add_runtime_dependency 'rspec-expectations', '>= 3.0.0' - spec.add_development_dependency 'bundler', '~> 1.3' + spec.add_development_dependency 'bundler', '> 1.3.0' spec.add_development_dependency 'rake', '~> 10.1.0' spec.add_development_dependency 'cucumber', '~> 1.3.8' - spec.add_development_dependency 'aruba', '~> 0.5' + spec.add_development_dependency "aruba", "~> 0.6.2" # 0.7 is broken on ruby 1.8.7 end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/script/test_all new/script/test_all --- old/script/test_all 2015-02-19 00:00:29.000000000 +0100 +++ new/script/test_all 2019-04-09 12:28:10.000000000 +0200 @@ -13,8 +13,11 @@ bin/rspec spec --format progress --profile echo "Running cucumber specs" -# TODO: it would be nice to figure out how to run the cukes w/o the overhead of -# bundler, but just running `bin/cucumber` can fail due to the fact that it -# shells out (via aruba) and executes `rspec`--which can pick up the wrong -# rspec version if we're not running with bundler. -bundle exec cucumber + +if ruby -e "exit(defined?(RUBY_PLATFORM) && RUBY_PLATFORM == 'java')"; then + # This is JRUBY which requires this one weird path trick... + PATH="${PWD}/bin:$PATH" \ + bundle exec cucumber --strict +else + bundle exec cucumber --strict +fi; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/script/update_rubygems_and_install_bundler new/script/update_rubygems_and_install_bundler --- old/script/update_rubygems_and_install_bundler 1970-01-01 01:00:00.000000000 +0100 +++ new/script/update_rubygems_and_install_bundler 2019-04-09 12:28:10.000000000 +0200 @@ -0,0 +1,22 @@ +#!/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 + +function is_ruby_23_plus { + if ruby -e "exit(RUBY_VERSION.to_f >= 2.3)"; then + return 0 + else + return 1 + fi +} + +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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/rspec/its_spec.rb new/spec/rspec/its_spec.rb --- old/spec/rspec/its_spec.rb 2015-02-19 00:00:29.000000000 +0100 +++ new/spec/rspec/its_spec.rb 2019-04-09 12:28:10.000000000 +0200 @@ -55,7 +55,11 @@ end its("name") { should eq("John") } its("name.size") { should eq(4) } - its("name.size.class") { should eq(Fixnum) } + if RUBY_VERSION >= "2.4.0" + its("name.size.class") { should eq(Integer) } + else + its("name.size.class") { should eq(Fixnum) } + end context "using should_not" do its("name") { should_not eq("Paul") } @@ -65,6 +69,10 @@ its("name") { is_expected.to eq("John") } end + context "using will_not" do + its("name") { will_not raise_error } + end + context "using are_expected" do its("name.chars.to_a") { are_expected.to eq(%w[J o h n]) } end @@ -86,7 +94,11 @@ end its([:a]) { should eq("Symbol: a") } its(['a']) { should eq("String: a") } - its([:b, 'c', 4]) { should eq("Symbol: b; String: c; Fixnum: 4") } + if RUBY_VERSION >= "2.4.0" + its([:b, 'c', 4]) { should eq("Symbol: b; String: c; Integer: 4") } + else + its([:b, 'c', 4]) { should eq("Symbol: b; String: c; Fixnum: 4") } + end its(:name) { should eq("George") } context "when referring to an attribute that doesn't exist" do context "it raises an error" do @@ -95,6 +107,10 @@ should eq(64) end.to raise_error(NoMethodError) end + + context "using will" do + its(:age) { will raise_error(NoMethodError) } + end end end @@ -109,6 +125,10 @@ its([:not_here]) { should be_nil } its([:a, :ghost]) { should be_nil } its([:deep, :ghost]) { expect { should eq("missing") }.to raise_error(NoMethodError) } + + context "using will" do + its([:deep, :ghost]) { will raise_error(NoMethodError) } + end end end end @@ -122,6 +142,10 @@ should eq("Symbol: a") end.to raise_error(NoMethodError) end + + context "using will" do + its([:a]) { will raise_error(NoMethodError) } + end end end @@ -232,6 +256,125 @@ end end end + + context "when expecting errors" do + subject do + Class.new do + def good; end + + def bad + raise ArgumentError, "message" + end + end.new + end + + its(:good) { will_not raise_error } + its(:bad) { will raise_error } + its(:bad) { will raise_error(ArgumentError) } + its(:bad) { will raise_error("message") } + its(:bad) { will raise_error(ArgumentError, "message") } + end + + context "when expecting throws" do + subject do + Class.new do + def good; end + + def bad + throw :abort, "message" + end + end.new + end + + its(:good) { will_not throw_symbol } + its(:bad) { will throw_symbol } + its(:bad) { will throw_symbol(:abort) } + its(:bad) { will throw_symbol(:abort, "message") } + end + + context "with change observation" do + subject do + Class.new do + attr_reader :count + + def initialize + @count = 0 + end + + def increment + @count += 1 + end + + def noop; end + end.new + end + + its(:increment) { will change { subject.count }.by(1) } + its(:increment) { will change { subject.count }.from(0) } + its(:increment) { will change { subject.count }.from(0).to(1) } + its(:increment) { will change { subject.count }.by_at_least(1) } + its(:increment) { will change { subject.count }.by_at_most(1) } + + its(:noop) { will_not change { subject.count } } + its(:noop) { will_not change { subject.count }.from(0) } + + its(:increment) do + expect { will_not change { subject.count }.by(0) }.to \ + raise_error(NotImplementedError, '`expect { }.not_to change { }.by()` is not supported') + end + + its(:increment) do + expect { will_not change { subject.count }.by_at_least(2) }.to \ + raise_error(NotImplementedError, '`expect { }.not_to change { }.by_at_least()` is not supported') + end + + its(:increment) do + expect { will_not change { subject.count }.by_at_most(3) }.to \ + raise_error(NotImplementedError, '`expect { }.not_to change { }.by_at_most()` is not supported') + end + end + + context "with output capture" do + subject do + Class.new do + def stdout + print "some output" + end + + def stderr + $stderr.print "some error" + end + + def noop; end + end.new + end + + its(:stdout) { will output("some output").to_stdout } + its(:stderr) { will output("some error").to_stderr } + + its(:noop) { will_not output("some error").to_stderr } + its(:noop) { will_not output("some output").to_stdout } + end + + context "#will with non block expectations" do + subject do + Class.new do + def terminator + "back" + end + end.new + end + + its(:terminator) do + expect { will be("back") }.to \ + raise_error(ArgumentError, '`will` only supports block expectations') + end + + its(:terminator) do + expect { will_not be("back") }.to \ + raise_error(ArgumentError, '`will_not` only supports block expectations') + end + end end end end
participants (1)
-
root