motion-spec 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWE4OTNmYWZiMmFiYzQ0YTM1NDZjMDM2NjhhNTU1YTIxN2QwODMwMQ==
4
+ N2I4ZTYyMjNhNTBmNDQ4NmVhNzlhYWZmMzZiYjZiMGI2ZWE0M2RhOQ==
5
5
  data.tar.gz: !binary |-
6
- MWY5MDA5NmE4Mzc0MzJjY2Y4ODVjOWU4NDM5N2ZjNmMwNTEzM2Y5Nw==
6
+ NGYwMjVhZmZiMjQyNjNiYzgwOGE4ZDczN2MyZGM3MTE5ZmZjYzBjNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MGMwNjMzZTcwYjZmZTI0MDdmZTQzZGYzMDVjZTJmZmJlOGVkYTg5YjIyNzBj
10
- MGVhMDMyZDkzNzczN2U4MzlmZDU3MzE0OTEwODE1MDE4NDI1NzU3YWZmOTM5
11
- YTA3OTQzNjA0ZDYxNGIzN2ZlNGJkNjBkNzQ4NGU0NWI2NzI3MmU=
9
+ Y2UyZjVlMjYwNjk5MzJiZTlmZGU2YTQ1NWZmNGZhYjM1NGNlYjA5NzEyZTY3
10
+ YzE4NDliZjI3Yzc5MmI1OTFkOGU3MGQ4YWE5ZTU4MDdmYTkyOGI3ZTdjMTIz
11
+ ZWM2OTQzNmRjOTY3OWQ2NGEzNWE3OGNlZTFhOTNmNmUyNzI5ZTA=
12
12
  data.tar.gz: !binary |-
13
- N2IwYTU5NTExYTAyMjZkMTZjYzM5NTA3MDBjYjQxZDE5OTg2OWU4YjUzNmM3
14
- NWY1OGEyZWNlZmQ0ZDhhYTQ5ODUxM2YyYzlmYzZiZDhlNzRhMDExODhhZjNj
15
- ZDM4OWQ5ZTVkMWQ1ZWQ1YmM4NmI3YmQ2ZDUxZTAzNmRiMGY5MTg=
13
+ NDlkZDk2OTI3MzYxNTVjNDE3NmUxYjNkMjdiNjM3NGQwZTI5NzU5NTkxZTg2
14
+ NmI4NWQ4Njg5NjM4OGFmNmJkNDhhODE5ODIyMjQyOTE3ZTkxNzkxNTNkZGRh
15
+ MzhhYWU4ZGE1ZjI1MjEzZDZjMjM0ZDYwNjZmY2I0ZmM0MzljM2M=
@@ -4,8 +4,6 @@ engines:
4
4
  enabled: true
5
5
  rubocop:
6
6
  enabled: true
7
- bundler-audit:
8
- enabled: true
9
7
  ratings:
10
8
  paths:
11
9
  - "**.rb"
@@ -2,6 +2,11 @@
2
2
  module MotionSpec
3
3
  module ContextHelper
4
4
  module Matchers
5
+ def be_a(test_class)
6
+ MotionSpec::Matcher::BeA.new(test_class)
7
+ end
8
+ alias_method :be_an, :be_a
9
+
5
10
  def be_nil
6
11
  MotionSpec::Matcher::BeNil.new
7
12
  end
@@ -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 = (error_class.is_a?(String) || error_class.is_a?(Regexp)) ? error_class : 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 = case @error_message
22
- when String
23
- exception.message.include?(@error_message)
24
- when Regexp
25
- @error_message.match(exception.message)
26
- else
27
- false
28
- end
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)
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module MotionSpec
4
- VERSION = '0.5.1'
4
+ VERSION = '0.6.0'
5
5
  end
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.5.1
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.6
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