transpec 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +4 -0
- data/lib/transpec/version.rb +1 -1
- data/transpec.gemspec +4 -3
- metadata +3 -97
- data/spec/.rubocop.yml +0 -23
- data/spec/integration/configuration_modification_spec.rb +0 -186
- data/spec/integration/conversion_spec.rb +0 -145
- data/spec/spec_helper.rb +0 -52
- data/spec/support/cache_helper.rb +0 -62
- data/spec/support/file_helper.rb +0 -25
- data/spec/support/shared_context.rb +0 -84
- data/spec/transpec/cli_spec.rb +0 -341
- data/spec/transpec/commit_message_spec.rb +0 -81
- data/spec/transpec/config_spec.rb +0 -99
- data/spec/transpec/converter_spec.rb +0 -1374
- data/spec/transpec/directory_cloner_spec.rb +0 -74
- data/spec/transpec/dynamic_analyzer/rewriter_spec.rb +0 -143
- data/spec/transpec/dynamic_analyzer_spec.rb +0 -329
- data/spec/transpec/git_spec.rb +0 -151
- data/spec/transpec/option_parser_spec.rb +0 -275
- data/spec/transpec/processed_source_spec.rb +0 -93
- data/spec/transpec/project_spec.rb +0 -194
- data/spec/transpec/record_spec.rb +0 -128
- data/spec/transpec/report_spec.rb +0 -126
- data/spec/transpec/rspec_version_spec.rb +0 -129
- data/spec/transpec/spec_file_finder_spec.rb +0 -118
- data/spec/transpec/spec_suite_spec.rb +0 -108
- data/spec/transpec/static_context_inspector_spec.rb +0 -713
- data/spec/transpec/syntax/allow_spec.rb +0 -122
- data/spec/transpec/syntax/be_boolean_spec.rb +0 -176
- data/spec/transpec/syntax/be_close_spec.rb +0 -51
- data/spec/transpec/syntax/current_example_spec.rb +0 -319
- data/spec/transpec/syntax/double_spec.rb +0 -175
- data/spec/transpec/syntax/example_group_spec.rb +0 -716
- data/spec/transpec/syntax/example_spec.rb +0 -301
- data/spec/transpec/syntax/expect_spec.rb +0 -313
- data/spec/transpec/syntax/have_spec.rb +0 -1276
- data/spec/transpec/syntax/hook_spec.rb +0 -215
- data/spec/transpec/syntax/its_spec.rb +0 -448
- data/spec/transpec/syntax/matcher_definition_spec.rb +0 -59
- data/spec/transpec/syntax/method_stub_spec.rb +0 -1301
- data/spec/transpec/syntax/oneliner_should_spec.rb +0 -628
- data/spec/transpec/syntax/operator_spec.rb +0 -871
- data/spec/transpec/syntax/pending_spec.rb +0 -415
- data/spec/transpec/syntax/raise_error_spec.rb +0 -354
- data/spec/transpec/syntax/receive_spec.rb +0 -499
- data/spec/transpec/syntax/rspec_configure_spec.rb +0 -870
- data/spec/transpec/syntax/should_receive_spec.rb +0 -1108
- data/spec/transpec/syntax/should_spec.rb +0 -497
- data/spec/transpec/util_spec.rb +0 -115
- data/spec/transpec_spec.rb +0 -22
@@ -1,194 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'transpec/project'
|
5
|
-
require 'active_support/core_ext/string/strip.rb'
|
6
|
-
|
7
|
-
module Transpec
|
8
|
-
describe Project do
|
9
|
-
include FileHelper
|
10
|
-
include CacheHelper
|
11
|
-
|
12
|
-
subject(:project) { Project.new }
|
13
|
-
|
14
|
-
describe '#using_bundler?' do
|
15
|
-
include_context 'isolated environment'
|
16
|
-
|
17
|
-
subject { project.using_bundler? }
|
18
|
-
|
19
|
-
context 'when the project has a Gemfile.lock' do
|
20
|
-
before do
|
21
|
-
create_file('Gemfile.lock', '')
|
22
|
-
end
|
23
|
-
|
24
|
-
it { should be_true }
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'when the project have no Gemfile.lock' do
|
28
|
-
it { should be_false }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '#depend_on_rspec_rails?' do
|
33
|
-
include_context 'isolated environment'
|
34
|
-
|
35
|
-
subject { project.depend_on_rspec_rails? }
|
36
|
-
|
37
|
-
context 'when the project has a Gemfile.lock' do
|
38
|
-
before do
|
39
|
-
create_file('Gemfile.lock', gemfile_content)
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'and rspec-rails is bundled' do
|
43
|
-
let(:gemfile_content) do
|
44
|
-
<<-END.strip_heredoc
|
45
|
-
GEM
|
46
|
-
remote: https://rubygems.org/
|
47
|
-
specs:
|
48
|
-
actionpack (4.1.7)
|
49
|
-
actionview (= 4.1.7)
|
50
|
-
activesupport (= 4.1.7)
|
51
|
-
rack (~> 1.5.2)
|
52
|
-
rack-test (~> 0.6.2)
|
53
|
-
actionview (4.1.7)
|
54
|
-
activesupport (= 4.1.7)
|
55
|
-
builder (~> 3.1)
|
56
|
-
erubis (~> 2.7.0)
|
57
|
-
activemodel (4.1.7)
|
58
|
-
activesupport (= 4.1.7)
|
59
|
-
builder (~> 3.1)
|
60
|
-
activesupport (4.1.7)
|
61
|
-
i18n (~> 0.6, >= 0.6.9)
|
62
|
-
json (~> 1.7, >= 1.7.7)
|
63
|
-
minitest (~> 5.1)
|
64
|
-
thread_safe (~> 0.1)
|
65
|
-
tzinfo (~> 1.1)
|
66
|
-
builder (3.2.2)
|
67
|
-
diff-lcs (1.2.5)
|
68
|
-
erubis (2.7.0)
|
69
|
-
i18n (0.6.11)
|
70
|
-
json (1.8.1)
|
71
|
-
minitest (5.4.3)
|
72
|
-
rack (1.5.2)
|
73
|
-
rack-test (0.6.2)
|
74
|
-
rack (>= 1.0)
|
75
|
-
railties (4.1.7)
|
76
|
-
actionpack (= 4.1.7)
|
77
|
-
activesupport (= 4.1.7)
|
78
|
-
rake (>= 0.8.7)
|
79
|
-
thor (>= 0.18.1, < 2.0)
|
80
|
-
rake (10.4.0)
|
81
|
-
rspec-core (2.14.8)
|
82
|
-
rspec-expectations (2.14.5)
|
83
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
84
|
-
rspec-mocks (2.14.6)
|
85
|
-
rspec-rails (2.14.2)
|
86
|
-
actionpack (>= 3.0)
|
87
|
-
activemodel (>= 3.0)
|
88
|
-
activesupport (>= 3.0)
|
89
|
-
railties (>= 3.0)
|
90
|
-
rspec-core (~> 2.14.0)
|
91
|
-
rspec-expectations (~> 2.14.0)
|
92
|
-
rspec-mocks (~> 2.14.0)
|
93
|
-
thor (0.19.1)
|
94
|
-
thread_safe (0.3.4)
|
95
|
-
tzinfo (1.2.2)
|
96
|
-
thread_safe (~> 0.1)
|
97
|
-
|
98
|
-
PLATFORMS
|
99
|
-
ruby
|
100
|
-
|
101
|
-
DEPENDENCIES
|
102
|
-
rspec-rails (~> 2.14.0)
|
103
|
-
END
|
104
|
-
end
|
105
|
-
|
106
|
-
it { should be_true }
|
107
|
-
end
|
108
|
-
|
109
|
-
context 'and rspec-rails is not bundled' do
|
110
|
-
let(:gemfile_content) do
|
111
|
-
<<-END.strip_heredoc
|
112
|
-
GEM
|
113
|
-
remote: https://rubygems.org/
|
114
|
-
specs:
|
115
|
-
diff-lcs (1.2.5)
|
116
|
-
rspec (2.14.1)
|
117
|
-
rspec-core (~> 2.14.0)
|
118
|
-
rspec-expectations (~> 2.14.0)
|
119
|
-
rspec-mocks (~> 2.14.0)
|
120
|
-
rspec-core (2.14.8)
|
121
|
-
rspec-expectations (2.14.5)
|
122
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
123
|
-
rspec-mocks (2.14.6)
|
124
|
-
|
125
|
-
PLATFORMS
|
126
|
-
ruby
|
127
|
-
|
128
|
-
DEPENDENCIES
|
129
|
-
rspec (~> 2.14.0)
|
130
|
-
END
|
131
|
-
end
|
132
|
-
|
133
|
-
it { should be_false }
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
context 'when the project have no Gemfile.lock' do
|
138
|
-
it { should be_false }
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe '#rspec_version' do
|
143
|
-
subject(:rspec_version) { project.rspec_version }
|
144
|
-
|
145
|
-
it 'returns an instance of RSpecVersion' do
|
146
|
-
should be_a(RSpecVersion)
|
147
|
-
end
|
148
|
-
|
149
|
-
context 'when the project has a Gemfile' do
|
150
|
-
context 'and depends on RSpec 2.13.0' do
|
151
|
-
around do |example|
|
152
|
-
with_cached_dir('rspec-2.13.0-project') do |cached|
|
153
|
-
unless cached
|
154
|
-
create_file('Gemfile', [
|
155
|
-
"source 'https://rubygems.org'",
|
156
|
-
"gem 'rspec-core', '2.13.0'"
|
157
|
-
])
|
158
|
-
|
159
|
-
Bundler.with_clean_env do
|
160
|
-
`bundle install --path vendor/bundle`
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
example.run
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
it 'returns the version' do
|
169
|
-
rspec_version.to_s.should == '2.13.0'
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
context 'when the project has no Gemfile' do
|
175
|
-
include_context 'isolated environment'
|
176
|
-
|
177
|
-
it 'returns version of the RSpec installed in the system' do
|
178
|
-
require 'rspec/core/version'
|
179
|
-
rspec_version.to_s.should == RSpec::Core::Version::STRING
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
context 'when failed checking version' do
|
184
|
-
before do
|
185
|
-
IO.stub(:popen).and_return(nil)
|
186
|
-
end
|
187
|
-
|
188
|
-
it 'raises error' do
|
189
|
-
-> { rspec_version }.should raise_error(/failed checking/i)
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
@@ -1,128 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'transpec/record'
|
5
|
-
|
6
|
-
module Transpec
|
7
|
-
describe Record do
|
8
|
-
subject(:record) { Record.new(old_syntax, new_syntax, options) }
|
9
|
-
let(:old_syntax) { 'obj.should' }
|
10
|
-
let(:new_syntax) { 'expect(obj).to' }
|
11
|
-
let(:options) { {} }
|
12
|
-
|
13
|
-
describe '.new' do
|
14
|
-
context 'when invalid type is passed' do
|
15
|
-
it 'raises error' do
|
16
|
-
lambda do
|
17
|
-
Record.new('foo', 'bar', type: :unknown_type)
|
18
|
-
end.should raise_error(/invalid type/i)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#type' do
|
24
|
-
subject { record.type }
|
25
|
-
|
26
|
-
context 'when it has both old and new syntaxes' do
|
27
|
-
let(:old_syntax) { 'obj.should' }
|
28
|
-
let(:new_syntax) { 'expect(obj).to' }
|
29
|
-
it { should == :conversion }
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'when it has only new syntax' do
|
33
|
-
let(:old_syntax) { nil }
|
34
|
-
let(:new_syntax) { 'expect(obj).to' }
|
35
|
-
it { should == :addition }
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'when it has only old syntax' do
|
39
|
-
let(:old_syntax) { 'obj.should' }
|
40
|
-
let(:new_syntax) { nil }
|
41
|
-
it { should == :removal }
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'when the type is specified explicitly' do
|
45
|
-
let(:old_syntax) { 'foo = true' }
|
46
|
-
let(:new_syntax) { 'foo = false' }
|
47
|
-
let(:options) { { type: :modification } }
|
48
|
-
it { should == :modification }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '#to_s' do
|
53
|
-
subject { record.to_s }
|
54
|
-
|
55
|
-
context "when it's a conversion" do
|
56
|
-
let(:old_syntax) { 'obj.should' }
|
57
|
-
let(:new_syntax) { 'expect(obj).to' }
|
58
|
-
|
59
|
-
it 'returns "Conversion from `old syntax` to `new syntax`"' do
|
60
|
-
record.to_s.should == 'Conversion from `obj.should` to `expect(obj).to`'
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context "when it's an addition" do
|
65
|
-
let(:old_syntax) { nil }
|
66
|
-
let(:new_syntax) { 'expect(obj).to' }
|
67
|
-
|
68
|
-
it 'returns "Addition of `new syntax`"' do
|
69
|
-
record.to_s.should == 'Addition of `expect(obj).to`'
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context "when it's a removal" do
|
74
|
-
let(:old_syntax) { 'obj.should' }
|
75
|
-
let(:new_syntax) { nil }
|
76
|
-
|
77
|
-
it 'returns "Removal of `old syntax`"' do
|
78
|
-
record.to_s.should == 'Removal of `obj.should`'
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe RecordBuilder do
|
85
|
-
describe '.build' do
|
86
|
-
builder_class = Class.new(RecordBuilder) do
|
87
|
-
attr_reader :some_attr
|
88
|
-
|
89
|
-
def initialize(some_attr)
|
90
|
-
@some_attr = some_attr
|
91
|
-
end
|
92
|
-
|
93
|
-
def old_syntax
|
94
|
-
"obj.should be #{some_attr}"
|
95
|
-
end
|
96
|
-
|
97
|
-
def new_syntax
|
98
|
-
"expect(obj).to be #{some_attr}"
|
99
|
-
end
|
100
|
-
|
101
|
-
def type
|
102
|
-
:modification
|
103
|
-
end
|
104
|
-
|
105
|
-
def annotation
|
106
|
-
'some annotation'
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
let(:record) { builder_class.build('something') }
|
111
|
-
|
112
|
-
it 'returns an instance of Record' do
|
113
|
-
record.should be_a(Record)
|
114
|
-
end
|
115
|
-
|
116
|
-
{
|
117
|
-
old_syntax: 'obj.should be something',
|
118
|
-
new_syntax: 'expect(obj).to be something',
|
119
|
-
type: :modification,
|
120
|
-
annotation: 'some annotation'
|
121
|
-
}.each do |attribute, value|
|
122
|
-
it "sets builder's ##{attribute} value to record's ##{attribute}" do
|
123
|
-
record.send(attribute).should == value
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
@@ -1,126 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'transpec/report'
|
5
|
-
require 'transpec/record'
|
6
|
-
require 'transpec/syntax'
|
7
|
-
|
8
|
-
module Transpec
|
9
|
-
describe Report do
|
10
|
-
subject(:report) { Report.new }
|
11
|
-
|
12
|
-
before do
|
13
|
-
options = { annotation: double('annotation') }
|
14
|
-
report.records << Record.new('obj.stub(:message)', 'allow(obj).to receive(:message)', options)
|
15
|
-
report.records << Record.new('obj.should', 'expect(obj).to')
|
16
|
-
report.records << Record.new('obj.should', 'expect(obj).to', options)
|
17
|
-
report.records << Record.new(nil, 'RSpec.configure { |c| c.infer_spec_type_from_file_location! }')
|
18
|
-
report.conversion_errors << ContextError.new('#should', '#expect', double('range'))
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '#unique_record_counts' do
|
22
|
-
subject(:unique_record_counts) { report.unique_record_counts }
|
23
|
-
|
24
|
-
it 'returns counts for unique records' do
|
25
|
-
unique_record_counts.size.should == 3
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'returns hash with record as key and count as value' do
|
29
|
-
unique_record_counts.each do |record, count|
|
30
|
-
case record
|
31
|
-
when Record.new('obj.stub(:message)', 'allow(obj).to receive(:message)')
|
32
|
-
count.should == 1
|
33
|
-
when Record.new('obj.should', 'expect(obj).to')
|
34
|
-
count.should == 2
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'is sorted by count in descending order' do
|
40
|
-
unique_record_counts.values.should == [2, 1, 1]
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '#summary' do
|
45
|
-
it 'returns summary string' do
|
46
|
-
report.summary.should == <<-END.gsub(/^\s+\|/, '')
|
47
|
-
|2 conversions
|
48
|
-
| from: obj.should
|
49
|
-
| to: expect(obj).to
|
50
|
-
|1 conversion
|
51
|
-
| from: obj.stub(:message)
|
52
|
-
| to: allow(obj).to receive(:message)
|
53
|
-
|1 addition
|
54
|
-
| of: RSpec.configure { |c| c.infer_spec_type_from_file_location! }
|
55
|
-
END
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'when :separate_by_blank_line option is enabled' do
|
59
|
-
it 'separates conversion entries by blank line' do
|
60
|
-
report.summary(separate_by_blank_line: true).should == <<-END.gsub(/^\s+\|/, '')
|
61
|
-
|2 conversions
|
62
|
-
| from: obj.should
|
63
|
-
| to: expect(obj).to
|
64
|
-
|
|
65
|
-
|1 conversion
|
66
|
-
| from: obj.stub(:message)
|
67
|
-
| to: allow(obj).to receive(:message)
|
68
|
-
|
|
69
|
-
|1 addition
|
70
|
-
| of: RSpec.configure { |c| c.infer_spec_type_from_file_location! }
|
71
|
-
END
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context 'when :bullet option is specified' do
|
76
|
-
it 'adds the bullet for each conversion entry' do
|
77
|
-
report.summary(bullet: '-').should == <<-END.gsub(/^\s+\|/, '')
|
78
|
-
|- 2 conversions
|
79
|
-
| from: obj.should
|
80
|
-
| to: expect(obj).to
|
81
|
-
|- 1 conversion
|
82
|
-
| from: obj.stub(:message)
|
83
|
-
| to: allow(obj).to receive(:message)
|
84
|
-
|- 1 addition
|
85
|
-
| of: RSpec.configure { |c| c.infer_spec_type_from_file_location! }
|
86
|
-
END
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe '#stats' do
|
92
|
-
it 'returns stats string' do
|
93
|
-
report.stats.should == '4 conversions, 1 incomplete, 2 warnings, 0 errors'
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '#<<' do
|
98
|
-
subject(:concated_report) { report << another_report }
|
99
|
-
|
100
|
-
let(:another_report) do
|
101
|
-
report = Report.new
|
102
|
-
report.records << Record.new('obj.stub(:message)', 'allow(obj).to receive(:message)')
|
103
|
-
report.conversion_errors << ContextError.new('#should', '#expect', double('range'))
|
104
|
-
report.conversion_errors << ContextError.new('#stub', '#allow', double('range'))
|
105
|
-
report.file_errors << double('file error')
|
106
|
-
report
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'returns the receiver' do
|
110
|
-
concated_report.should equal(report)
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'concats records' do
|
114
|
-
concated_report.should have(5).records
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'concats conversion errors' do
|
118
|
-
concated_report.should have(3).conversion_errors
|
119
|
-
end
|
120
|
-
|
121
|
-
it 'concats file errors' do
|
122
|
-
concated_report.should have(1).file_errors
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|