Skip to content

Commit

Permalink
Add test for passed-in block
Browse files Browse the repository at this point in the history
  • Loading branch information
amcaplan committed Jan 31, 2016
1 parent d59044f commit b386df2
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion spec/dynamic_class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def expect_subject_does_not_respond(attribute)
end

describe 'append-only method signature' do
it 'does not respond to getters and setters by default' do
it 'does not respond to getters and setters by default' do
expect_subject_does_not_respond(:foo)
end

Expand Down Expand Up @@ -255,4 +255,28 @@ def expect_subject_does_not_respond(attribute)
end
end
end

describe 'custom class code' do
context 'when a block is not specified' do
let(:klass) { DynamicClass.new }

it 'does not raise an error' do
expect { klass.new }.not_to raise_error
end
end

context 'when a block is specified' do
let(:klass) {
DynamicClass.new do
def four
4
end
end
}

it 'responds to methods defined in the passed-in block' do
expect(subject.four).to eq(4)
end
end
end
end

0 comments on commit b386df2

Please sign in to comment.