paramesan 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2ec829da8c0a763523519359e2759713f8ca3e3f
4
+ data.tar.gz: c56c3ef7d36f622257e685b20e08de3920cc9fbb
5
+ SHA512:
6
+ metadata.gz: cb0308e57a4659cc8939a28d6143fe87829594e3729ba17cbce7ce5c17e6fcb47c5c7c10130ea5c12e07a8cc215cd6c4943d4d0a10091977f51c04d3918c302b
7
+ data.tar.gz: adea8068805d95b7c483102ec1baea0b2f3c778095b49053082ef6125cd08ccebd39bd2fa484198ef2c9b9b85c21800122ae8ef6b603ec1ccd4976f3b5f5743c
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in paramesan.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Jeff Pace
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,93 @@
1
+ # Overview
2
+
3
+ Paramesan adds parameterized tests to test/unit in Ruby. This is to eliminate the boilerplate of
4
+ repetitious methods.
5
+
6
+ This is inspired by
7
+ [Parameterized-tests](https://github.com/junit-team/junit4/wiki/Parameterized-tests), the basis for
8
+ executing parameterized tests in Java, with JUnit4.
9
+
10
+ That concept was taken further by [JUnitParams](https://github.com/Pragmatists/JUnitParams), which
11
+ expands the options that are supported, and has been an epiphany for the way that I view and write
12
+ unit tests, which initially focused on the behavior (the process or code), then looks at the input
13
+ and output as data that go through the process.
14
+
15
+ I looked for the equivalent in Ruby, and the closest that I found was
16
+ [param_test](https://www.ruby-toolbox.com/projects/param_test). That, however, uses activesupport,
17
+ which is included in Rails, but I wanted a version that ran in a pure Ruby environment, using only
18
+ Test::Unit.
19
+
20
+ Ergo, paramesan, which as of this writing, allows a very primitive set of options for parameterized
21
+ tests.
22
+
23
+ # Example
24
+
25
+ ## Before
26
+
27
+ ```ruby
28
+ require 'pvn/log/options'
29
+ require 'test/unit'
30
+
31
+ class FormatOptionTest < Test::Unit::TestCase
32
+ def assert_formatter expected, *types
33
+ types.each do |type|
34
+ fmtr = Pvn::Log::FormatOption.new type
35
+ assert_kind_of expected, fmtr.formatter, "type: #{type}"
36
+ end
37
+ end
38
+
39
+ def test_oneline
40
+ assert_formatter Pvn::Log::FormatOneLine, "single", "single-line", "si", "oneline"
41
+ end
42
+
43
+ def test_summary
44
+ assert_formatter Pvn::Log::FormatSummary, "summary", "su"
45
+ end
46
+
47
+ def test_revision_only
48
+ assert_formatter Pvn::Log::FormatRevisionOnly, "revision", "rev", "revisiononly"
49
+ end
50
+
51
+ def test_revision_author
52
+ assert_formatter Pvn::Log::FormatRevisionAuthor, "revauthor", "revauth", "revisionauthor"
53
+ end
54
+
55
+ def test_colorized
56
+ assert_formatter Pvn::Log::FormatColorized, "color", "colorized"
57
+ end
58
+ end
59
+ ```
60
+
61
+ ## After
62
+
63
+ ```ruby
64
+ require 'pvn/log/options'
65
+ require 'test/unit'
66
+ require 'paramesan'
67
+
68
+ class FormatOptionTest < Test::Unit::TestCase
69
+ extend Paramesan
70
+
71
+ param_test [
72
+ [ Pvn::Log::FormatOneLine, "single", "single-line", "si", "oneline" ],
73
+ [ Pvn::Log::FormatSummary, "summary", "su" ],
74
+ [ Pvn::Log::FormatRevisionOnly, "revision", "rev", "revisiononly" ],
75
+ [ Pvn::Log::FormatRevisionAuthor, "revauthor", "revauth", "revisionauthor" ],
76
+ [ Pvn::Log::FormatColorized, "color", "colorized" ],
77
+ ] do |exp, *types|
78
+ fmts = Pvn::Log::Formats.new
79
+ types.each do |type|
80
+ assert_equal exp, fmts.class_for(type), "type: #{type}"
81
+ end
82
+ end
83
+ end
84
+ ```
85
+
86
+ ## Contributing
87
+
88
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jpace/paramesan.
89
+
90
+ ## License
91
+
92
+ This gem is available as open source under the terms of the [MIT
93
+ License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "paramesan"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require "paramesan/version"
5
+
6
+ module Paramesan
7
+ def param_test paramlist, &blk
8
+ puts "self: #{self}"
9
+
10
+ paramlist.each do |params|
11
+ basename = "test_" + params.to_s.gsub(Regexp.new('[^\w]+'), '_')
12
+ mname = basename
13
+
14
+ count = 1
15
+ while instance_methods.include? mname.to_sym
16
+ mname += "_#{count}"
17
+ end
18
+
19
+ define_method mname do
20
+ instance_exec(params, &blk)
21
+ puts
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'pathname'
5
+
6
+ module Paramesan
7
+ VERSION = "0.0.1"
8
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'paramesan/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "paramesan"
8
+ spec.version = Paramesan::VERSION
9
+ spec.authors = ["Jeff Pace"]
10
+ spec.email = ["jeugenepace@gmail.com"]
11
+
12
+ spec.summary = %q{Parameterized tests}
13
+ spec.description = %q{Parameterized tests}
14
+ spec.homepage = "https://github.com/jpace/paramesan"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.12"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "test-unit", "~> 3.1.5"
33
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paramesan
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Pace
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-06-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.1.5
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.1.5
55
+ description: Parameterized tests
56
+ email:
57
+ - jeugenepace@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".travis.yml"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - lib/paramesan.rb
71
+ - lib/paramesan/version.rb
72
+ - paramesan.gemspec
73
+ homepage: https://github.com/jpace/paramesan
74
+ licenses:
75
+ - MIT
76
+ metadata:
77
+ allowed_push_host: https://rubygems.org
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.6.3
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Parameterized tests
98
+ test_files: []