simple_assertions 0.6.0 → 0.6.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab353a3f99dec499be827540ec3214f657402b4f
4
- data.tar.gz: f75755baa2a76e2d3a81fc726a0b6d3640fafe8a
3
+ metadata.gz: 89fe8e74e2562b356bd24226ddcc34b5c17983e3
4
+ data.tar.gz: fa16be366073492209a255d8376d834a09ed509a
5
5
  SHA512:
6
- metadata.gz: aeffe28c5440cb24cb803bad688685678f3878defd60f9db0e9f75c0acfdcbbe9e976f54d62d59ab07abac2f8f6c368a3ce7efde0341db1a5974ec54c2e2f113
7
- data.tar.gz: ef4b1baa4fb63e0ef739253faa72b8cd9995bc19410268e35f344d91f3005e6b9675af179b48b858634794dc7eee223e7275c49eda2cf21e11e3d87a7a48c1d5
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 2015-03-19 16:23:55 +0100 using RuboCop version 0.29.1.
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: 44
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: 8
14
+ Max: 9
20
15
 
21
- # Offense count: 15
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: :test
7
+ task default: :spec
8
8
 
9
- Rake::TestTask.new(:test) do |test|
10
- test.test_files = FileList.new("test/**/*_test.rb")
11
- test.libs << "test"
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,
@@ -1,3 +1,3 @@
1
1
  module SimpleAssertions
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
@@ -22,6 +22,5 @@ Gem::Specification.new do |s|
22
22
  s.add_runtime_dependency "rdoc"
23
23
 
24
24
  s.add_development_dependency "minitest", "~> 5.5.1"
25
- s.add_development_dependency "testem"
26
25
  s.add_development_dependency "activemodel"
27
26
  end
@@ -1,8 +1,8 @@
1
- require "helper"
1
+ require "spec_helper"
2
2
 
3
3
  require "active_model"
4
4
 
5
- class SimpleAssertionsAssertErrorsOnTest < Spec
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
- context "setup" do
23
- test "factories" do
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
- context "basic" do
30
- test "validate record" do
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
- test "yield block" do
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
- context "error count with fixnum" do
46
- test "correct" do
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
- test "implicit count is 1" do
55
+ it "implicit count is 1" do
56
56
  assert_errors_on empty, :username, :email
57
57
  end
58
58
 
59
- test "does not overwrite with implicit count" do
59
+ it "does not overwrite with implicit count" do
60
60
  assert_errors_on empty, :fullname, fullname: 2
61
61
  end
62
62
 
63
- test "fail" do
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
- context "partial match with regexp" do
71
- test "match" do
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
- test "mismatch" do
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
- context "exact single string match" do
86
- test "match" do
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
- test "mismatch" do
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
- context "exact string match with array" do
100
- test "match" do
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
- test "mismatch" do
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
- context "translation match with symbol" do
113
- test "match" do
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
- test "mismatch" do
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
- context "unknown matcher type" do
125
- test "fails" do
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
@@ -1,6 +1,6 @@
1
- require "helper"
1
+ require "spec_helper"
2
2
 
3
- class SimpleAssertionsAssertRaisesTest < Spec
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
- context :assert_raises do
30
- test "match param exactly" do
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
- test "match param via regexp" do
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
- test "match param class" do
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
- test "param does not match on === operator" do
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
- test "exception does not respond to invalid param" do
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
- test "access to private exception param" do
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
- test "access to protected exception param" do
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.0
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: 2015-03-19 00:00:00.000000000 Z
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
- - test/helper.rb
104
- - test/simple_assertions/assert_errors_on_test.rb
105
- - test/simple_assertions/assert_raises_test.rb
106
- - test/simple_assertions_test.rb
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.2.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