Sha256: fcc51f422fbea1a0ab34766566683c01122b8b4c9e3c0f73a433270bf0647f7a
Contents?: true
Size: 1.75 KB
Versions: 4
Compression:
Stored size: 1.75 KB
Contents
shared_examples_for 'a mutator' do subject { object.each(node) { |item| yields << item } } let(:yields) { [] } let(:object) { described_class } unless instance_methods.map(&:to_s).include?('node') let(:node) { source.to_ast } end it_should_behave_like 'a command method' context 'with no block' do subject { object.each(node) } it { should be_instance_of(to_enum.class) } def assert_transitive(ast) generated = ToSource.to_source(ast) parsed = generated.to_ast again = ToSource.to_source(parsed) unless generated == again fail "Untransitive:\n%s\n---\n%s" % [generated, again] end end unless instance_methods.include?(:expected_mutations) let(:expected_mutations) do mutations.map do |mutation| case mutation when String ast = mutation.to_ast assert_transitive(ast) ast when Rubinius::AST::Node assert_transitive(mutation) mutation else raise end end.map do |node| ToSource.to_source(node) end.to_set end end it 'generates the expected mutations' do generated = self.subject.map { |mutation| ToSource.to_source(mutation) }.to_set missing = (expected_mutations - generated).to_a unexpected = (generated - expected_mutations).to_a unless generated == expected_mutations message ="Missing mutations:\n%s\nUnexpected mutations:\n%s" % [missing.join("\n----\n"), unexpected.join("\n----\n")] fail message end end end end shared_examples_for 'a noop mutator' do let(:mutations) { [] } it_should_behave_like 'a mutator' end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
mutant-0.2.12 | spec/shared/mutator_behavior.rb |
mutant-0.2.11 | spec/shared/mutator_behavior.rb |
mutant-0.2.9 | spec/shared/mutator_behavior.rb |
mutant-0.2.8 | spec/shared/mutator_behavior.rb |