spec/unit/yardcheck/runner_spec.rb in yardcheck-0.0.1 vs spec/unit/yardcheck/runner_spec.rb in yardcheck-0.0.2
- old
+ new
@@ -17,36 +17,34 @@
end
end
let(:observed_events) do
[
- Yardcheck::MethodCall.process(
+ Yardcheck::MethodCall::Return.process(
scope: :instance,
selector: :add,
namespace: TestApp::Namespace,
params: { left: 'foo', right: 3 },
return_value: 5,
- example_location: 'test_app_spec.rb:1',
- error_raised: false
+ example_location: 'test_app_spec.rb:1'
),
- Yardcheck::MethodCall.process(
+ Yardcheck::MethodCall::Return.process(
scope: :class,
selector: :add,
namespace: TestApp::Namespace.singleton_class,
params: { left: 2, right: 3 },
return_value: 5,
- example_location: 'test_app_spec.rb:2',
- error_raised: false
+ example_location: 'test_app_spec.rb:2'
)
]
end
let(:output) do
<<~MSG
Expected #<Class:TestApp::Namespace>#add to return String but observed Fixnum
- source: ./test_app/lib/test_app.rb:9
+ source: ./test_app/lib/test_app.rb:15
tests:
- test_app_spec.rb:2
# Singleton method with correct param definition and incorrect return
#
@@ -58,11 +56,11 @@
left + right
end
Expected TestApp::Namespace#add to receive Integer for left but observed String
- source: ./test_app/lib/test_app.rb:19
+ source: ./test_app/lib/test_app.rb:25
tests:
- test_app_spec.rb:1
# Instance method with correct param definition and incorrect return
#
@@ -74,11 +72,11 @@
left + right
end
Expected TestApp::Namespace#add to return String but observed Fixnum
- source: ./test_app/lib/test_app.rb:19
+ source: ./test_app/lib/test_app.rb:25
tests:
- test_app_spec.rb:1
# Instance method with correct param definition and incorrect return
#
@@ -95,10 +93,14 @@
def remove_color(string)
string.gsub(/\e\[(?:1\;)?\d+m/, '')
end
+ before do
+ allow(Kernel).to receive(:exit).with(1)
+ end
+
shared_examples 'violation output' do
it 'compares the spec observations against the documentation' do
runner.check
expect(remove_color(io.string)).to eql(output)
@@ -108,45 +110,42 @@
include_examples 'violation output'
context 'when multiple tests find the same violation' do
let(:observed_events) do
[
- Yardcheck::MethodCall.process(
+ Yardcheck::MethodCall::Return.process(
scope: :instance,
selector: :add,
namespace: TestApp::Namespace,
params: { left: 'foo', right: 3 },
return_value: 'valid return type',
- example_location: 'test_app_spec.rb:1',
- error_raised: false
+ example_location: 'test_app_spec.rb:1'
),
- Yardcheck::MethodCall.process(
+ Yardcheck::MethodCall::Return.process(
scope: :instance,
selector: :add,
namespace: TestApp::Namespace,
params: { left: 'foo', right: 3 },
return_value: 'valid return type',
- example_location: 'test_app_spec.rb:2',
- error_raised: false
+ example_location: 'test_app_spec.rb:2'
),
- Yardcheck::MethodCall.process(
+ Yardcheck::MethodCall::Return.process(
scope: :instance,
selector: :add,
namespace: TestApp::Namespace,
params: { left: 1, right: 'now this one is wrong' },
return_value: 'valid return type',
- example_location: 'test_app_spec.rb:3',
- error_raised: false
+ example_location: 'test_app_spec.rb:3'
)
]
end
let(:output) do
<<~MSG
Expected TestApp::Namespace#add to receive Integer for left but observed String
- source: ./test_app/lib/test_app.rb:19
+ source: ./test_app/lib/test_app.rb:25
tests:
- test_app_spec.rb:1
- test_app_spec.rb:2
# Instance method with correct param definition and incorrect return
@@ -159,10 +158,10 @@
left + right
end
Expected TestApp::Namespace#add to receive Integer for right but observed String
- source: ./test_app/lib/test_app.rb:19
+ source: ./test_app/lib/test_app.rb:25
tests:
- test_app_spec.rb:3
# Instance method with correct param definition and incorrect return
#