motion-spec 0.3.0 → 0.4.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/.rubocop.yml +12 -0
- data/Gemfile.lock +1 -1
- data/lib/motion-spec/context.rb +28 -9
- data/lib/motion-spec/context_helper/memoized_helpers.rb +51 -0
- 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
|
+
ZGVhMjk5MWRlZGU0NTEwMDNkMmQ1YTQxYzA3NGU0NGI5MjMwMjk5Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTNiZTMwZTMyMDFjY2ZlNDcyYjNhOTJlZDM4OGI1NTdiNTgzOTYxZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODdiODllYjUyODFkNzhkODM2MTY1MjQ1MDA4NmZlZWExZTA4YjU3MmYxZWRh
|
10
|
+
ZDJjMWQyOGYyYjNkNzk1NTNlMTJkYTY4YTY2YWExYzY0YjQwZDFiZGNiYjM1
|
11
|
+
YjE2OTE2ZjU3OTk2NmU5MzJhMmEzYjJkN2Y5MmFmMjdkMGIxNDQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MWIzZDdjNjI5ODhlOWIwMmNlNzQyZTg3YWQ5MzNjYTM0MjEzNzMxNDhlY2Qy
|
14
|
+
YjQ3MjMyMjQ1NTg3OGM2YmFiOWNhZDdjMzdiOTY0MGJkYzNiMjZkZDIxZWRh
|
15
|
+
ODg0MmFhNzQ1ODU2M2YxYjE2ZjE3NmU3YTQ1OWNkNjMwMDdiYjQ=
|
data/.rubocop.yml
CHANGED
@@ -46,6 +46,12 @@ Metrics/ParameterLists:
|
|
46
46
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params'
|
47
47
|
Enabled: false
|
48
48
|
|
49
|
+
Style/DotPosition:
|
50
|
+
EnforcedStyle: leading
|
51
|
+
SupportedStyles:
|
52
|
+
- leading
|
53
|
+
- trailing
|
54
|
+
|
49
55
|
Style/EmptyLineBetweenDefs:
|
50
56
|
AllowAdjacentOneLineDefs: true
|
51
57
|
|
@@ -57,6 +63,12 @@ Style/IndentationWidth:
|
|
57
63
|
Style/MethodName:
|
58
64
|
Enabled: false
|
59
65
|
|
66
|
+
Style/MultilineOperationIndentation:
|
67
|
+
EnforcedStyle: indented
|
68
|
+
SupportedStyles:
|
69
|
+
- aligned
|
70
|
+
- indented
|
71
|
+
|
60
72
|
Style/StringLiterals:
|
61
73
|
Description: Checks if uses of quotes match the configured preference.
|
62
74
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
|
data/Gemfile.lock
CHANGED
data/lib/motion-spec/context.rb
CHANGED
@@ -4,6 +4,7 @@ module MotionSpec
|
|
4
4
|
include ContextHelper::Matchers
|
5
5
|
include ContextHelper::Should
|
6
6
|
include ContextHelper::Expectation
|
7
|
+
include ContextHelper::MemoizedHelpers
|
7
8
|
|
8
9
|
attr_reader :name, :block
|
9
10
|
|
@@ -21,8 +22,7 @@ module MotionSpec
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def run
|
24
|
-
# TODO
|
25
|
-
# return unless name =~ RestrictContext
|
25
|
+
# TODO: return unless name =~ RestrictContext
|
26
26
|
|
27
27
|
if Platform.android?
|
28
28
|
@specifications.each(&:run)
|
@@ -69,11 +69,16 @@ module MotionSpec
|
|
69
69
|
instance_eval(&Shared[name])
|
70
70
|
end
|
71
71
|
|
72
|
-
def it(description, &block)
|
72
|
+
def it(description = nil, &block)
|
73
73
|
return unless description =~ RestrictName
|
74
|
+
|
74
75
|
block ||= proc { should.flunk 'not implemented' }
|
76
|
+
|
75
77
|
Counter[:specifications] += 1
|
76
|
-
|
78
|
+
|
79
|
+
@specifications << Specification.new(
|
80
|
+
self, description, block, @before, @after
|
81
|
+
)
|
77
82
|
end
|
78
83
|
|
79
84
|
def should(*args, &block)
|
@@ -135,11 +140,25 @@ module MotionSpec
|
|
135
140
|
private
|
136
141
|
|
137
142
|
def build_ios_parent_context(context)
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
+
parent_context = self
|
144
|
+
|
145
|
+
# object.methods(false) returns duplicate method names where one ends in
|
146
|
+
# a ':' (e.g. ['foo:', 'foo']). This was causing a low-level Ruby error:
|
147
|
+
# Assertion failed: (b != NULL), function rb_vm_block_method_imp, file vm.cpp, line 3386.
|
148
|
+
# To fix the issue we removed the 'foo:' version of the method names.
|
149
|
+
methods = parent_context
|
150
|
+
.methods(false)
|
151
|
+
.map { |name| name.to_s.chomp(':') }
|
152
|
+
.uniq
|
153
|
+
|
154
|
+
context_eigenclass = (class << context; self; end)
|
155
|
+
context_eigenclass.send(:define_method, :parent_context) { parent_context }
|
156
|
+
|
157
|
+
methods.each do |method_name|
|
158
|
+
next if context.respond_to?(method_name)
|
159
|
+
|
160
|
+
context_eigenclass.send(:define_method, method_name) do |*args|
|
161
|
+
parent_context.send(method_name, *args)
|
143
162
|
end
|
144
163
|
end
|
145
164
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module MotionSpec
|
3
|
+
module ContextHelper
|
4
|
+
module MemoizedHelpers
|
5
|
+
attr_accessor :__memoized
|
6
|
+
|
7
|
+
def let(name, &block)
|
8
|
+
raise '#let or #subject called without a block' unless block_given?
|
9
|
+
|
10
|
+
(class << self; self; end).class_eval do
|
11
|
+
define_method(name) do
|
12
|
+
self.__memoized ||= {}
|
13
|
+
__memoized.fetch(name) { __memoized[name] = block.call }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# The way that nested contexts are implemented requires us to manually
|
18
|
+
# reset any memoized values after each spec via an 'after'.
|
19
|
+
after { reset_memoized }
|
20
|
+
end
|
21
|
+
|
22
|
+
def let!(name, &block)
|
23
|
+
let(name, &block)
|
24
|
+
before { __send__(name) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def subject(name = nil, &block)
|
28
|
+
if name
|
29
|
+
let(name, &block)
|
30
|
+
alias_method :subject, name
|
31
|
+
else
|
32
|
+
let(:subject, &block)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def subject!(name = nil, &block)
|
37
|
+
subject(name, &block)
|
38
|
+
before { subject }
|
39
|
+
end
|
40
|
+
|
41
|
+
def is_expected # rubocop:disable Style/PredicateName
|
42
|
+
expect(subject)
|
43
|
+
end
|
44
|
+
|
45
|
+
def reset_memoized
|
46
|
+
@__memoized = nil
|
47
|
+
parent_context.reset_memoized if respond_to?(:parent_context)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/motion-spec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Bender
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: motion-require
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/motion-spec/context.rb
|
61
61
|
- lib/motion-spec/context_helper/expectation.rb
|
62
62
|
- lib/motion-spec/context_helper/matchers.rb
|
63
|
+
- lib/motion-spec/context_helper/memoized_helpers.rb
|
63
64
|
- lib/motion-spec/context_helper/should.rb
|
64
65
|
- lib/motion-spec/core.rb
|
65
66
|
- lib/motion-spec/error.rb
|