{"action":"created","issue":{"url":"https://api.github.com/repos/sethvargo/chefspec/issues/559","labels_url":"https://api.github.com/repos/sethvargo/chefspec/issues/559/labels{/name}","comments_url":"https://api.github.com/repos/sethvargo/chefspec/issues/559/comments","events_url":"https://api.github.com/repos/sethvargo/chefspec/issues/559/events","html_url":"https://github.com/sethvargo/chefspec/issues/559","id":55697079,"number":559,"title":"[question] How much control over the content of a render_file does one have inside a test?","user":{"login":"miketheman","id":529516,"avatar_url":"https://avatars.githubusercontent.com/u/529516?v=3","gravatar_id":"","url":"https://api.github.com/users/miketheman","html_url":"https://github.com/miketheman","followers_url":"https://api.github.com/users/miketheman/followers","following_url":"https://api.github.com/users/miketheman/following{/other_user}","gists_url":"https://api.github.com/users/miketheman/gists{/gist_id}","starred_url":"https://api.github.com/users/miketheman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miketheman/subscriptions","organizations_url":"https://api.github.com/users/miketheman/orgs","repos_url":"https://api.github.com/users/miketheman/repos","events_url":"https://api.github.com/users/miketheman/events{/privacy}","received_events_url":"https://api.github.com/users/miketheman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-01-28T00:32:21Z","updated_at":"2015-01-28T20:14:39Z","closed_at":null,"body":"This is a question, maybe I'm Doing It Wrong, but I've been poking at it for some time now, and can't seem to figure out if it's me or not.\r\n\r\nIn a recipe, I have a template resource that renders out a yaml file.\r\n\r\nIn a kitchen test, I am able to converge, inspect, load, convert the file to my liking - say load from yaml, convert to json and back, test validity of those operations.\r\n\r\nYes, I'm living on the edge.\r\n\r\nI'd like to be able to use RSpec matchers to assert the validity of the rendered YAML file by converting it to JSON, and comparing the loaded object with an expected, dummy object - hopefully to catch any indentation errors I have.\r\n\r\nThe [json_spec](https://github.com/collectiveidea/json_spec) is the RSpec matcher I've been using successfully in Serverspec tests, so I wanted to see if I might be able to use i here as well in some fashion.\r\n\r\nConsider, pseudo-code:\r\n```ruby\r\nexpected = {\r\n  \"foo\": \"bar\",\r\n  \"baz\": [\r\n    \"qux\",\r\n    \"quxx\"\r\n  ]\r\n}\r\n\r\nit 'renders a yaml file' do\r\n  # yaml file:\r\n  #   foo: \"bar\"\r\n  #   baz: \r\n  #     - \"qux\"\r\n  #     - \"quxx\"\r\n\r\n  expect(chef_run).to render_file('/rendered.yaml').with_content(\r\n   # manipulate the rendered content here to.json or such\r\n    be_json_eql(expected.to_json)\r\n  )\r\nend\r\n```\r\n\r\nOr something along these lines.\r\n\r\nThe problem manifests that within `with_content()`, I will only have the raw YAML, and cannot manipulate that into something like `@content.to_json` for the purpose of comparison.\r\n\r\nDoes this make any sense?"},"comment":{"url":"https://api.github.com/repos/sethvargo/chefspec/issues/comments/71907190","html_url":"https://github.com/sethvargo/chefspec/issues/559#issuecomment-71907190","issue_url":"https://api.github.com/repos/sethvargo/chefspec/issues/559","id":71907190,"user":{"login":"miketheman","id":529516,"avatar_url":"https://avatars.githubusercontent.com/u/529516?v=3","gravatar_id":"","url":"https://api.github.com/users/miketheman","html_url":"https://github.com/miketheman","followers_url":"https://api.github.com/users/miketheman/followers","following_url":"https://api.github.com/users/miketheman/following{/other_user}","gists_url":"https://api.github.com/users/miketheman/gists{/gist_id}","starred_url":"https://api.github.com/users/miketheman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miketheman/subscriptions","organizations_url":"https://api.github.com/users/miketheman/orgs","repos_url":"https://api.github.com/users/miketheman/repos","events_url":"https://api.github.com/users/miketheman/events{/privacy}","received_events_url":"https://api.github.com/users/miketheman/received_events","type":"User","site_admin":false},"created_at":"2015-01-28T20:14:39Z","updated_at":"2015-01-28T20:14:39Z","body":"@sethvargo Then that's awesome, I think. :grin: "}}