Skip to content
Permalink
Browse files

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`.
  • Loading branch information
mbj committed Aug 10, 2014
1 parent 978e246 commit 6df5811a8762bbf7adcf241f5b9867952854433f
Showing with 52 additions and 142 deletions.
  1. +1 −0 .rspec
  2. +1 −6 spec/integration/mutant/corpus_spec.rb
  3. +1 −3 spec/integration/mutant/null_spec.rb
  4. +1 −3 spec/integration/mutant/rspec_spec.rb
  5. +1 −3 spec/integration/mutant/test_mutator_handles_types_spec.rb
  6. +1 −3 spec/integration/mutant/zombie_spec.rb
  7. +1 −1 spec/shared/method_matcher_behavior.rb
  8. +2 −2 spec/shared/mutator_behavior.rb
  9. +3 −5 spec/unit/mutant/cli_spec.rb
  10. +1 −3 spec/unit/mutant/context/root_spec.rb
  11. +1 −3 spec/unit/mutant/context/scope/root_spec.rb
  12. +1 −3 spec/unit/mutant/context/scope/unqualified_name_spec.rb
  13. +1 −3 spec/unit/mutant/diff_spec.rb
  14. +1 −3 spec/unit/mutant/expression/method_spec.rb
  15. +1 −3 spec/unit/mutant/expression/methods_spec.rb
  16. +1 −3 spec/unit/mutant/expression/namespace/flat_spec.rb
  17. +1 −3 spec/unit/mutant/expression/namespace/recursive_spec.rb
  18. +1 −3 spec/unit/mutant/expression_spec.rb
  19. +2 −4 spec/unit/mutant/integration_spec.rb
  20. +2 −4 spec/unit/mutant/isolation_spec.rb
  21. +1 −3 spec/unit/mutant/loader/eval_spec.rb
  22. +1 −3 spec/unit/mutant/matcher/chain_spec.rb
  23. +1 −3 spec/unit/mutant/matcher/compiler/subject_prefix_spec.rb
  24. +1 −3 spec/unit/mutant/matcher/compiler_spec.rb
  25. +1 −3 spec/unit/mutant/matcher/filter_spec.rb
  26. +1 −3 spec/unit/mutant/matcher/method/instance_spec.rb
  27. +1 −3 spec/unit/mutant/matcher/method/singleton_spec.rb
  28. +1 −3 spec/unit/mutant/matcher/methods/instance_spec.rb
  29. +1 −3 spec/unit/mutant/matcher/methods/singleton_spec.rb
  30. +1 −3 spec/unit/mutant/matcher/namespace_spec.rb
  31. +1 −3 spec/unit/mutant/matcher/null_spec.rb
  32. +1 −3 spec/unit/mutant/mutation_spec.rb
  33. +1 −3 spec/unit/mutant/mutator/node_spec.rb
  34. +1 −3 spec/unit/mutant/reporter/cli_spec.rb
  35. +1 −3 spec/unit/mutant/reporter/null_spec.rb
  36. +1 −3 spec/unit/mutant/require_highjack_spec.rb
  37. +1 −3 spec/unit/mutant/runner_spec.rb
  38. +1 −3 spec/unit/mutant/subject/context_spec.rb
  39. +2 −6 spec/unit/mutant/subject/method/instance_spec.rb
  40. +1 −5 spec/unit/mutant/subject/method/singleton_spec.rb
  41. +1 −3 spec/unit/mutant/subject_spec.rb
  42. +1 −3 spec/unit/mutant/test_spec.rb
  43. +1 −3 spec/unit/mutant/warning_expectation.rb
  44. +1 −3 spec/unit/mutant/warning_filter_spec.rb
  45. +1 −3 spec/unit/mutant_spec.rb
  46. +1 −1 test_app/spec/unit/test_app/literal/string_spec.rb
1 .rspec
@@ -1,4 +1,5 @@
--color
--require spec_helper
--format progress
--warnings
--order random
@@ -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')
@@ -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*"' }

@@ -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' }

@@ -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|
@@ -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)
@@ -1,4 +1,4 @@
shared_examples_for 'a method matcher' do
RSpec.shared_examples_for 'a method matcher' do

before { subject }

@@ -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 @@ def normalize(node)
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'
@@ -1,20 +1,18 @@
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
end.to raise_error(Mutant::CLI::Error, expected_message)
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
@@ -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 }
@@ -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) }
@@ -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') }
@@ -1,6 +1,4 @@
require 'spec_helper'

describe Mutant::Diff do
RSpec.describe Mutant::Diff do
let(:object) { described_class }

describe '.build' do
@@ -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 }
@@ -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 }
@@ -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 }
@@ -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*' }
@@ -1,6 +1,4 @@
require 'spec_helper'

describe Mutant::Expression do
RSpec.describe Mutant::Expression do
let(:object) { described_class }

describe '.try_parse' do
@@ -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 @@
end
end

describe Mutant::Integration::Null do
RSpec.describe Mutant::Integration::Null do

let(:object) { described_class.new }

@@ -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 @@
end
end

describe Mutant::Isolation::Fork do
RSpec.describe Mutant::Isolation::Fork do
before do
@initial = 1
end
@@ -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) }

@@ -1,6 +1,4 @@
require 'spec_helper'

describe Mutant::Matcher::Chain do
RSpec.describe Mutant::Matcher::Chain do

let(:object) { described_class.new(matchers) }

@@ -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)) }
@@ -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 }
@@ -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
@@ -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 }
@@ -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) }
@@ -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 }

@@ -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 }

@@ -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') }
@@ -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
@@ -1,6 +1,4 @@
require 'spec_helper'

describe Mutant::Mutation do
RSpec.describe Mutant::Mutation do

class TestMutation < Mutant::Mutation
SYMBOL = 'test'.freeze
@@ -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
@@ -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 }

@@ -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
@@ -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) { [] }
@@ -1,5 +1,3 @@
require 'spec_helper'

class Double
include Concord.new(:name, :attributes)

@@ -19,7 +17,7 @@ def method_missing(name, *arguments)
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 }
@@ -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
@@ -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 @@ def foo
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 }
@@ -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 }
@@ -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
@@ -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') }

0 comments on commit 6df5811

Please sign in to comment.
You can’t perform that action at this time.