Use RSpec as receiver for rspec DSL methods

* I dislike the global infection RSpec does. This commit is a first step
  to get a rid of it.
* Also remove the need for `require 'spec_helper` in each spec file with
  adjusting `.rspec`.
This commit is contained in:
Markus Schirp 2014-08-10 21:04:05 +00:00
parent 978e246b67
commit 6df5811a87
46 changed files with 52 additions and 142 deletions

1
.rspec
View File

@ -1,4 +1,5 @@
--color
--require spec_helper
--format progress
--warnings
--order random

View File

@ -1,9 +1,4 @@
# encoding: UTF-8
require 'parallel'
require 'spec_helper'
describe 'Mutant on ruby corpus' do
RSpec.describe 'Mutant on ruby corpus' do
before do
skip 'Corpus test is deactivated on 1.9.3' if RUBY_VERSION.eql?('1.9.3')

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe 'null integration' do
RSpec.describe 'null integration' do
let(:base_cmd) { 'bundle exec mutant -I lib --require test_app "TestApp*"' }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe 'rspec integration' do
RSpec.describe 'rspec integration' do
let(:base_cmd) { 'bundle exec mutant -I lib --require test_app --use rspec' }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe do
RSpec.describe do
specify 'mutant should not crash for any node parser can generate' do
Mutant::AST::Types::ALL.each do |type|

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe 'as a zombie' do
RSpec.describe 'as a zombie' do
specify 'it allows to create zombie from mutant' do
expect { Mutant.zombify }.to change { defined?(Zombie) }.from(nil).to('constant')
expect(Zombie.constants).to include(:Mutant)

View File

@ -1,4 +1,4 @@
shared_examples_for 'a method matcher' do
RSpec.shared_examples_for 'a method matcher' do
before { subject }

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
shared_examples_for 'a mutator' do
RSpec.shared_examples_for 'a mutator' do
subject { object.each(node, &yields.method(:<<)) }
let(:yields) { [] }
@ -48,7 +48,7 @@ shared_examples_for 'a mutator' do
end
end
shared_examples_for 'a noop mutator' do
RSpec.shared_examples_for 'a noop mutator' do
let(:mutations) { [] }
it_should_behave_like 'a mutator'

View File

@ -1,6 +1,4 @@
require 'spec_helper'
shared_examples_for 'an invalid cli run' do
RSpec.shared_examples_for 'an invalid cli run' do
it 'raises error' do
expect do
subject
@ -8,13 +6,13 @@ shared_examples_for 'an invalid cli run' do
end
end
shared_examples_for 'a cli parser' do
RSpec.shared_examples_for 'a cli parser' do
it { expect(subject.config.integration).to eql(expected_integration) }
it { expect(subject.config.reporter).to eql(expected_reporter) }
it { expect(subject.config.matcher_config).to eql(expected_matcher_config) }
end
describe Mutant::CLI do
RSpec.describe Mutant::CLI do
let(:object) { described_class }
describe '.run' do

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Context, '#root' do
RSpec.describe Mutant::Context, '#root' do
subject { object.root }
let(:object) { described_class.allocate }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Context::Scope, '#root' do
RSpec.describe Mutant::Context::Scope, '#root' do
subject { object.root(node) }
let(:object) { described_class.new(TestApp::Literal, path) }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Context::Scope, '#unqualified_name' do
RSpec.describe Mutant::Context::Scope, '#unqualified_name' do
subject { object.unqualified_name }
let(:path) { double('Path') }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Diff do
RSpec.describe Mutant::Diff do
let(:object) { described_class }
describe '.build' do

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Expression::Method do
RSpec.describe Mutant::Expression::Method do
let(:object) { described_class.parse(input) }
let(:env) { Fixtures::TEST_ENV }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Expression::Methods do
RSpec.describe Mutant::Expression::Methods do
let(:object) { described_class.parse(input) }
let(:env) { Fixtures::TEST_ENV }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Expression::Namespace::Exact do
RSpec.describe Mutant::Expression::Namespace::Exact do
let(:object) { described_class.parse(input) }
let(:env) { Fixtures::TEST_ENV }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Expression::Namespace::Recursive do
RSpec.describe Mutant::Expression::Namespace::Recursive do
let(:object) { described_class.parse(input) }
let(:input) { 'TestApp::Literal*' }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Expression do
RSpec.describe Mutant::Expression do
let(:object) { described_class }
describe '.try_parse' do

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Integration do
RSpec.describe Mutant::Integration do
let(:class_under_test) do
Class.new(described_class)
@ -14,7 +12,7 @@ describe Mutant::Integration do
end
end
describe Mutant::Integration::Null do
RSpec.describe Mutant::Integration::Null do
let(:object) { described_class.new }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Isolation::None do
RSpec.describe Mutant::Isolation::None do
before do
@initial = 1
end
@ -24,7 +22,7 @@ describe Mutant::Isolation::None do
end
end
describe Mutant::Isolation::Fork do
RSpec.describe Mutant::Isolation::Fork do
before do
@initial = 1
end

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Loader::Eval, '.call' do
RSpec.describe Mutant::Loader::Eval, '.call' do
subject { object.call(node, mutation_subject) }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Matcher::Chain do
RSpec.describe Mutant::Matcher::Chain do
let(:object) { described_class.new(matchers) }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Matcher::Compiler::SubjectPrefix do
RSpec.describe Mutant::Matcher::Compiler::SubjectPrefix do
let(:object) { described_class.new(Mutant::Expression.parse('Foo*')) }
let(:_subject) { double('Subject', expression: Mutant::Expression.parse(subject_expression)) }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Matcher::Compiler do
RSpec.describe Mutant::Matcher::Compiler do
let(:object) { described_class }
let(:env) { Fixtures::TEST_ENV }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Matcher::Filter do
RSpec.describe Mutant::Matcher::Filter do
let(:object) { described_class.new(matcher, predicate) }
describe '#each' do

View File

@ -1,7 +1,5 @@
require 'spec_helper'
# rubocop:disable ClassAndModuleChildren
describe Mutant::Matcher::Method::Instance do
RSpec.describe Mutant::Matcher::Method::Instance do
let(:env) { Fixtures::TEST_ENV }
let(:reporter) { Fixtures::TEST_CONFIG.reporter }

View File

@ -1,7 +1,5 @@
require 'spec_helper'
# rubocop:disable ClassAndModuleChildren
describe Mutant::Matcher::Method::Singleton, '#each' do
RSpec.describe Mutant::Matcher::Method::Singleton, '#each' do
subject { object.each { |subject| yields << subject } }
let(:object) { described_class.new(env, scope, method) }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Matcher::Methods::Instance, '#each' do
RSpec.describe Mutant::Matcher::Methods::Instance, '#each' do
let(:object) { described_class.new(env, Foo) }
let(:env) { Fixtures::TEST_ENV }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Matcher::Methods::Singleton, '#each' do
RSpec.describe Mutant::Matcher::Methods::Singleton, '#each' do
let(:object) { described_class.new(env, Foo) }
let(:env) { Fixtures::TEST_ENV }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Matcher::Namespace do
RSpec.describe Mutant::Matcher::Namespace do
let(:object) { described_class.new(env, Mutant::Expression.parse('TestApp*')) }
let(:yields) { [] }
let(:env) { double('Env') }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Matcher::Null do
RSpec.describe Mutant::Matcher::Null do
let(:object) { described_class.new }
describe '#each' do

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Mutation do
RSpec.describe Mutant::Mutation do
class TestMutation < Mutant::Mutation
SYMBOL = 'test'.freeze

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Mutator::Node do
RSpec.describe Mutant::Mutator::Node do
Mutant::Meta::Example::ALL.each do |example|
context "on #{example.node.type.inspect}" do
it 'generates the correct mutations' do

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Reporter::CLI do
RSpec.describe Mutant::Reporter::CLI do
let(:object) { described_class.new(output) }
let(:output) { StringIO.new }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Reporter::Null do
RSpec.describe Mutant::Reporter::Null do
let(:object) { described_class.new }
describe '#report' do

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::RequireHighjack do
RSpec.describe Mutant::RequireHighjack do
let(:object) { described_class.new(target, highjacked_calls.method(:push)) }
let(:highjacked_calls) { [] }

View File

@ -1,5 +1,3 @@
require 'spec_helper'
class Double
include Concord.new(:name, :attributes)
@ -19,7 +17,7 @@ class Double
end
# FIXME: This is not even close to a mutation covering spec.
describe Mutant::Runner do
RSpec.describe Mutant::Runner do
let(:object) { described_class.new(env) }
let(:reporter) { Mutant::Reporter::Trace.new }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Subject, '#context' do
RSpec.describe Mutant::Subject, '#context' do
subject { object.context }
let(:class_under_test) do

View File

@ -1,8 +1,4 @@
# encoding: UTF-8
require 'spec_helper'
describe Mutant::Subject::Method::Instance do
RSpec.describe Mutant::Subject::Method::Instance do
let(:object) { described_class.new(config, context, node) }
let(:context) { double }
let(:config) { Mutant::Config::DEFAULT }
@ -71,7 +67,7 @@ describe Mutant::Subject::Method::Instance do
end
end
describe Mutant::Subject::Method::Instance::Memoized do
RSpec.describe Mutant::Subject::Method::Instance::Memoized do
let(:object) { described_class.new(config, context, node) }
let(:context) { double }
let(:config) { Mutant::Config::DEFAULT }

View File

@ -1,8 +1,4 @@
# encoding: UTF-8
require 'spec_helper'
describe Mutant::Subject::Method::Singleton do
RSpec.describe Mutant::Subject::Method::Singleton do
let(:object) { described_class.new(config, context, node) }
let(:config) { Mutant::Config::DEFAULT }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Subject do
RSpec.describe Mutant::Subject do
let(:class_under_test) do
Class.new(described_class) do
def expression

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::Test do
RSpec.describe Mutant::Test do
let(:object) { described_class.new(integration, expression) }
let(:integration) { double('Integration', name: 'test-integration') }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::WarningExpectation do
RSpec.describe Mutant::WarningExpectation do
let(:object) { described_class.new(expected_warnings) }
let(:expected_warnings) { [] }

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant::WarningFilter do
RSpec.describe Mutant::WarningFilter do
before do
if RUBY_ENGINE.eql?('rbx')
skip 'Disabled because expected warnings are from MRI'

View File

@ -1,6 +1,4 @@
require 'spec_helper'
describe Mutant do
RSpec.describe Mutant do
let(:object) { described_class }
describe '.zombify' do

View File

@ -2,7 +2,7 @@
require 'spec_helper'
describe TestApp::Literal, '#string' do
RSpec.describe TestApp::Literal, '#string' do
subject { object.string }
let(:object) { described_class.new }