Skip to content

Commit

Permalink
Merge pull request #98 from rspec/prep-for-version-2-0-0
Browse files Browse the repository at this point in the history
Modernise rspec-its, prepare version 2.0.0 dropping outdated RSpec / Ruby
  • Loading branch information
JonRowe authored Nov 3, 2024
2 parents 6dec295 + 8e3ceb1 commit c75e524
Show file tree
Hide file tree
Showing 19 changed files with 513 additions and 662 deletions.
96 changes: 10 additions & 86 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
branches:
- '*'
env:
BRANCH: '3-12-maintenance'
RSPEC_CI: true
jobs:
test:
Expand All @@ -18,77 +17,30 @@ jobs:
strategy:
matrix:
ruby:
- '3.3'
- '3.2'
- '3.1'
- '3.0'
- 2.7
- 2.6
- 2.5
- 2.4
- 2.3
- 2.2
- 2.1.9
env:
-
BRANCH: "main"
include:
- ruby: jruby-9.2.13.0
- ruby: '3.3'
name_extra: "against RSpec 3.13"
env:
JRUBY_OPTS: "--dev"
# Compatibility builds
BRANCH: "3-13-maintenance"
- ruby: '3.2'
name_extra: "against RSpec 3.12"
name_extra: "against RSpec 3.13"
env:
BRANCH: "3-12-maintenance"
BRANCH: "3-13-maintenance"
- ruby: '3.1'
name_extra: "against RSpec 3.11"
name_extra: "against RSpec 3.13"
env:
BRANCH: "3-11-maintenance"
- ruby: '3.1'
name_extra: "against RSpec 3.10"
env:
BRANCH: "3-10-maintenance"
- ruby: '3.0'
name_extra: "against RSpec 3.9"
env:
BRANCH: "3-9-maintenance"
- ruby: '3.0'
name_extra: "against RSpec 3.8"
env:
BRANCH: "3-8-maintenance"
- ruby: '3.0'
name_extra: "against RSpec 3.7"
env:
BRANCH: "3-7-maintenance"
- ruby: '3.0'
name_extra: "against RSpec 3.6"
env:
BRANCH: "3-6-maintenance"
- ruby: '3.0'
name_extra: "against RSpec 3.5"
env:
BRANCH: "3-5-maintenance"
- ruby: '3.0'
name_extra: "against RSpec 3.4"
env:
BRANCH: "3-4-maintenance"
- ruby: '3.0'
name_extra: "against RSpec 3.3"
env:
BRANCH: "3-3-maintenance"
- ruby: '3.0'
name_extra: "against RSpec 3.2"
env:
BRANCH: "3-2-maintenance"
- ruby: '3.0'
name_extra: "against RSpec 3.1"
env:
BRANCH: "3-1-maintenance"
BRANCH: "3-13-maintenance"
- ruby: '3.0'
name_extra: "against RSpec 3.0"
name_extra: "against RSpec 3.13"
env:
BRANCH: "3-0-maintenance"

BRANCH: "3-13-maintenance"
fail-fast: false
continue-on-error: ${{ matrix.allow_failure || endsWith(matrix.ruby, 'head') }}
env: ${{ matrix.env }}
Expand All @@ -101,31 +53,3 @@ jobs:
- run: script/update_rubygems_and_install_bundler
- run: bundle install --binstubs --standalone
- run: script/test_all

legacy:
name: Legacy Ruby Builds (${{ matrix.container.version }})
runs-on: ubuntu-20.04
container:
image: ${{ matrix.container.tag }}
options: ${{ matrix.container.options || '--add-host github-complains-if-this-is-empty.com:127.0.0.1' }}
strategy:
fail-fast: false
matrix:
container:
- version: "2.0"
tag: ghcr.io/rspec/docker-ci:2.0.0
- version: "1.9.3"
tag: ghcr.io/rspec/docker-ci:1.9.3
- version: "JRuby 1.7"
tag: ghcr.io/rspec/docker-ci:jruby-1.7
- version: "JRuby 9.1.17.0"
tag: ghcr.io/rspec/docker-ci:jruby-9.1.17.0
options: "--add-host rubygems.org:151.101.129.227 --add-host api.rubygems.org:151.101.129.227"
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
LEGACY_CI: true
JRUBY_OPTS: ${{ matrix.container.jruby_opts || '--dev' }}
steps:
- uses: actions/checkout@v3
- run: script/legacy_setup.sh
- run: script/test_all
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ spec/reports
test/tmp
test/version_tmp
tmp
bin/*
7 changes: 7 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### 2.0.0.pre

Version 2.0.0 is a maintenance release, it drops support for Ruby below 3, and
changes the supported RSpec version to "main" and current release series.
(At the time of writing this is 3.13.x, but it means the current supported
release only).

### 1.3.1 / 2024-10-23
[full changelog](http://github.com/rspec/rspec-its/compare/v1.3.0...v1.3.1)

Expand Down
38 changes: 13 additions & 25 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,26 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in rspec-its.gemspec
gemspec

%w[rspec rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib|
branch = ENV.fetch('BRANCH','main')
branch = ENV.fetch('BRANCH', 'main')
library_path = File.expand_path("../../#{lib}", __FILE__)

if File.exist?(library_path) && !ENV['USE_GIT_REPOS']
gem lib, :path => library_path
gem lib, path: library_path
elsif lib == 'rspec'
gem 'rspec', :git => "https://github.com/rspec/rspec-metagem.git", :branch => branch
gem 'rspec', git: "https://github.com/rspec/rspec-metagem.git", branch: branch
else
gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => branch
gem lib, git: "https://github.com/rspec/#{lib}.git", branch: branch
end
end

if RUBY_VERSION < '2.2.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/)
gem 'ffi', '< 1.10'
elsif RUBY_VERSION < '2.4.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/)
gem 'ffi', '< 1.15'
elsif RUBY_VERSION < '2.0'
gem 'ffi', '< 1.9.19' # ffi dropped Ruby 1.8 support in 1.9.19
elsif RUBY_VERSION < '2.3.0'
gem 'ffi', '~> 1.12.0'
else
gem 'ffi', '~> 1.15.0'
end

# test coverage
# gem 'simplecov', :require => false

gem 'contracts', '< 0.16' if RUBY_VERSION < '1.9.0'

gem 'coveralls', :require => false, :platform => :mri_20

eval File.read('Gemfile-custom') if File.exist?('Gemfile-custom')
gem 'aruba', '~> 2.2.0'
gem 'bundler', '> 2.0.0'
gem 'coveralls', require: false
gem 'cucumber', '>= 1.3.8'
gem 'ffi', '~> 1.17.0'
gem 'matrix', '~> 0.4.2'
gem 'rake', '~> 13.2.0'
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(The MIT License)

Copyright (c) 2024 The RSpec Development Team
Copyright (c) 2013 Peter Alfvin
Copyright (c) 2012 David Chelimsky, Myron Marston
Copyright (c) 2006 David Chelimsky, The RSpec Development Team
Copyright (c) 2005 Steven Baker

MIT License

Expand Down
26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RSpec::Its [![Build Status](https://travis-ci.org/rspec/rspec-its.svg)](https://travis-ci.org/rspec/rspec-its)
# RSpec::Its [![Build Status](https://github.com/rspec/rspec-its/actions/workflows/ci.yml/badge.svg)](https://github.com/rspec/rspec-its/actions/workflows/ci.yml/badge.svg)

RSpec::Its provides the `its` method as a short-hand to specify the expected value of an attribute.

Expand Down Expand Up @@ -26,33 +26,31 @@ 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`.
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 `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.

```ruby
its(:size) { should eq(1) }
its("length") { should eq(1) }
its(:size) { is_expected.to eq(1) }
its("length") { is_expected.to eq(1) }
```

You can use a string with dots to specify a nested attribute (i.e. an
attribute of the attribute of the subject).

```ruby
its("phone_numbers.size") { should_not eq(0) }
its("phone_numbers.size") { is_expected.to_not eq(0) }
```

The following expect-style method is also available:
The following should-style method is also available:

```ruby
its(:size) { is_expected.to eq(1) }
its(:size) { should eq(1) }
```

as is this alias for pluralized use:
as is an alias of `is_expected` for pluralized use:

```ruby
its(:keys) { are_expected.to eq([:key1, :key2]) }
Expand Down Expand Up @@ -88,13 +86,13 @@ For other objects, multiple keys within the array will be passed as separate arg

```ruby
subject { Matrix[ [:a, :b], [:c, :d] ] }
its([1,1]) { should eq(:d) }
its([1,1]) { is_expected.to eq(:d) }
```

Metadata arguments are supported.

```ruby
its(:size, focus: true) { should eq(1) }
its(:size, focus: true) { is_expected.to eq(1) }
```

## Contributing
Expand Down
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "bundler"
Bundler.setup
Bundler::GemHelper.install_tasks
Expand All @@ -13,4 +15,4 @@ RSpec::Core::RakeTask.new(:spec) do |t|
t.ruby_opts = %w[-w]
end

task :default => [:spec, :cucumber]
task default: %i[spec cucumber]
Loading

0 comments on commit c75e524

Please sign in to comment.