{"action":"reopened","issue":{"url":"https://api.github.com/repos/ageweke/fortitude/issues/28","labels_url":"https://api.github.com/repos/ageweke/fortitude/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/ageweke/fortitude/issues/28/comments","events_url":"https://api.github.com/repos/ageweke/fortitude/issues/28/events","html_url":"https://github.com/ageweke/fortitude/issues/28","id":95098933,"number":28,"title":"Unit testing of widgets?","user":{"login":"jdickey","id":157938,"avatar_url":"https://avatars.githubusercontent.com/u/157938?v=3","gravatar_id":"","url":"https://api.github.com/users/jdickey","html_url":"https://github.com/jdickey","followers_url":"https://api.github.com/users/jdickey/followers","following_url":"https://api.github.com/users/jdickey/following{/other_user}","gists_url":"https://api.github.com/users/jdickey/gists{/gist_id}","starred_url":"https://api.github.com/users/jdickey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdickey/subscriptions","organizations_url":"https://api.github.com/users/jdickey/orgs","repos_url":"https://api.github.com/users/jdickey/repos","events_url":"https://api.github.com/users/jdickey/events{/privacy}","received_events_url":"https://api.github.com/users/jdickey/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-07-15T03:49:13Z","updated_at":"2015-10-02T21:52:43Z","closed_at":null,"body":"With Erector, as demonstrated in their [specs](https://github.com/erector/erector/blob/master/spec/erector/widget_spec.rb), testing widgets using `#to_html`, `#to_a`, etc, was drop-dead simple. Writing simple tests like\r\n\r\n```ruby\r\n    it 'renders the expected content' do\r\n      expect(FooWidget.new.to_html).must_equal expected_content\r\n    end\r\n```\r\n\r\nwould Just Work. Fortitude adds an internal, apparently-undocumented rendering context that leads the above MiniTest::Spec code to fail with the obviously-intended-to-be-helpful message\r\n\r\n    Fortitude::Errors::NoBlockToYieldTo: You're trying to call 'yield' (or 'yield_from_widget', or the Erector-compatibility method 'call_block')\r\n    from the widget #<Views::FooWidget:xxxxxxxx>; however, there is nothing to yield to. Fortitude\r\n    looks for something to yield to in this order:\r\n      1. A block passed to a yield at render time directly (usually via the 'widget' call);\r\n      2. A block passed to the constructor of the widget;\r\n      3. The layout the widget is being rendered in.\r\n    None of these exist here, and so calling 'yield', 'yield_from_widget', or 'call_block' is an\r\n    undefined operation.\r\n\r\nSo what should I be doing instead to unit-test a widget? Isn't the whole *point* of \"Views Are Code\" supposed to be that we can treat widgets and widget-derived code like pages the same as any other classes in our system — with testing, composition, SOLID, and so on?  Of *course* feature specs work, but that's only *half the job*.\r\n\r\nWhat has everybody else been doing?"}}