This repository was archived by the owner on Aug 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathquotes_spec.rb
More file actions
107 lines (88 loc) · 3.47 KB
/
Copy pathquotes_spec.rb
File metadata and controls
107 lines (88 loc) · 3.47 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
require_relative '../spec_helper'
require 'tailor/critic'
require 'tailor/configuration/style'
describe "Consistent usage of quotes" do
before do
Tailor::Logger.stub(:log)
FakeFS.activate!
File.open(file_name.to_s, 'w') { |f| f.write contents }
critic.check_file(file_name.to_s, style.to_hash)
end
let(:critic) do
Tailor::Critic.new
end
let(:contents) {
{
:single_quotes => %Q{a = 'test'},
:double_quotes => %Q{a = "test"},
:mixed_quotes => %Q{a = 'test'; b = "test"},
:special_quotes => %Q{a = %q(test); b = %Q(test)}
}[file_name]
}
describe "single quotes" do
let(:style) do
style = Tailor::Configuration::Style.new
style.trailing_newlines 0, level: :off
style.allow_invalid_ruby true, level: :off
style.quotes "single", level: :error
style
end
context "ok" do
let(:file_name) { :single_quotes }
specify { critic.problems[file_name.to_s].size.should == 0 }
end
context "double quotes" do
let(:file_name) { :double_quotes }
specify { critic.problems[file_name.to_s].size.should == 1 }
specify { critic.problems[file_name.to_s].first[:type].should == "quotes" }
specify { critic.problems[file_name.to_s].first[:line].should be 1 }
specify { critic.problems[file_name.to_s].first[:column].should be 4 }
specify { critic.problems[file_name.to_s].first[:level].should be :error }
end
context "mixed quotes" do
let(:file_name) { :mixed_quotes }
specify { critic.problems[file_name.to_s].size.should == 1 }
specify { critic.problems[file_name.to_s].first[:type].should == "quotes" }
specify { critic.problems[file_name.to_s].first[:line].should be 1 }
specify { critic.problems[file_name.to_s].first[:column].should be 16 }
specify { critic.problems[file_name.to_s].first[:level].should be :error }
end
context "special quotes" do
let(:file_name) { :special_quotes }
specify { critic.problems[file_name.to_s].size.should == 0 }
end
end
describe "double quotes" do
let(:style) do
style = Tailor::Configuration::Style.new
style.trailing_newlines 0, level: :off
style.allow_invalid_ruby true, level: :off
style.quotes "double", level: :error
style
end
context "ok" do
let(:file_name) { :double_quotes }
specify { critic.problems[file_name.to_s].size.should == 0 }
end
context "single quotes" do
let(:file_name) { :single_quotes }
specify { critic.problems[file_name.to_s].size.should == 1 }
specify { critic.problems[file_name.to_s].first[:type].should == "quotes" }
specify { critic.problems[file_name.to_s].first[:line].should be 1 }
specify { critic.problems[file_name.to_s].first[:column].should be 4 }
specify { critic.problems[file_name.to_s].first[:level].should be :error }
end
context "mixed quotes" do
let(:file_name) { :mixed_quotes }
specify { critic.problems[file_name.to_s].size.should == 1 }
specify { critic.problems[file_name.to_s].first[:type].should == "quotes" }
specify { critic.problems[file_name.to_s].first[:line].should be 1 }
specify { critic.problems[file_name.to_s].first[:column].should be 4 }
specify { critic.problems[file_name.to_s].first[:level].should be :error }
end
context "special quotes" do
let(:file_name) { :special_quotes }
specify { critic.problems[file_name.to_s].size.should == 0 }
end
end
end