Permalink
Browse files

Kill mutations in ClassMethods#new

  • Loading branch information...
1 parent 5a16b03 commit a494e9fd3a3dd46a58cd373e532197e309144206 @mbj mbj committed Jun 29, 2013
Showing with 36 additions and 8 deletions.
  1. +36 −8 spec/unit/abstract_type/class_methods/new_spec.rb
@@ -3,19 +3,47 @@
require 'spec_helper'
describe AbstractType::ClassMethods, '#new' do
- subject { object.new }
+ context 'with arguments' do
+ subject { object.new(:foo) }
- let(:abstract_type) { Class.new { include AbstractType } }
+ let(:abstract_type) do
+ Class.new do
+ include AbstractType
- context 'called on a subclass' do
- let(:object) { Class.new(abstract_type) }
+ def initialize(foo)
+ @foo = foo
+ end
+ end
+ end
- it { should be_instance_of(object) }
+ context 'called on a subclass' do
+ let(:object) { Class.new(abstract_type) }
+
+ it { should be_instance_of(object) }
+ end
+
+ context 'called on the class' do
+ let(:object) { abstract_type }
+
+ specify { expect { subject }.to raise_error(NotImplementedError, "#{object} is an abstract type") }
+ end
end
- context 'called on the class' do
- let(:object) { abstract_type }
+ context 'without arguments' do
+ subject { object.new }
+
+ let(:abstract_type) { Class.new { include AbstractType } }
+
+ context 'called on a subclass' do
+ let(:object) { Class.new(abstract_type) }
+
+ it { should be_instance_of(object) }
+ end
+
+ context 'called on the class' do
+ let(:object) { abstract_type }
- specify { expect { subject }.to raise_error(NotImplementedError, "#{object} is an abstract type") }
+ specify { expect { subject }.to raise_error(NotImplementedError, "#{object} is an abstract type") }
+ end
end
end

0 comments on commit a494e9f

Please sign in to comment.