motion-spec 0.5.1 → 0.6.0
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 +8 -8
- data/.codeclimate.yml +0 -2
- data/lib/motion-spec/context_helper/matchers.rb +5 -0
- data/lib/motion-spec/fail_message_renderer.rb +4 -0
- data/lib/motion-spec/matcher/be_a.rb +21 -0
- data/lib/motion-spec/matcher/raise_error.rb +15 -12
- data/lib/motion-spec/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2I4ZTYyMjNhNTBmNDQ4NmVhNzlhYWZmMzZiYjZiMGI2ZWE0M2RhOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGYwMjVhZmZiMjQyNjNiYzgwOGE4ZDczN2MyZGM3MTE5ZmZjYzBjNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2UyZjVlMjYwNjk5MzJiZTlmZGU2YTQ1NWZmNGZhYjM1NGNlYjA5NzEyZTY3
|
10
|
+
YzE4NDliZjI3Yzc5MmI1OTFkOGU3MGQ4YWE5ZTU4MDdmYTkyOGI3ZTdjMTIz
|
11
|
+
ZWM2OTQzNmRjOTY3OWQ2NGEzNWE3OGNlZTFhOTNmNmUyNzI5ZTA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDlkZDk2OTI3MzYxNTVjNDE3NmUxYjNkMjdiNjM3NGQwZTI5NzU5NTkxZTg2
|
14
|
+
NmI4NWQ4Njg5NjM4OGFmNmJkNDhhODE5ODIyMjQyOTE3ZTkxNzkxNTNkZGRh
|
15
|
+
MzhhYWU4ZGE1ZjI1MjEzZDZjMjM0ZDYwNjZmY2I0ZmM0MzljM2M=
|
data/.codeclimate.yml
CHANGED
@@ -5,6 +5,10 @@ module MotionSpec
|
|
5
5
|
"#{negated ? ' not' : ''} expected"
|
6
6
|
end
|
7
7
|
|
8
|
+
def self.message_for_be_a(negated, subject, test_class)
|
9
|
+
"#{subject.inspect}#{expectation(negated)} to be a kind of #{test_class}"
|
10
|
+
end
|
11
|
+
|
8
12
|
def self.message_for_be_false(negated, subject)
|
9
13
|
"#{subject.inspect}#{expectation(negated)} to be false"
|
10
14
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module MotionSpec
|
3
|
+
module Matcher
|
4
|
+
class BeA
|
5
|
+
def initialize(test_class)
|
6
|
+
@test_class = test_class
|
7
|
+
end
|
8
|
+
|
9
|
+
def matches?(subject)
|
10
|
+
comparison_object = subject.is_a?(Class) ? subject : subject.class
|
11
|
+
|
12
|
+
comparison_object.ancestors.include? @test_class
|
13
|
+
end
|
14
|
+
|
15
|
+
def fail!(subject, negated)
|
16
|
+
message = FailMessageRenderer.message_for_be_a(negated, subject, @test_class)
|
17
|
+
fail FailedExpectation.new(message)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -4,7 +4,7 @@ module MotionSpec
|
|
4
4
|
class RaiseError
|
5
5
|
def initialize(error_class = Exception, message = '')
|
6
6
|
@error_class = error_class.is_a?(Class) ? error_class : Exception
|
7
|
-
@error_message =
|
7
|
+
@error_message = exception_matcher?(error_class) ? error_class : message
|
8
8
|
end
|
9
9
|
|
10
10
|
def matches?(_value, &block)
|
@@ -15,21 +15,24 @@ module MotionSpec
|
|
15
15
|
exception_matches(e)
|
16
16
|
end
|
17
17
|
|
18
|
+
def exception_matcher?(error_class)
|
19
|
+
error_class.is_a?(String) || error_class.is_a?(Regexp)
|
20
|
+
end
|
21
|
+
|
18
22
|
def exception_matches(exception)
|
19
23
|
return false unless exception.is_a?(@error_class)
|
20
24
|
|
21
|
-
is_match =
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
return false unless is_match
|
25
|
+
is_match =
|
26
|
+
case @error_message
|
27
|
+
when String
|
28
|
+
exception.message.include?(@error_message)
|
29
|
+
when Regexp
|
30
|
+
@error_message.match(exception.message)
|
31
|
+
else
|
32
|
+
false
|
33
|
+
end
|
31
34
|
|
32
|
-
true
|
35
|
+
is_match ? true : false
|
33
36
|
end
|
34
37
|
|
35
38
|
def fail!(_subject, negated)
|
data/lib/motion-spec/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Bender
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/motion-spec/extensions/proc.rb
|
74
74
|
- lib/motion-spec/fail_message_renderer.rb
|
75
75
|
- lib/motion-spec/matcher/be.rb
|
76
|
+
- lib/motion-spec/matcher/be_a.rb
|
76
77
|
- lib/motion-spec/matcher/be_false.rb
|
77
78
|
- lib/motion-spec/matcher/be_generic.rb
|
78
79
|
- lib/motion-spec/matcher/be_nil.rb
|
@@ -130,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
131
|
version: '0'
|
131
132
|
requirements: []
|
132
133
|
rubyforge_project:
|
133
|
-
rubygems_version: 2.4.
|
134
|
+
rubygems_version: 2.4.8
|
134
135
|
signing_key:
|
135
136
|
specification_version: 4
|
136
137
|
summary: RubyMotion derivative of Bacon, which is a derivative of RSpec
|