{"action":"created","issue":{"url":"https://api.github.com/repos/oesmith/puffing-billy/issues/241","repository_url":"https://api.github.com/repos/oesmith/puffing-billy","labels_url":"https://api.github.com/repos/oesmith/puffing-billy/issues/241/labels{/name}","comments_url":"https://api.github.com/repos/oesmith/puffing-billy/issues/241/comments","events_url":"https://api.github.com/repos/oesmith/puffing-billy/issues/241/events","html_url":"https://github.com/oesmith/puffing-billy/issues/241","id":318855064,"number":241,"title":"v1.1.0 Dynamic responses via procs - breaking Changes","user":{"login":"AlanFoster","id":1271782,"avatar_url":"https://avatars2.githubusercontent.com/u/1271782?v=4","gravatar_id":"","url":"https://api.github.com/users/AlanFoster","html_url":"https://github.com/AlanFoster","followers_url":"https://api.github.com/users/AlanFoster/followers","following_url":"https://api.github.com/users/AlanFoster/following{/other_user}","gists_url":"https://api.github.com/users/AlanFoster/gists{/gist_id}","starred_url":"https://api.github.com/users/AlanFoster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlanFoster/subscriptions","organizations_url":"https://api.github.com/users/AlanFoster/orgs","repos_url":"https://api.github.com/users/AlanFoster/repos","events_url":"https://api.github.com/users/AlanFoster/events{/privacy}","received_events_url":"https://api.github.com/users/AlanFoster/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-04-30T11:08:07Z","updated_at":"2018-05-12T20:54:52Z","closed_at":"2018-05-12T20:54:52Z","author_association":"CONTRIBUTOR","body":"Hey; I just noticed that v1.1.0 has breaking changes in it. I believe this has been caused by https://github.com/oesmith/puffing-billy/pull/232\r\n\r\nOn version 1.0.0 calling methods or variables defined within the scope of your test from a stub proc was possible, however this is no longer possible due to the following implementation change:\r\n\r\n```diff\r\n-        res = @response.call(params, headers, body)\r\n+        res = instance_exec(params, headers, body, url, method, &@response)\r\n```\r\n\r\nAs an example, this test will pass on v1.0.0, but not on v1.1.0:\r\n\r\n```ruby\r\nrequire 'spec_helper'\r\n\r\ndescribe 'Tumblr API example', type: :feature, js: true do\r\n  let(:posts) do\r\n    [\r\n      {\r\n        'regular-title' => 'News Item 1',\r\n        'url-with-slug' => 'http://example.com/news/1',\r\n        'regular-body' => 'News item 1 content here'\r\n      },\r\n      {\r\n        'regular-title' => 'News Item 2',\r\n        'url-with-slug' => 'http://example.com/news/2',\r\n        'regular-body' => 'News item 2 content here'\r\n      }\r\n    ]\r\n  end\r\n\r\n  before do\r\n    proxy.stub('http://blog.howmanyleft.co.uk/api/read/json').and_return(Proc.new do\r\n      {\r\n        jsonp: {\r\n          # This breaks on v1.1.0, due to the `instance_exec` implementation change\r\n          posts: posts\r\n        }\r\n      }\r\n    end)\r\n  end\r\n\r\n  it 'should show news stories' do\r\n    visit '/tumblr_api.html'\r\n    expect(page).to have_link('News Item 1', href: 'http://example.com/news/1')\r\n    expect(page).to have_content('News item 1 content here')\r\n    expect(page).to have_link('News Item 2', href: 'http://example.com/news/2')\r\n    expect(page).to have_content('News item 2 content here')\r\n  end\r\nend\r\n```\r\n\r\nThe specific failure on v1.1.0 is:\r\n\r\n```\r\nNameError: undefined local variable or method `posts' for #<Billy::ProxyRequestStub:0x007fac289def00>\r\nfrom /Users/a/Documents/Shopkeep/puffing-billy/spec/features/examples/tumblr_api_spec.rb:23:in `block (3 levels) in <top (required)>'\r\n```\r\n\r\nNote: I understand that the proc is superfluous in this scenario, but it's just a quickly thrown together example 🎉 "},"comment":{"url":"https://api.github.com/repos/oesmith/puffing-billy/issues/comments/388582262","html_url":"https://github.com/oesmith/puffing-billy/issues/241#issuecomment-388582262","issue_url":"https://api.github.com/repos/oesmith/puffing-billy/issues/241","id":388582262,"user":{"login":"ronwsmith","id":4006875,"avatar_url":"https://avatars1.githubusercontent.com/u/4006875?v=4","gravatar_id":"","url":"https://api.github.com/users/ronwsmith","html_url":"https://github.com/ronwsmith","followers_url":"https://api.github.com/users/ronwsmith/followers","following_url":"https://api.github.com/users/ronwsmith/following{/other_user}","gists_url":"https://api.github.com/users/ronwsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/ronwsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ronwsmith/subscriptions","organizations_url":"https://api.github.com/users/ronwsmith/orgs","repos_url":"https://api.github.com/users/ronwsmith/repos","events_url":"https://api.github.com/users/ronwsmith/events{/privacy}","received_events_url":"https://api.github.com/users/ronwsmith/received_events","type":"User","site_admin":false},"created_at":"2018-05-12T20:54:52Z","updated_at":"2018-05-12T20:54:52Z","author_association":"COLLABORATOR","body":"Fixed in v1.1.1"}}
{"actor":{"display_login":"ronwsmith"}}