simple_assertions 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +4 -9
- data/Rakefile +4 -4
- data/lib/simple_assertions/assert_errors_on.rb +1 -1
- data/lib/simple_assertions/version.rb +1 -1
- data/simple_assertions.gemspec +0 -1
- data/{test/simple_assertions/assert_errors_on_test.rb → spec/simple_assertions/assert_errors_on_spec.rb} +33 -26
- data/{test/simple_assertions/assert_raises_test.rb → spec/simple_assertions/assert_raises_spec.rb} +10 -10
- data/spec/simple_assertions_spec.rb +12 -0
- data/{test/helper.rb → spec/spec_helper.rb} +0 -6
- metadata +7 -21
- data/test/simple_assertions_test.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89fe8e74e2562b356bd24226ddcc34b5c17983e3
|
4
|
+
data.tar.gz: fa16be366073492209a255d8376d834a09ed509a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0346b129908e86f709b38684a51a928e79504db90dbdbe16a4a5912a6e235b6c2806aa2551c205d56364addbb356ce8fe657cccfbcf6fed3375638e636d8696e
|
7
|
+
data.tar.gz: 54be640bcbe260811601c0f7a643c86e287671f6e0445f4cdb9111e5ec04c8739e47d0403fdb6b45d9b995afd2ca17cdcf96b8ad802f795737f86a625e16567f
|
data/.rubocop_todo.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
-
# on
|
2
|
+
# on 2017-01-09 15:27:00 +0100 using RuboCop version 0.29.1.
|
3
3
|
# The point is for the user to remove these configuration records
|
4
4
|
# one by one as the offenses are removed from the code base.
|
5
5
|
# Note that changes in the inspected code, or installation of new
|
@@ -7,18 +7,13 @@
|
|
7
7
|
|
8
8
|
# Offense count: 1
|
9
9
|
Metrics/AbcSize:
|
10
|
-
Max:
|
11
|
-
|
12
|
-
# Offense count: 1
|
13
|
-
# Configuration parameters: CountComments.
|
14
|
-
Metrics/ClassLength:
|
15
|
-
Max: 120
|
10
|
+
Max: 45
|
16
11
|
|
17
12
|
# Offense count: 1
|
18
13
|
Metrics/CyclomaticComplexity:
|
19
|
-
Max:
|
14
|
+
Max: 9
|
20
15
|
|
21
|
-
# Offense count:
|
16
|
+
# Offense count: 16
|
22
17
|
# Configuration parameters: AllowURI, URISchemes.
|
23
18
|
Metrics/LineLength:
|
24
19
|
Max: 126
|
data/Rakefile
CHANGED
@@ -4,11 +4,11 @@ require "bundler/gem_tasks"
|
|
4
4
|
# Test
|
5
5
|
require "rake/testtask"
|
6
6
|
desc "Default: run unit tests."
|
7
|
-
task default: :
|
7
|
+
task default: :spec
|
8
8
|
|
9
|
-
Rake::TestTask.new(:
|
10
|
-
test.test_files = FileList.new("
|
11
|
-
test.libs << "
|
9
|
+
Rake::TestTask.new(:spec) do |test|
|
10
|
+
test.test_files = FileList.new("spec/**/*_spec.rb")
|
11
|
+
test.libs << "spec"
|
12
12
|
test.verbose = true
|
13
13
|
test.warning = true
|
14
14
|
end
|
@@ -39,7 +39,7 @@ module SimpleAssertions
|
|
39
39
|
assert_equal pattern, errors.size,
|
40
40
|
"#{pattern} error(s) expected for #{object.class}.#{field} but got #{errors.inspect}."
|
41
41
|
when Regexp
|
42
|
-
assert errors.all? { |message| pattern.match(message) },
|
42
|
+
assert errors.any? && errors.all? { |message| pattern.match(message) },
|
43
43
|
"expected to match #{pattern} for #{object.class}.#{field} but got #{errors.inspect}."
|
44
44
|
when String
|
45
45
|
assert_equal [pattern], errors,
|
data/simple_assertions.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require "
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
require "active_model"
|
4
4
|
|
5
|
-
|
5
|
+
describe SimpleAssertions::AssertErrorsOn do
|
6
6
|
include SimpleAssertions::AssertRaises
|
7
7
|
include SimpleAssertions::AssertErrorsOn
|
8
8
|
|
@@ -19,21 +19,21 @@ class SimpleAssertionsAssertErrorsOnTest < Spec
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
describe "setup" do
|
23
|
+
it "factories" do
|
24
24
|
assert valid.valid?
|
25
25
|
refute empty.valid?
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
describe "basic" do
|
30
|
+
it "validate record" do
|
31
31
|
assert_assertion(/should be invalid/) do
|
32
32
|
assert_errors_on valid
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
it "yield block" do
|
37
37
|
assert_assertion "inside" do
|
38
38
|
assert_errors_on empty do
|
39
39
|
flunk "inside"
|
@@ -42,8 +42,8 @@ class SimpleAssertionsAssertErrorsOnTest < Spec
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
describe "error count with fixnum" do
|
46
|
+
it "correct" do
|
47
47
|
assert_errors_on empty, username: 1, email: 1
|
48
48
|
assert_errors_on empty, username: 1
|
49
49
|
assert_errors_on empty, [:username, :email] => 1
|
@@ -52,77 +52,84 @@ class SimpleAssertionsAssertErrorsOnTest < Spec
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
|
55
|
+
it "implicit count is 1" do
|
56
56
|
assert_errors_on empty, :username, :email
|
57
57
|
end
|
58
58
|
|
59
|
-
|
59
|
+
it "does not overwrite with implicit count" do
|
60
60
|
assert_errors_on empty, :fullname, fullname: 2
|
61
61
|
end
|
62
62
|
|
63
|
-
|
63
|
+
it "fail" do
|
64
64
|
assert_assertion(/2 error\(s\) expected for .*?\.username/) do
|
65
65
|
assert_errors_on empty, username: 2
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
|
71
|
-
|
70
|
+
describe "partial match with regexp" do
|
71
|
+
it "match" do
|
72
72
|
assert_errors_on empty, username: /blank/, email: /blank/
|
73
73
|
assert_errors_on person(username: nil, email: "invalid"), username: /blank/, email: /invalid/
|
74
74
|
assert_errors_on empty, username: /blank/
|
75
75
|
assert_errors_on empty, [:username, :email] => /blank/
|
76
76
|
end
|
77
77
|
|
78
|
-
|
78
|
+
it "mismatch" do
|
79
79
|
assert_assertion(/expected to match.*?invalid.*?\.username/) do
|
80
80
|
assert_errors_on empty, username: /invalid/
|
81
81
|
end
|
82
82
|
end
|
83
|
+
|
84
|
+
it "raises for valid attributes" do
|
85
|
+
person = person(username: nil, email: nil, fullname: "valid fullname")
|
86
|
+
assert_assertion(/expected to match.*?WHY.*?\.fullname/) do
|
87
|
+
assert_errors_on person, fullname: /WHY/
|
88
|
+
end
|
89
|
+
end
|
83
90
|
end
|
84
91
|
|
85
|
-
|
86
|
-
|
92
|
+
describe "exact single string match" do
|
93
|
+
it "match" do
|
87
94
|
assert_errors_on empty, username: "can't be blank", email: "can't be blank"
|
88
95
|
assert_errors_on person(username: nil, email: "invalid"), username: "can't be blank", email: "is invalid"
|
89
96
|
assert_errors_on empty, [:username, :email] => "can't be blank"
|
90
97
|
end
|
91
98
|
|
92
|
-
|
99
|
+
it "mismatch" do
|
93
100
|
assert_assertion(/"is invalid" expected for.*?\.username/) do
|
94
101
|
assert_errors_on empty, username: "is invalid"
|
95
102
|
end
|
96
103
|
end
|
97
104
|
end
|
98
105
|
|
99
|
-
|
100
|
-
|
106
|
+
describe "exact string match with array" do
|
107
|
+
it "match" do
|
101
108
|
assert_errors_on person(fullname: nil), fullname: ["can't be blank", "is invalid"]
|
102
109
|
assert_errors_on person(fullname: nil), fullname: ["is invalid", "can't be blank"]
|
103
110
|
end
|
104
111
|
|
105
|
-
|
112
|
+
it "mismatch" do
|
106
113
|
assert_assertion(/\["yay"\] expected for.*?\.fullname/) do
|
107
114
|
assert_errors_on person(fullname: nil), fullname: ["yay"]
|
108
115
|
end
|
109
116
|
end
|
110
117
|
end
|
111
118
|
|
112
|
-
|
113
|
-
|
119
|
+
describe "translation match with symbol" do
|
120
|
+
it "match" do
|
114
121
|
assert_errors_on empty, username: :"errors.messages.blank"
|
115
122
|
end
|
116
123
|
|
117
|
-
|
124
|
+
it "mismatch" do
|
118
125
|
assert_assertion(/:"errors\.messages\.invalid\"\(is invalid\) expected for.*?\.username/) do
|
119
126
|
assert_errors_on empty, username: :"errors.messages.invalid"
|
120
127
|
end
|
121
128
|
end
|
122
129
|
end
|
123
130
|
|
124
|
-
|
125
|
-
|
131
|
+
describe "unknown matcher type" do
|
132
|
+
it "fails" do
|
126
133
|
assert_assertion("unknown matcher type Float: 1.0") do
|
127
134
|
assert_errors_on empty, username: 1.0
|
128
135
|
end
|
data/{test/simple_assertions/assert_raises_test.rb → spec/simple_assertions/assert_raises_spec.rb}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
|
-
require "
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
|
3
|
+
describe SimpleAssertions::AssertRaises do
|
4
4
|
class MyError < StandardError
|
5
5
|
attr_reader :param
|
6
6
|
|
@@ -26,26 +26,26 @@ class SimpleAssertionsAssertRaisesTest < Spec
|
|
26
26
|
|
27
27
|
include SimpleAssertions::AssertRaises
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
describe :assert_raises do
|
30
|
+
it "match param exactly" do
|
31
31
|
assert_raises MyError, param: "string" do
|
32
32
|
my_error! "string"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
it "match param via regexp" do
|
37
37
|
assert_raises MyError, param: /string/i do
|
38
38
|
my_error! "my STRING rocks"
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
it "match param class" do
|
43
43
|
assert_raises MyError, param: MyError do
|
44
44
|
my_error! MyError
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
|
48
|
+
it "param does not match on === operator" do
|
49
49
|
assert_raises MiniTest::Assertion, message: /"foo" to match "bar"/ do
|
50
50
|
assert_raises MyError, param: "foo" do
|
51
51
|
my_error! "bar"
|
@@ -53,7 +53,7 @@ class SimpleAssertionsAssertRaisesTest < Spec
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
|
56
|
+
it "exception does not respond to invalid param" do
|
57
57
|
assert_raises MiniTest::Assertion, message: /to respond to #invalid/ do
|
58
58
|
assert_raises MyError, invalid: "foo" do
|
59
59
|
my_error!
|
@@ -61,7 +61,7 @@ class SimpleAssertionsAssertRaisesTest < Spec
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
|
64
|
+
it "access to private exception param" do
|
65
65
|
assert_raises MiniTest::Assertion, message: /to respond to #paula/ do
|
66
66
|
assert_raises MyError, paula: :sir do
|
67
67
|
my_error!
|
@@ -69,7 +69,7 @@ class SimpleAssertionsAssertRaisesTest < Spec
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
|
72
|
+
it "access to protected exception param" do
|
73
73
|
assert_raises MiniTest::Assertion, message: /to respond to #enemy/ do
|
74
74
|
assert_raises MyError, enemy: :war do
|
75
75
|
my_error!
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe SimpleAssertions do
|
4
|
+
describe ".all" do
|
5
|
+
let(:all) { SimpleAssertions.all }
|
6
|
+
|
7
|
+
it "returns all autoloaded modules except VERSION" do
|
8
|
+
refute all.empty?
|
9
|
+
refute_includes all, SimpleAssertions::VERSION
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,14 +1,8 @@
|
|
1
|
-
require "bundler/setup"
|
2
|
-
|
3
1
|
if ENV["CODECLIMATE_REPO_TOKEN"]
|
4
2
|
require "codeclimate-test-reporter"
|
5
3
|
CodeClimate::TestReporter.start
|
6
4
|
end
|
7
5
|
|
8
6
|
require "minitest/autorun"
|
9
|
-
require "testem"
|
10
7
|
|
11
8
|
require "simple_assertions"
|
12
|
-
|
13
|
-
class Spec < Testem
|
14
|
-
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_assertions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Suschlik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 5.5.1
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: testem
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: activemodel
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,10 +86,10 @@ files:
|
|
100
86
|
- lib/simple_assertions/version.rb
|
101
87
|
- rakelib/rubocop.rake
|
102
88
|
- simple_assertions.gemspec
|
103
|
-
-
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
89
|
+
- spec/simple_assertions/assert_errors_on_spec.rb
|
90
|
+
- spec/simple_assertions/assert_raises_spec.rb
|
91
|
+
- spec/simple_assertions_spec.rb
|
92
|
+
- spec/spec_helper.rb
|
107
93
|
homepage: https://github.com/neopoly/simple_assertions
|
108
94
|
licenses: []
|
109
95
|
metadata: {}
|
@@ -123,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
109
|
version: '0'
|
124
110
|
requirements: []
|
125
111
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.5.2
|
127
113
|
signing_key:
|
128
114
|
specification_version: 4
|
129
115
|
summary: A collection of useful assertions.
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
class SimpleAssertionsTest < Spec
|
4
|
-
context :all do
|
5
|
-
let(:all) { SimpleAssertions.all }
|
6
|
-
|
7
|
-
test "returns all autoloaded modules except VERSION" do
|
8
|
-
refute all.empty?
|
9
|
-
refute all.include?(SimpleAssertions::VERSION)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|