A summary of data about the Ruby ecosystem.

https://github.com/tomykaira/rspec-parameterized

RSpec::Parameterized supports simple parameterized test syntax in rspec.
https://github.com/tomykaira/rspec-parameterized

Keywords from Contributors

activerecord activejob mvc rubygems feature-flag rspec rubocop code-formatter static-code-analysis ruby-gem

Last synced: about 7 hours ago
JSON representation

Repository metadata

RSpec::Parameterized supports simple parameterized test syntax in rspec.

README.md

RSpec::Parameterized Gem Version rspec

Support simple parameterized test syntax in rspec.

# Nested Array Style
describe "plus" do
  where(:a, :b, :answer) do
    [
      [1 , 2 , 3],
      [5 , 8 , 13],
      [0 , 0 , 0]
    ]
  end

  with_them do
    it "should do additions" do
      expect(a + b).to eq answer
    end
  end

  with_them do
    # Can browse parameters via `params` method in with_them block
    # Can browse all parameters via `all_params` method in with_them block
    it "#{params[:a]} + #{params[:b]} == #{params[:answer]}" do
      expect(a + b).to eq answer
    end
  end
end

# Hash and Array Style
# Given parameters is each value combinations
# On this case
# [
#   [1, 5, 2],
#   [1, 5, 4],
#   [1, 7, 2],
#   [1, 7, 4],
#   [1, 9, 2],
#   [1, 9, 4],
#   [3, 5, 2],
#   [3, 5, 4],
#   [3, 7, 2],
#   [3, 7, 4],
#   [3, 9, 2],
#   [3, 9, 4]
# ]
describe "Hash arguments" do
  where(a: [1, 3], b: [5, 7, 9], c: [2, 4])

  with_them do
    it "sums is even" do
      expect(a + b + c).to be_even
    end
  end
end

# Table Syntax Style (like Groovy spock)
# Need ruby-2.1 or later
describe "plus" do
  using RSpec::Parameterized::TableSyntax

  where(:a, :b, :answer) do
    1 | 2 | 3
    5 | 8 | 13
    0 | 0 | 0
  end

  with_them do
    it "should do additions" do
      expect(a + b).to eq answer
    end
  end
end

# Verbose Syntax
# For complex inputs or if you just want to be super explicit
describe "Verbose syntax" do
  where do
    {
      "positive integers" => {
        a: 1,
        b: 2,
        answer: 3,
      },
      "negative_integers" => {
        a: -1,
        b: -2,
        answer: -3,
      },
      "mixed_integers" => {
        a: 3,
        b: -3,
        answer: 0,
      },
    }
  end

  with_them do
    it "should do additions" do
      expect(a + b).to eq answer
    end
  end
end

# It's also possible to override each combination name using magic variable :case_name
# Output:
# Custom names for regular syntax
#   positive integers
#     should do additions
#   negative integers
#     should do additions
#   mixed integers
#     should do additions
describe "Custom names for regular syntax" do
  where(:case_name, :a, :b, :answer) do
    [
      ["positive integers",  6,  2,  8],
      ["negative integers", -1, -2, -3],
      ["mixed integers", -5,  3, -2],
    ]
  end

  with_them do
    it "should do additions" do
      expect(a + b).to eq answer
    end
  end
end

# Or :case_names lambda for hash syntax
# Output:
# Custom naming for hash syntax
#   1 + 5 + 2
#     sum is even
#   1 + 5 + 4
#     sum is even
#   1 + 7 + 2
#     sum is even
#   ...
describe "Custom naming for hash syntax" do
  where(case_names: ->(a, b, c){"#{a} + #{b} + #{c}"}, a: [1, 3], b: [5, 7, 9], c: [2, 4])

  with_them do
    it "sum is even" do
      expect(a + b + c).to be_even
    end
  end
end

# Use ref(:symbol) to use let/let! defined variables in the where block
# Use lazy when you want to create let/let! variables after the where block
#
# Failures will be more readable in the future - https://github.com/tomykaira/rspec-parameterized/pull/65
describe "lazy and ref types" do
  let(:one) { 1 }
  let(:four) { 4 }

  where(:a, :b, :result) do
    [
      [ref(:one), ref(:four), lazy { two + three }]
    ]
  end

  with_them do
    context "use let after where block" do
      let(:two) { 2 }
      let(:three) { 3 }

      it 'should equal 5' do
        expect(a + b).to eq result
      end
    end
  end
end

I was inspired by udzura's mock.

Support Versions

Ruby-2.6.0 or later.

Installation

group :test do
  gem "rspec-parameterized", ">= 1.0.0"
end

Usage

Require rspec-parameterized from your spec_helper.rb.

require 'rspec-parameterized'

Follow the sample spec above.

Arguments given to with_them is directly passed to describe. You can specify :pending, :focus, etc. here.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Also see


Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 7 days ago

Total Commits: 177
Total Committers: 22
Avg Commits per committer: 8.045
Development Distribution Score (DDS): 0.644

Commits in past year: 14
Committers in past year: 2
Avg Commits per committer in past year: 7.0
Development Distribution Score (DDS) in past year: 0.286

Name Email Commits
sue445 s****5@s****t 63
joker1007 k****t@g****m 47
tomykaira t****a@g****m 34
dependabot[bot] 4****] 6
aliaksandr-martsinovich a****h@g****m 5
Mitsutaka Mimura t****m@g****m 3
hana-da h****a 2
Shinji Yoshida y****m@g****m 2
Olle Jonsson o****n@g****m 2
Aleksei Lipniagov a****v@g****m 1
Isamu Mogi s****c@g****m 1
ryonext r****s@g****m 1
sueyoshi_go g****i@d****p 1
HaiTo t****s@g****m 1
Junichi Ito j****t@s****p 1
Matija Folnovic m****c@g****m 1
Michał Zając m****c@g****m 1
Oscar Alberto Tovar o****r@g****m 1
Ryo Naruse n****1@g****m 1
nalabjp n****p@g****m 1
soartec-lab i****o@s****k 1
yiyenene g****d@a****p 1

Committer domains:


Issue and Pull Request metadata

Last synced: 11 days ago

Total issues: 26
Total pull requests: 71
Average time to close issues: 10 months
Average time to close pull requests: 16 days
Total issue authors: 16
Total pull request authors: 22
Average comments per issue: 1.81
Average comments per pull request: 0.94
Merged pull request: 64
Bot issues: 0
Bot pull requests: 4

Past year issues: 1
Past year pull requests: 7
Past year average time to close issues: N/A
Past year average time to close pull requests: 1 minute
Past year issue authors: 1
Past year pull request authors: 2
Past year average comments per issue: 1.0
Past year average comments per pull request: 0.0
Past year merged pull request: 5
Past year bot issues: 0
Past year bot pull requests: 2

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/tomykaira/rspec-parameterized

Top Issue Authors

  • sue445 (5)
  • joker1007 (4)
  • tomykaira (3)
  • thedrow (2)
  • caalberts (1)
  • mttkay (1)
  • stanhu (1)
  • PetrVales (1)
  • ryogift (1)
  • malcolm-pro (1)
  • pyromaniac (1)
  • dleidert (1)
  • balasankarc (1)
  • tnir (1)
  • hamilton-keisuke (1)

Top Pull Request Authors

  • sue445 (26)
  • joker1007 (17)
  • dependabot[bot] (4)
  • baban (2)
  • aliaksandr-martsinovich (2)
  • oatovar (2)
  • shinji-yoshida (2)
  • olleolleolle (2)
  • takkanm (1)
  • Quintasan (1)
  • HaiTo (1)
  • yiyenene (1)
  • nalabjp (1)
  • malcolm-pro (1)
  • ryonext (1)

Top Issue Labels

Top Pull Request Labels

  • dependencies (4)
  • github_actions (2)

Package metadata

gem.coop: rspec-parameterized

RSpec::Parameterized supports simple parameterized test syntax in rspec.

  • Homepage: https://github.com/tomykaira/rspec-parameterized
  • Documentation: http://www.rubydoc.info/gems/rspec-parameterized/
  • Licenses: MIT
  • Latest release: 2.0.1 (published 12 days ago)
  • Last Synced: 2025-12-09T17:30:37.462Z (2 days ago)
  • Versions: 30
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 71,128,632 Total
  • Docker Downloads: 435,118,677
  • Rankings:
    • Dependent repos count: 0.0%
    • Dependent packages count: 0.0%
    • Average: 0.169%
    • Docker downloads count: 0.281%
    • Downloads: 0.395%
  • Maintainers (3)
rubygems.org: rspec-parameterized

RSpec::Parameterized supports simple parameterized test syntax in rspec.

  • Homepage: https://github.com/tomykaira/rspec-parameterized
  • Documentation: http://www.rubydoc.info/gems/rspec-parameterized/
  • Licenses: MIT
  • Latest release: 2.0.1 (published 12 days ago)
  • Last Synced: 2025-12-09T14:30:55.708Z (3 days ago)
  • Versions: 30
  • Dependent Packages: 60
  • Dependent Repositories: 3,028
  • Downloads: 71,123,920 Total
  • Docker Downloads: 435,118,677
  • Rankings:
    • Docker downloads count: 0.347%
    • Downloads: 0.469%
    • Dependent packages count: 0.511%
    • Dependent repos count: 0.569%
    • Average: 1.673%
    • Stargazers count: 2.859%
    • Forks count: 5.279%
  • Maintainers (3)

Dependencies

.github/workflows/rspec.yml actions
  • actions/checkout v2 composite
  • ruby/setup-ruby v1 composite
rspec-parameterized.gemspec rubygems
  • rake >= 12.0.0 development
  • rspec-parameterized-core < 2
  • rspec-parameterized-table_syntax < 2

Score: 29.98793155321129