rspec-power_assert 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -0
- data/lib/rspec/power_assert/version.rb +1 -1
- data/lib/rspec/power_assert.rb +15 -3
- data/spec/rspec/power_assert_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ab9f427b3995cf84a3de0821222fd738c71a2e1
|
4
|
+
data.tar.gz: 8a24473cb5ae7f26de3f9760180845c919df7f19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64f426cc559260705a03894f2043d983d48a7e226a1906c6cda8f7832fab3886f987db60265c6fb8adb581499a8dbadbcf11510fb7e9ce4ecb32044ebffbd741
|
7
|
+
data.tar.gz: c4180fffcea435229705e6062700b2275863abe7703bf5759bd06ac1d21e6aa92bf3579b92a2d36e55cb6325ad7435b5e9151cadbf018ea24ee860b5017ae59f
|
data/README.md
CHANGED
@@ -53,6 +53,20 @@ If it set false, Successful Example reports without `power_assert` outputs.
|
|
53
53
|
|
54
54
|
Default is *true*.
|
55
55
|
|
56
|
+
### example_assertion_alias
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
# enable `assert` method in Example block
|
60
|
+
RSpec::PowerAssert.example_assertion_alias :assert
|
61
|
+
```
|
62
|
+
|
63
|
+
### example_group_assertion_alias
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
# enable `assert` method in ExampleGroup block
|
67
|
+
RSpec::PowerAssert.example_group_assertion_alias :assert
|
68
|
+
```
|
69
|
+
|
56
70
|
## Sample
|
57
71
|
### spec sample
|
58
72
|
```ruby
|
data/lib/rspec/power_assert.rb
CHANGED
@@ -33,12 +33,20 @@ module RSpec
|
|
33
33
|
@verbose_successful_report = verbose
|
34
34
|
end
|
35
35
|
|
36
|
+
def self.example_assertion_alias(name)
|
37
|
+
alias_method(name.to_sym, :is_asserted_by)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.example_group_assertion_alias(name)
|
41
|
+
PowerAssertExtensions.assertion_method_alias(name)
|
42
|
+
end
|
43
|
+
|
36
44
|
def is_asserted_by(&blk)
|
37
|
-
result, msg = ::PowerAssert.start(blk, assertion_method:
|
45
|
+
result, msg = ::PowerAssert.start(blk, assertion_method: __callee__) do |tp|
|
38
46
|
[tp.yield, tp.message_proc.call]
|
39
47
|
end
|
40
48
|
|
41
|
-
handle_result_and_message(result, msg,
|
49
|
+
handle_result_and_message(result, msg, __callee__)
|
42
50
|
end
|
43
51
|
|
44
52
|
private
|
@@ -122,10 +130,14 @@ module RSpec
|
|
122
130
|
end
|
123
131
|
|
124
132
|
module PowerAssertExtensions
|
133
|
+
def self.assertion_method_alias(name)
|
134
|
+
alias_method name.to_sym, :it_is_asserted_by
|
135
|
+
end
|
136
|
+
|
125
137
|
def it_is_asserted_by(description = nil, &blk)
|
126
138
|
file, lineno = blk.source_location
|
127
139
|
cmd = description ? "it(description)" : "specify"
|
128
|
-
eval %{#{cmd} do evaluate_example("#{
|
140
|
+
eval %{#{cmd} do evaluate_example("#{__callee__}", &blk) end}, binding, file, lineno
|
129
141
|
end
|
130
142
|
end
|
131
143
|
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
RSpec::PowerAssert.example_assertion_alias :assert
|
4
|
+
RSpec::PowerAssert.example_group_assertion_alias :assert
|
5
|
+
|
3
6
|
describe Rspec::PowerAssert do
|
4
7
|
describe Array do
|
5
8
|
describe "#map" do
|
@@ -14,6 +17,10 @@ describe Rspec::PowerAssert do
|
|
14
17
|
is_asserted_by { subject.map(&:upcase) == array }
|
15
18
|
end
|
16
19
|
|
20
|
+
it do
|
21
|
+
assert { subject.map(&:upcase) == array }
|
22
|
+
end
|
23
|
+
|
17
24
|
it do
|
18
25
|
is_asserted_by {
|
19
26
|
subject.map(&:upcase) == array
|
@@ -47,8 +54,12 @@ describe Rspec::PowerAssert do
|
|
47
54
|
|
48
55
|
it_is_asserted_by { subject.map(&:upcase) == %w(A B C) }
|
49
56
|
|
57
|
+
assert { subject.map(&:upcase) == %w(A B C) }
|
58
|
+
|
50
59
|
it_is_asserted_by { subject.map(&:upcase) == %w(A B) }
|
51
60
|
|
61
|
+
assert { subject.map(&:upcase) == %w(A B) }
|
62
|
+
|
52
63
|
it_is_asserted_by do
|
53
64
|
subject.map(&:upcase) == %w(A B C)
|
54
65
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-power_assert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- joker1007
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: power_assert
|