On Monday, March 31, 2014 12:41:06 AM UTC-7, Dmitriy Konovalov wrote:
>
> Hi everybody,
>
> I want to create an rspec formatter that will out the xml for the mind map 
> building. I'm QA and want to create checklists based on test scenarios 
>  created in spec files. And it works now, but I'd like to use a lot of Mind 
> map features like tags, icons, links, attached descriptions for each node. 
> And I use metadata for this point. 
> The trouble is: when I assign some metadata tags to example group all 
> nested ones are inherit these tags, so all nested nodes in mind map file 
> will have all these info until be override.
>
> So the question is:
>
> Is there some possibility to temporarily turn off the tags-inheriting 
> feature? otherwise I need to override all tags each time for each node to 
> 'nil' (now it works for me fine, but makes the code awful to read):
>
>
> describe 'Sidebar', link: nil, user_story: nil do
>   describe 'Album info widget', link: 'https://www.google.com', 
> user_story: true do
>     it 'something', link: nil, user_story: nil
>   end
>   describe 'Photo Albums widget', link: 'https://www.google.com', 
> user_story: true do
>     it 'something', link: nil, user_story: nil
>   end
> end
>

There's not a built-in way to do this. The metadata inheritance is 
intentional and is very useful.

You can do something like this:

module SetMetadataKeysToNil
  def describe(description, user_metadata={})
    user_metadata.merge!(metadata_hash_with_nil_values)
    super
  end

  def it(description, user_metadata={})
    user_metadata.merge!(metadata_hash_with_nil_values)
    super
  end

private

  def metadata_hash_with_nil_values
    user_keys = metadata.keys - RSpec::Core::Metadata::RESERVED_KEYS
    user_keys -= [:parent_example_group, :example_group]
    user_keys.each_with_object({}) do |key, hash|
      hash[key] = nil
    end
  end
end

RSpec.configure do |rspec|
  rspec.extend SetMetadataKeysToNil
end

HTH,
Myron

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/c9abe6e6-ed70-48a7-875f-5a5f20601030%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to