transpec 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +1 -1
- data/CHANGELOG.md +6 -0
- data/README.md +106 -79
- data/README.md.erb +91 -73
- data/lib/transpec/cli.rb +1 -1
- data/lib/transpec/converter.rb +16 -5
- data/lib/transpec/syntax/allow.rb +4 -0
- data/lib/transpec/syntax/expect.rb +4 -0
- data/lib/transpec/syntax/have.rb +24 -13
- data/lib/transpec/syntax/method_stub.rb +42 -6
- data/lib/transpec/syntax/mixin/any_instance_block.rb +14 -5
- data/lib/transpec/syntax/mixin/expect_base.rb +6 -5
- data/lib/transpec/syntax/mixin/messaging_host.rb +17 -0
- data/lib/transpec/syntax/mixin/{allow_no_message.rb → no_message_allowance.rb} +5 -4
- data/lib/transpec/syntax/mixin/send.rb +0 -13
- data/lib/transpec/syntax/mixin/should_base.rb +7 -1
- data/lib/transpec/syntax/mixin/useless_and_return.rb +79 -0
- data/lib/transpec/syntax/operator_matcher.rb +20 -4
- data/lib/transpec/syntax/receive.rb +21 -6
- data/lib/transpec/syntax/should_receive.rb +14 -11
- data/lib/transpec/util.rb +46 -0
- data/lib/transpec/version.rb +1 -1
- data/spec/transpec/converter_spec.rb +60 -18
- data/spec/transpec/syntax/expect_spec.rb +41 -9
- data/spec/transpec/syntax/method_stub_spec.rb +99 -2
- data/spec/transpec/syntax/operator_matcher_spec.rb +19 -84
- data/spec/transpec/syntax/receive_spec.rb +231 -2
- data/spec/transpec/syntax/should_receive_spec.rb +38 -0
- data/spec/transpec/syntax/should_spec.rb +28 -39
- data/tasks/readme.rake +16 -2
- metadata +5 -3
@@ -937,6 +937,44 @@ module Transpec
|
|
937
937
|
end
|
938
938
|
end
|
939
939
|
|
940
|
+
describe '#remove_useless_and_return!' do
|
941
|
+
before do
|
942
|
+
should_receive_object.remove_useless_and_return!
|
943
|
+
end
|
944
|
+
|
945
|
+
context 'when it is `subject.should_receive(:method).and_return { value }` form' do
|
946
|
+
let(:source) do
|
947
|
+
<<-END
|
948
|
+
describe 'example' do
|
949
|
+
it 'receives #foo and returns 1' do
|
950
|
+
subject.should_receive(:foo).and_return { 1 }
|
951
|
+
end
|
952
|
+
end
|
953
|
+
END
|
954
|
+
end
|
955
|
+
|
956
|
+
let(:expected_source) do
|
957
|
+
<<-END
|
958
|
+
describe 'example' do
|
959
|
+
it 'receives #foo and returns 1' do
|
960
|
+
subject.should_receive(:foo) { 1 }
|
961
|
+
end
|
962
|
+
end
|
963
|
+
END
|
964
|
+
end
|
965
|
+
|
966
|
+
it 'converts into `subject.should_receive(:method) { value }` form' do
|
967
|
+
rewritten_source.should == expected_source
|
968
|
+
end
|
969
|
+
|
970
|
+
it 'adds record ' \
|
971
|
+
'`obj.should_receive(:message).and_return { value }` -> `obj.should_receive(:message) { value }`' do
|
972
|
+
record.original_syntax.should == 'obj.should_receive(:message).and_return { value }'
|
973
|
+
record.converted_syntax.should == 'obj.should_receive(:message) { value }'
|
974
|
+
end
|
975
|
+
end
|
976
|
+
end
|
977
|
+
|
940
978
|
describe '#add_receiver_arg_to_any_instance_implementation_block!' do
|
941
979
|
before do
|
942
980
|
should_receive_object.add_receiver_arg_to_any_instance_implementation_block!
|
@@ -12,7 +12,9 @@ module Transpec
|
|
12
12
|
let(:record) { should_object.report.records.first }
|
13
13
|
|
14
14
|
describe '#matcher_node' do
|
15
|
-
|
15
|
+
let(:matcher_name) { should_object.matcher_node.children[1] }
|
16
|
+
|
17
|
+
context 'when the matcher is operator' do
|
16
18
|
let(:source) do
|
17
19
|
<<-END
|
18
20
|
describe 'example' do
|
@@ -23,22 +25,12 @@ module Transpec
|
|
23
25
|
END
|
24
26
|
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
# (str "is 1"))
|
29
|
-
# (args)
|
30
|
-
# (send
|
31
|
-
# (send
|
32
|
-
# (send nil :subject) :should) :==
|
33
|
-
# (int 1)))
|
34
|
-
|
35
|
-
it 'returns its parent node' do
|
36
|
-
should_object.parent_node.children[1].should == :==
|
37
|
-
should_object.matcher_node.should == should_object.parent_node
|
28
|
+
it 'returns the matcher node' do
|
29
|
+
matcher_name.should == :==
|
38
30
|
end
|
39
31
|
end
|
40
32
|
|
41
|
-
context 'when
|
33
|
+
context 'when the matcher is not operator' do
|
42
34
|
let(:source) do
|
43
35
|
<<-END
|
44
36
|
describe 'example' do
|
@@ -49,43 +41,40 @@ module Transpec
|
|
49
41
|
END
|
50
42
|
end
|
51
43
|
|
52
|
-
|
53
|
-
|
54
|
-
# (str "is empty"))
|
55
|
-
# (args)
|
56
|
-
# (send
|
57
|
-
# (send nil :subject) :should
|
58
|
-
# (send nil :be_empty)))
|
59
|
-
|
60
|
-
it 'returns its argument node' do
|
61
|
-
should_object.arg_node.children[1].should == :be_empty
|
62
|
-
should_object.matcher_node.should == should_object.arg_node
|
44
|
+
it 'returns the matcher node' do
|
45
|
+
matcher_name.should == :be_empty
|
63
46
|
end
|
64
47
|
end
|
65
48
|
|
66
|
-
context 'when
|
49
|
+
context 'when the matcher is chained by another method' do
|
67
50
|
let(:source) do
|
68
51
|
<<-END
|
69
52
|
describe 'example' do
|
70
|
-
it '
|
71
|
-
subject.should
|
53
|
+
it 'has 2 items' do
|
54
|
+
subject.should have(2).items
|
72
55
|
end
|
73
56
|
end
|
74
57
|
END
|
75
58
|
end
|
76
59
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
60
|
+
it 'returns the matcher node' do
|
61
|
+
matcher_name.should == :have
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'when the matcher is chained by another method that is taking a block' do
|
66
|
+
let(:source) do
|
67
|
+
<<-END
|
68
|
+
describe 'example' do
|
69
|
+
it 'has 2 items' do
|
70
|
+
subject.should have(2).items { }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
END
|
74
|
+
end
|
85
75
|
|
86
|
-
it 'returns
|
87
|
-
|
88
|
-
should_object.matcher_node.should == should_object.arg_node
|
76
|
+
it 'returns the first node of the chain' do
|
77
|
+
matcher_name.should == :have
|
89
78
|
end
|
90
79
|
end
|
91
80
|
end
|
data/tasks/readme.rake
CHANGED
@@ -23,7 +23,21 @@ def generate_readme
|
|
23
23
|
require 'erb'
|
24
24
|
require 'transpec/cli'
|
25
25
|
|
26
|
-
|
27
|
-
erb = ERB.new(
|
26
|
+
readme = File.read('README.md.erb')
|
27
|
+
erb = ERB.new(readme, nil, '-')
|
28
28
|
erb.result(binding)
|
29
29
|
end
|
30
|
+
|
31
|
+
def table_of_contents(lines, header_level)
|
32
|
+
header_pattern = /^#{'#' * header_level}[^#]/
|
33
|
+
|
34
|
+
titles = lines.map do |line|
|
35
|
+
next unless line.match(header_pattern)
|
36
|
+
line.sub(/^[#\s]*/, '').chomp
|
37
|
+
end.compact
|
38
|
+
|
39
|
+
titles.map do |title|
|
40
|
+
anchor = '#' + title.gsub(/[^\w_\- ]/, '').downcase.gsub(' ', '-')
|
41
|
+
"* [#{title}](#{anchor})"
|
42
|
+
end.join("\n")
|
43
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transpec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Nakayama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -262,16 +262,18 @@ files:
|
|
262
262
|
- lib/transpec/syntax/its.rb
|
263
263
|
- lib/transpec/syntax/matcher_definition.rb
|
264
264
|
- lib/transpec/syntax/method_stub.rb
|
265
|
-
- lib/transpec/syntax/mixin/allow_no_message.rb
|
266
265
|
- lib/transpec/syntax/mixin/any_instance_block.rb
|
267
266
|
- lib/transpec/syntax/mixin/expect_base.rb
|
268
267
|
- lib/transpec/syntax/mixin/expectizable.rb
|
269
268
|
- lib/transpec/syntax/mixin/have_matcher_owner.rb
|
269
|
+
- lib/transpec/syntax/mixin/messaging_host.rb
|
270
270
|
- lib/transpec/syntax/mixin/monkey_patch.rb
|
271
271
|
- lib/transpec/syntax/mixin/monkey_patch_any_instance.rb
|
272
|
+
- lib/transpec/syntax/mixin/no_message_allowance.rb
|
272
273
|
- lib/transpec/syntax/mixin/owned_matcher.rb
|
273
274
|
- lib/transpec/syntax/mixin/send.rb
|
274
275
|
- lib/transpec/syntax/mixin/should_base.rb
|
276
|
+
- lib/transpec/syntax/mixin/useless_and_return.rb
|
275
277
|
- lib/transpec/syntax/oneliner_should.rb
|
276
278
|
- lib/transpec/syntax/operator_matcher.rb
|
277
279
|
- lib/transpec/syntax/raise_error.rb
|