Skip to content

Setup CI #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Dec 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions .github/workflows/main.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: RSpec

on:
push:
branches:
- main
pull_request:

jobs:
test:

runs-on: ubuntu-latest
strategy:
matrix:
ruby-version:
- '2.6'
- '2.7'
- '3.0'
- '3.1'
- '3.2'

steps:
- uses: actions/checkout@v3
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@

# rspec failure tracking
.rspec_status

Gemfile.lock
13 changes: 0 additions & 13 deletions .rubocop.yml

This file was deleted.

6 changes: 0 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,3 @@ source "https://rubygems.org"

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

gem "rake", "~> 13.0"

gem "rspec", "~> 3.0"

gem "rubocop", "~> 1.21"
6 changes: 1 addition & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@ require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

require "rubocop/rake_task"

RuboCop::RakeTask.new

task default: %i[spec rubocop]
task default: %i[spec]
49 changes: 0 additions & 49 deletions lib/rspec/parameterized/table.rb

This file was deleted.

25 changes: 4 additions & 21 deletions lib/rspec/parameterized/table_syntax.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
# frozen_string_literal: true

require_relative "table_syntax/version"
require 'rspec/parameterized/table'
require "rspec/parameterized/table_syntax/version"
require 'rspec/parameterized/table_syntax/table'
require 'rspec/parameterized/table_syntax/table_syntax_implement'
require "rspec/parameterized/core"
require 'binding_of_caller'

module RSpec
module Parameterized
module TableSyntaxImplement
def |(other)
where_binding = binding.of_caller(1) # get where block binding
caller_instance = eval("self", where_binding) # get caller instance (ExampleGroup)

if caller_instance.instance_variable_defined?(:@__parameter_table)
table = caller_instance.instance_variable_get(:@__parameter_table)
else
table = RSpec::Parameterized::Table.new
caller_instance.instance_variable_set(:@__parameter_table, table)
end

row = Table::Row.new(self)
table.add_row(row)
row.add_param(other)
table
end
end

module TableSyntax
if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create("3.2.0.rc1")
refine Object do
Expand Down
51 changes: 51 additions & 0 deletions lib/rspec/parameterized/table_syntax/table.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module RSpec
module Parameterized
module TableSyntax
class Table
attr_reader :last_row

def initialize
@rows = []
@last_row = nil
end

def add_row(row)
unless @rows.find {|r| r.object_id == row.object_id}
@rows << row
@last_row = row
end
self
end

def add_param_to_last_row(param)
last_row.add_param(param)
self
end
alias :| :add_param_to_last_row

def to_a
@rows.map(&:to_a)
end
alias :to_params :to_a

class Row
def initialize(param)
@params = [param]
end

def add_param(param)
@params << param
end

def to_a
@params
end

def to_params
[@params]
end
end
end
end
end
end
24 changes: 24 additions & 0 deletions lib/rspec/parameterized/table_syntax/table_syntax_implement.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module RSpec
module Parameterized
module TableSyntax
module TableSyntaxImplement
def |(other)
where_binding = binding.of_caller(1) # get where block binding
caller_instance = eval("self", where_binding) # get caller instance (ExampleGroup)

if caller_instance.instance_variable_defined?(:@__parameter_table)
table = caller_instance.instance_variable_get(:@__parameter_table)
else
table = RSpec::Parameterized::TableSyntax::Table.new
caller_instance.instance_variable_set(:@__parameter_table, table)
end

row = Table::Row.new(self)
table.add_row(row)
row.add_param(other)
table
end
end
end
end
end
25 changes: 14 additions & 11 deletions rspec-parameterized-table_syntax.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ require_relative "lib/rspec/parameterized/table_syntax/version"
Gem::Specification.new do |spec|
spec.name = "rspec-parameterized-table_syntax"
spec.version = Rspec::Parameterized::TableSyntax::VERSION
spec.authors = ["sue445"]
spec.email = ["[email protected]"]
spec.authors = ["sue445", "tomykaira", "joker1007"]
spec.email = ["[email protected]", "[email protected]"]

spec.summary = "TODO: Write a short summary, because RubyGems requires one."
spec.description = "TODO: Write a longer description or delete this line."
spec.homepage = "TODO: Put your gem's website or public repo URL here."
spec.description = %q{RSpec::Parameterized supports simple parameterized test syntax in rspec.}
spec.summary = %q{RSpec::Parameterized supports simple parameterized test syntax in rspec.
I was inspired by [udzura's mock](https://gist.github.com/1881139).}

spec.homepage = "https://github.com/rspec-parameterized/rspec-parameterized-table_syntax"
spec.license = "MIT"
spec.required_ruby_version = ">= 2.6.0"

spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
spec.metadata["source_code_uri"] = spec.homepage
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
Expand All @@ -31,8 +31,11 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

# Uncomment to register a new dependency of your gem
# spec.add_dependency "example-gem", "~> 1.0"
spec.add_dependency "binding_of_caller"
spec.add_dependency "rspec-parameterized-core"

spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"

# For more information and examples about making a new gem, check out our
# guide at: https://bundler.io/guides/creating_gem.html
Expand Down
Loading