mountain_berry_fields-magic_comments 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b16321bfcfcd96db10a6eba98e3b434c17af542c
|
4
|
+
data.tar.gz: f687ea2fc43944cf51f8043b6cea5e859b946567
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6d0bede3368a828927b6da04934e2334b391dcd964c31c7c798b0a62991094bde979590d517978b095ad8f93c5728735462b9742b5e9b6764859dfe2d0fdac87
|
7
|
+
data.tar.gz: 00120ec2785183453250048ee49b75b35a1113a75b603bc24194b94da15174b22cafdba50907caf40c23370969f917dd5f85fb490fc99ced8372826ce0a2a648
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source '
|
1
|
+
source 'http://rubygems.org'
|
2
2
|
gemspec
|
@@ -18,6 +18,11 @@ Then /^it exits with a status of (\d+), and a stderr of:$/ do |status, stderr|
|
|
18
18
|
last_cmdline.stderr.chomp.should == interpret_curlies(stderr).chomp
|
19
19
|
end
|
20
20
|
|
21
|
+
Then /^it exits with a status of (\d+), and a stderr including:$/ do |status, stderr|
|
22
|
+
last_cmdline.exitstatus.should == status.to_i
|
23
|
+
last_cmdline.stderr.chomp.should include interpret_curlies(stderr).chomp
|
24
|
+
end
|
25
|
+
|
21
26
|
Then /^it prints nothing to (stdout|stderr)$/ do |descriptor|
|
22
27
|
last_cmdline.send(descriptor).should == ''
|
23
28
|
end
|
@@ -22,6 +22,51 @@ Feature: Testing with :magic_comments
|
|
22
22
|
More shit here
|
23
23
|
"""
|
24
24
|
|
25
|
+
Scenario: Passing magic comments, abbreviated
|
26
|
+
Given the file "Readme.mountain_berry_fields.md":
|
27
|
+
"""
|
28
|
+
# Whatever
|
29
|
+
|
30
|
+
<% test 'lame Fibonacci', with: :magic_comments do %>
|
31
|
+
def fib(n)
|
32
|
+
if n <= 2
|
33
|
+
[1, 1]
|
34
|
+
else
|
35
|
+
series = fib(n-1)
|
36
|
+
series << series[-2] + series[-1]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
fib(2) # => [1, 1]
|
41
|
+
fib(4) # => [1, 1, 2, 3]
|
42
|
+
fib(44) # => [1, 1, 2, 3, 5, 8, 13, ..., 433494437, 701408733]
|
43
|
+
fib(45) # => [1, 1, 2, 3, 5, 8, 13, ......
|
44
|
+
<% end %>
|
45
|
+
|
46
|
+
More shit here
|
47
|
+
"""
|
48
|
+
When I run "mountain_berry_fields Readme.mountain_berry_fields.md"
|
49
|
+
Then it exits with a status of 0
|
50
|
+
And I see the file "Readme.md":
|
51
|
+
"""
|
52
|
+
# Whatever
|
53
|
+
|
54
|
+
def fib(n)
|
55
|
+
if n <= 2
|
56
|
+
[1, 1]
|
57
|
+
else
|
58
|
+
series = fib(n-1)
|
59
|
+
series << series[-2] + series[-1]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
fib(2) # => [1, 1]
|
64
|
+
fib(4) # => [1, 1, 2, 3]
|
65
|
+
fib(44) # => [1, 1, 2, 3, 5, 8, 13, ..., 433494437, 701408733]
|
66
|
+
fib(45) # => [1, 1, 2, 3, 5, 8, 13, ......
|
67
|
+
|
68
|
+
More shit here
|
69
|
+
"""
|
25
70
|
|
26
71
|
Scenario: Failing magic comments
|
27
72
|
Given the file "Readme.mountain_berry_fields.md":
|
@@ -56,14 +101,9 @@ Feature: Testing with :magic_comments
|
|
56
101
|
More shit here
|
57
102
|
"""
|
58
103
|
When I run "mountain_berry_fields Readme.mountain_berry_fields.md"
|
59
|
-
Then it exits with a status of 1, and a stderr
|
104
|
+
Then it exits with a status of 1, and a stderr including:
|
60
105
|
"""
|
61
106
|
FAILURE: basic addition
|
62
|
-
-:1: syntax error
|
63
|
-
} + { # => 12
|
64
|
-
^
|
65
|
-
|
66
|
-
original file:
|
67
|
-
} + { # => 12
|
107
|
+
-:1: syntax error
|
68
108
|
"""
|
69
109
|
And I do not see the file "Readme.md"
|
@@ -10,6 +10,7 @@ class MountainBerryFields
|
|
10
10
|
#
|
11
11
|
# Like that, but if the output isn't 3, then this will fail your test
|
12
12
|
class MagicComments
|
13
|
+
ELLIPSIS_REGEX = /\s+\.{3,}\s*/
|
13
14
|
|
14
15
|
Strategy.register :magic_comments, self
|
15
16
|
include Strategy
|
@@ -52,7 +53,7 @@ class MountainBerryFields
|
|
52
53
|
|
53
54
|
def pass?
|
54
55
|
each_line_pair do |expected_line, actual_line|
|
55
|
-
return false unless
|
56
|
+
return false unless lines_match?(expected_line, actual_line)
|
56
57
|
end
|
57
58
|
true
|
58
59
|
end
|
@@ -67,8 +68,26 @@ class MountainBerryFields
|
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
70
|
-
def lines_match?(
|
71
|
-
|
71
|
+
def lines_match?(expected, actual)
|
72
|
+
if ELLIPSIS_REGEX.match(expected)
|
73
|
+
expected_regex = ellipses_to_wildcards_regex(normalize(expected))
|
74
|
+
expected_regex.match(actual)
|
75
|
+
else
|
76
|
+
normalize(expected) == normalize(actual)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# magic for " ..." in magic comments
|
81
|
+
#
|
82
|
+
# This translates a string with groups of three or more dots into a
|
83
|
+
# regular expression with the dot groups replaced by wildcards.
|
84
|
+
# For example, "Blah, blah, blah, ... and so on" is translated into
|
85
|
+
# /\ABlah\,\ blah\,\ blah,\.*and so on\z/.
|
86
|
+
|
87
|
+
def ellipses_to_wildcards_regex(line)
|
88
|
+
content_pieces = line.split(ELLIPSIS_REGEX, -1)
|
89
|
+
.map(&Regexp.method(:escape))
|
90
|
+
/\A#{content_pieces.join('.*?')}\Z/
|
72
91
|
end
|
73
92
|
|
74
93
|
def normalize(line)
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
13
|
gem.name = "mountain_berry_fields-magic_comments"
|
14
14
|
gem.require_paths = ["lib"]
|
15
|
-
gem.version = '1.0.
|
15
|
+
gem.version = '1.0.2'
|
16
16
|
|
17
17
|
gem.add_runtime_dependency 'rcodetools', '~> 0.8.5.0'
|
18
18
|
gem.add_runtime_dependency 'deject', '~> 0.2.2'
|
metadata
CHANGED
@@ -1,93 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mountain_berry_fields-magic_comments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Josh Cheek
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-09-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rcodetools
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 0.8.5.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.5.0
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: deject
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - ~>
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: 0.2.2
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.2.2
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: mountain_berry_fields
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
45
|
- - ~>
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: 1.0.2
|
44
48
|
type: :runtime
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.2
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: surrogate
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
59
|
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: 0.5.1
|
55
62
|
type: :development
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.5.1
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: rspec
|
60
|
-
requirement:
|
61
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
62
72
|
requirements:
|
63
73
|
- - ~>
|
64
74
|
- !ruby/object:Gem::Version
|
65
75
|
version: 2.10.0
|
66
76
|
type: :development
|
67
77
|
prerelease: false
|
68
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.10.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: cucumber
|
71
|
-
requirement:
|
72
|
-
none: false
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
73
86
|
requirements:
|
74
87
|
- - ~>
|
75
88
|
- !ruby/object:Gem::Version
|
76
89
|
version: 1.2.0
|
77
90
|
type: :development
|
78
91
|
prerelease: false
|
79
|
-
version_requirements:
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.2.0
|
80
97
|
- !ruby/object:Gem::Dependency
|
81
98
|
name: rake
|
82
|
-
requirement:
|
83
|
-
none: false
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
84
100
|
requirements:
|
85
|
-
- -
|
101
|
+
- - '>='
|
86
102
|
- !ruby/object:Gem::Version
|
87
103
|
version: '0'
|
88
104
|
type: :development
|
89
105
|
prerelease: false
|
90
|
-
version_requirements:
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
91
111
|
description: Test code samples embedded in files like readmes
|
92
112
|
email:
|
93
113
|
- josh.cheek@gmail.com
|
@@ -111,27 +131,26 @@ files:
|
|
111
131
|
- spec/test/magic_comments_spec.rb
|
112
132
|
homepage: https://github.com/JoshCheek/mountain_berry_fields-magic_comments
|
113
133
|
licenses: []
|
134
|
+
metadata: {}
|
114
135
|
post_install_message:
|
115
136
|
rdoc_options: []
|
116
137
|
require_paths:
|
117
138
|
- lib
|
118
139
|
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
-
none: false
|
120
140
|
requirements:
|
121
|
-
- -
|
141
|
+
- - '>='
|
122
142
|
- !ruby/object:Gem::Version
|
123
143
|
version: '0'
|
124
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
-
none: false
|
126
145
|
requirements:
|
127
|
-
- -
|
146
|
+
- - '>='
|
128
147
|
- !ruby/object:Gem::Version
|
129
148
|
version: '0'
|
130
149
|
requirements: []
|
131
150
|
rubyforge_project:
|
132
|
-
rubygems_version:
|
151
|
+
rubygems_version: 2.0.3
|
133
152
|
signing_key:
|
134
|
-
specification_version:
|
153
|
+
specification_version: 4
|
135
154
|
summary: Test code samples embedded in files like readmes
|
136
155
|
test_files:
|
137
156
|
- features/step_definitions/steps.rb
|