Skip to content

Commit

Permalink
Test dynamic accessor generation for output context class
Browse files Browse the repository at this point in the history
  • Loading branch information
maetl committed May 18, 2018
1 parent 3633da9 commit 43e8b11
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/output_context_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require "spec_helper"

describe Yarrow::Output::Context do
let(:context_hash) do
Yarrow::Output::Context.new(number: 99, text: "plain value")
end

class Value
def text
"nested value"
end
end

let(:object_hash) do
Yarrow::Output::Context.new(value: Value.new)
end

it 'generates dynamic accessors for hash values on initialization' do
expect(context_hash.number).to eq(99)
expect(context_hash.text).to eq("plain value")
end

it 'generates dynamic accessors for value objects on initialization' do
expect(object_hash.value.text).to eq("nested value")
end
end

0 comments on commit 43e8b11

Please sign in to comment.