Interesting. So, what happens if you define @representor_hash in a before
block. It is just really non-standard to create variables in these blocks
in my experience.


On Thu, Jun 5, 2014 at 6:44 PM, Shea Valentine <notifications@github.com>
wrote:

> In spec/lib/representors/serialization/hal_serializer_spec.rb:
>
> > +        end
> > +      end
> > +    end
> > +
> > +
> > +    describe '#to_media_type' do
> > +      context 'empty document' do
> > +        let(:document) { {} }
> > +
> > +        it 'returns a hash with no attributes, links or embedded resources' do
> > +          expect(serializer.to_media_type).to be_empty
> > +        end
> > +      end
> > +
> > +      context 'Document with only properties' do
> > +        representor_hash = {
>
>       context 'Document with properties, links, and embedded' do
>         let(:representor_hash) do
>           {
>             attributes: {
>               'title' => {value: 'The Neverending Story'},
>             },
>             transitions: [
>               {
>                 href: '/mike',
>                 rel: 'author',
>               }
>             ],
>             embedded: {
>               'embedded_book' => {attributes: {'content' => { value: 'A...' } }, transitions: [{rel: 'self', href: '/foo'}]}
>             }
>           }
>         end
>
>         it_behaves_like 'a hal documents attributes', representor_hash
>         it_behaves_like 'a hal documents links', representor_hash
>         it_behaves_like 'a hal documents ebedded hal documents', representor_hash
>       end
>
> results in
>
> /Users/svalentine/Projects/temp/crichton-representors/spec/lib/representors/serialization/hal_serializer_spec.rb:134:in `block (3 levels) in <module:Representors>': undefined local variable or method `representor_hash' for #<Class:0x007fa2a6ce1c38> (NameError)
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:246:in `module_eval'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:246:in `subclass'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:232:in `describe'
>     from /Users/svalentine/Projects/temp/crichton-representors/spec/lib/representors/serialization/hal_serializer_spec.rb:116:in `block (2 levels) in <module:Representors>'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:246:in `module_eval'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:246:in `subclass'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:232:in `describe'
>     from /Users/svalentine/Projects/temp/crichton-representors/spec/lib/representors/serialization/hal_serializer_spec.rb:74:in `block in <module:Representors>'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:246:in `module_eval'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:246:in `subclass'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:232:in `describe'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/dsl.rb:18:in `describe'
>     from /Users/svalentine/Projects/temp/crichton-representors/spec/lib/representors/serialization/hal_serializer_spec.rb:6:in `<module:Representors>'
>     from /Users/svalentine/Projects/temp/crichton-representors/spec/lib/representors/serialization/hal_serializer_spec.rb:5:in `<top (required)>'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `load'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `each'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `load_spec_files'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:22:in `run'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:80:in `run'
>     from /Users/svalentine/.rvm/gems/ruby-1.9.3-p545/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:17:in `block in autorun'
> Coverage report generated for RSpec to /Users/svalentine/Projects/temp/crichton-representors/coverage. 469 / 810 LOC (57.9%) covered.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/mdsol/crichton-representors/pull/18/files#r13473722>.
>