param_test 0.0.2 → 0.1.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  param_test
2
2
  ==========
3
3
 
4
- **Parametrized unit tests for Ruby/ActiveSupport**
4
+ **Parameterized unit tests for Ruby/ActiveSupport**
5
5
 
6
6
  This gem extends `ActiveSupport::TestCase` with a simple `param_test` class method that generates multiple tests with different parameters from a single code block.
7
7
 
@@ -60,7 +60,16 @@ For better readability, any `nil` parameters will be string substituted as a `"n
60
60
 
61
61
  ## Installation
62
62
 
63
- gem install param_test
63
+ If using Rails 4, add to your Gemfile:
64
+
65
+ gem 'param_test', '~> 0.1.0'
66
+
67
+ If using Rails 3.2, add to your Gemfile:
68
+
69
+ gem 'param_test', '~> 0.0.2'
70
+
71
+ (Since you generally only use param_test in tests, you probably want to add this to
72
+ the group `:test` in your Gemfile.)
64
73
 
65
74
 
66
75
  ## License
data/param_test.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'param_test'
3
- s.version = '0.0.2'
3
+ s.version = '0.1.0.rc1'
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.authors = ['Nik Haldimann']
6
6
  s.email = ['nhaldimann@gmail.com']
7
7
  s.homepage = 'https://github.com/nikhaldi/param-test-ruby'
8
- s.summary = 'Parametrized unit tests for Ruby/ActiveSupport'
9
- s.description = 'Parametrized unit tests for Ruby/ActiveSupport'
8
+ s.summary = 'Parameterized unit tests for Ruby/ActiveSupport'
9
+ s.description = 'Parameterized unit tests for Ruby/ActiveSupport'
10
10
 
11
- s.add_runtime_dependency 'activesupport', '~> 3.2'
11
+ s.add_runtime_dependency 'activesupport', '~> 4.0.0.rc2'
12
12
  s.add_development_dependency 'rake'
13
13
 
14
14
  s.files = `git ls-files`.split("\n")
@@ -0,0 +1,9 @@
1
+ This directory contains the complete example code used in a blog post
2
+ about param_test at
3
+ http://blog.nikhaldimann.com/2013/01/23/robust-parametrized-unit-tests-in-ruby/
4
+
5
+ The easiest way to run individual test examples is via this method from:
6
+
7
+ $ ruby -I"test/blog" test/blog/multiple_params_test.rb
8
+
9
+ (Assuming we're in the base directory of the param_test source.)
@@ -0,0 +1,11 @@
1
+ require 'whitespace'
2
+ require 'active_support/test_case'
3
+ require 'test/unit'
4
+
5
+ class BadDeclarativeTest < ActiveSupport::TestCase
6
+ [" ", "\n"].each do |input|
7
+ test "#{input} includes whitespace" do
8
+ assert includes_whitespace? input
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'whitespace'
2
+ require 'test/unit'
3
+
4
+ class BadLoopingTest < Test::Unit::TestCase
5
+ def test_includes_whitespace
6
+ inputs = ["hello world", "foo bar", "foo", "bar\n"]
7
+ inputs.each do |input|
8
+ assert includes_whitespace? input
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'whitespace'
2
+ require 'active_support/test_case'
3
+ require 'test/unit'
4
+
5
+ class BetterDeclarativeTest < ActiveSupport::TestCase
6
+ ["hello world", "foo bar", "foo", "bar\n"].each do |input|
7
+ test "#{input} includes whitespace" do
8
+ assert includes_whitespace? input
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ require 'whitespace'
2
+ require 'param_test'
3
+ require 'test/unit'
4
+
5
+ class MultipleParamsTest < ActiveSupport::TestCase
6
+ param_test "%s includes whitespace is %s", [
7
+ ["hello world", true],
8
+ ["foo bar", true],
9
+ ["foo", false],
10
+ ] do |input, expected|
11
+ assert_equal expected, includes_whitespace?(input)
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ require 'whitespace'
2
+ require 'param_test'
3
+ require 'test/unit'
4
+
5
+ class SingleParamTest < ActiveSupport::TestCase
6
+ param_test "%s includes whitespace",
7
+ ["hello world", "foo bar", "foo", "bar\n"] do |input|
8
+ assert includes_whitespace? input
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ # Whether a given string includes any whitespace.
2
+ def includes_whitespace?(string)
3
+ not string.match(/\s/).nil?
4
+ end
@@ -8,7 +8,7 @@ class ParamTestMetaTest < ActiveSupport::TestCase
8
8
  end
9
9
 
10
10
  def assert_has_test_method(clazz, expected_method_name)
11
- assert_include clazz.instance_methods, expected_method_name
11
+ assert_includes clazz.instance_methods, expected_method_name
12
12
  end
13
13
 
14
14
  test "empty parameters adds no tests" do
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: param_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.1.0.rc1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nik Haldimann
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-23 00:00:00.000000000 Z
12
+ date: 2013-06-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '3.2'
21
+ version: 4.0.0.rc2
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: '3.2'
29
+ version: 4.0.0.rc2
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rake
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
- description: Parametrized unit tests for Ruby/ActiveSupport
46
+ description: Parameterized unit tests for Ruby/ActiveSupport
47
47
  email:
48
48
  - nhaldimann@gmail.com
49
49
  executables: []
@@ -58,6 +58,13 @@ files:
58
58
  - lib/active_support/testing/parametrized.rb
59
59
  - lib/param_test.rb
60
60
  - param_test.gemspec
61
+ - test/blog/README.md
62
+ - test/blog/bad_declarative_test.rb
63
+ - test/blog/bad_looping_test.rb
64
+ - test/blog/better_declarative_test.rb
65
+ - test/blog/multiple_params_test.rb
66
+ - test/blog/single_param_test.rb
67
+ - test/blog/whitespace.rb
61
68
  - test/helper.rb
62
69
  - test/param_test_meta_test.rb
63
70
  - test/param_test_test.rb
@@ -76,16 +83,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
83
  required_rubygems_version: !ruby/object:Gem::Requirement
77
84
  none: false
78
85
  requirements:
79
- - - ! '>='
86
+ - - ! '>'
80
87
  - !ruby/object:Gem::Version
81
- version: '0'
88
+ version: 1.3.1
82
89
  requirements: []
83
90
  rubyforge_project:
84
- rubygems_version: 1.8.24
91
+ rubygems_version: 1.8.23
85
92
  signing_key:
86
93
  specification_version: 3
87
- summary: Parametrized unit tests for Ruby/ActiveSupport
94
+ summary: Parameterized unit tests for Ruby/ActiveSupport
88
95
  test_files:
96
+ - test/blog/README.md
97
+ - test/blog/bad_declarative_test.rb
98
+ - test/blog/bad_looping_test.rb
99
+ - test/blog/better_declarative_test.rb
100
+ - test/blog/multiple_params_test.rb
101
+ - test/blog/single_param_test.rb
102
+ - test/blog/whitespace.rb
89
103
  - test/helper.rb
90
104
  - test/param_test_meta_test.rb
91
105
  - test/param_test_test.rb