/
mspec.diff
66 lines (64 loc) · 2.61 KB
/
mspec.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
diff --git a/mspec/lib/mspec/runner/mspec.rb b/mspec/lib/mspec/runner/mspec.rb
index f094da0..c48e568 100644
--- a/mspec/lib/mspec/runner/mspec.rb
+++ b/mspec/lib/mspec/runner/mspec.rb
@@ -293,7 +293,7 @@ module MSpec
# file if it is empty.
def self.delete_tag(tag)
deleted = false
- pattern = /#{tag.tag}.*#{Regexp.escape tag.description}/
+ pattern = /#{tag.tag}.*#{Regexp.escape(tag.escape(tag.description))}/
file = tags_file
if File.exist? file
lines = IO.readlines(file)
diff --git a/mspec/spec/runner/mspec_spec.rb b/mspec/spec/runner/mspec_spec.rb
index a7ff4fd..b562d75 100644
--- a/mspec/spec/runner/mspec_spec.rb
+++ b/mspec/spec/runner/mspec_spec.rb
@@ -415,6 +415,7 @@ describe MSpec, ".write_tags" do
IO.read(tmp("tags.txt")).should == %[fail(broken):Some#method? works
incomplete(20%):The#best method ever
benchmark(0.01825):The#fastest method today
+extended():\"Multi-line\\ntext\\ntag\"
]
MSpec.write_tags [@tag1, @tag2]
IO.read(tmp("tags.txt")).should == %[check(broken):Tag#rewrite works
@@ -461,6 +462,15 @@ describe MSpec, ".delete_tag" do
MSpec.delete_tag(@tag).should == true
IO.read(tmp("tags.txt")).should == %[incomplete(20%):The#best method ever
benchmark(0.01825):The#fastest method today
+extended():\"Multi-line\\ntext\\ntag\"
+]
+ end
+
+ it "deletes a tag with escaped newlines" do
+ MSpec.delete_tag(SpecTag.new('extended:"Multi-line\ntext\ntag"')).should == true
+ IO.read(tmp("tags.txt")).should == %[fail(broken):Some#method? works
+incomplete(20%):The#best method ever
+benchmark(0.01825):The#fastest method today
]
end
@@ -470,6 +480,7 @@ benchmark(0.01825):The#fastest method today
IO.read(tmp("tags.txt")).should == %[fail(broken):Some#method? works
incomplete(20%):The#best method ever
benchmark(0.01825):The#fastest method today
+extended():\"Multi-line\\ntext\\ntag\"
]
end
@@ -477,6 +488,7 @@ benchmark(0.01825):The#fastest method today
MSpec.delete_tag(@tag).should == true
MSpec.delete_tag(SpecTag.new("incomplete:The#best method ever")).should == true
MSpec.delete_tag(SpecTag.new("benchmark:The#fastest method today")).should == true
+ MSpec.delete_tag(SpecTag.new("extended:\"Multi-line\ntext\ntag\"")).should == true
File.exist?(tmp("tags.txt")).should == false
end
end
diff --git a/mspec/spec/runner/tags.txt b/mspec/spec/runner/tags.txt
index 5e39ee5..f4eb6ad 100644
--- a/mspec/spec/runner/tags.txt
+++ b/mspec/spec/runner/tags.txt
@@ -1,3 +1,4 @@
fail(broken):Some#method? works
incomplete(20%):The#best method ever
benchmark(0.01825):The#fastest method today
+extended():"Multi-line\ntext\ntag"