{"action":"created","issue":{"url":"https://api.github.com/repos/searls/jasmine-given/issues/48","labels_url":"https://api.github.com/repos/searls/jasmine-given/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/searls/jasmine-given/issues/48/comments","events_url":"https://api.github.com/repos/searls/jasmine-given/issues/48/events","html_url":"https://github.com/searls/jasmine-given/issues/48","id":109423209,"number":48,"title":"Given, When, Then descriptions","user":{"login":"nitro52","id":643962,"avatar_url":"https://avatars.githubusercontent.com/u/643962?v=3","gravatar_id":"","url":"https://api.github.com/users/nitro52","html_url":"https://github.com/nitro52","followers_url":"https://api.github.com/users/nitro52/followers","following_url":"https://api.github.com/users/nitro52/following{/other_user}","gists_url":"https://api.github.com/users/nitro52/gists{/gist_id}","starred_url":"https://api.github.com/users/nitro52/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nitro52/subscriptions","organizations_url":"https://api.github.com/users/nitro52/orgs","repos_url":"https://api.github.com/users/nitro52/repos","events_url":"https://api.github.com/users/nitro52/events{/privacy}","received_events_url":"https://api.github.com/users/nitro52/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-02T03:25:18Z","updated_at":"2015-10-02T16:25:46Z","closed_at":"2015-10-02T15:48:43Z","body":"Hi, \r\nI really love the Given, When, Then approach to splitting up your tests, but a huge part of why this is so useful in other frameworks is that it gives you the ability to describe the actions in a human readable way. It would be great if we could add an optional description string that then gets reported in the test results. For example\r\n\r\ndescribe(\"assigning stuff to this\", function() {\r\n  Given(\"I have the number 24\", function() { this.number = 24; });\r\n  Given(\"I increment by one\", function() { this.number++; });\r\n  When(\"I multiply by two\", function() { this.number *= 2; });\r\n  Then(\"I should get 50\", function() { return this.number === 50; });\r\n});\r\n\r\nThen it would be good to see in the test results something like this\r\n\r\nassigning stuff to this - Passed\r\n----- Given I have the number 24 - Passed\r\n----- Given I increment by one  - Passed\r\n----- When I multiply by two  - Passed\r\n----- Then I should get 50  - Passed\r\n\r\nOr ideally replace subsequent actions with And \r\n\r\nassigning stuff to this - Passed\r\n----- Given I have the number 24 - Passed\r\n----- And I increment by one  - Passed\r\n----- When I multiply by two  - Passed\r\n----- Then I should get 50  - Passed\r\n"},"comment":{"url":"https://api.github.com/repos/searls/jasmine-given/issues/comments/145078717","html_url":"https://github.com/searls/jasmine-given/issues/48#issuecomment-145078717","issue_url":"https://api.github.com/repos/searls/jasmine-given/issues/48","id":145078717,"user":{"login":"ronen","id":125620,"avatar_url":"https://avatars.githubusercontent.com/u/125620?v=3","gravatar_id":"","url":"https://api.github.com/users/ronen","html_url":"https://github.com/ronen","followers_url":"https://api.github.com/users/ronen/followers","following_url":"https://api.github.com/users/ronen/following{/other_user}","gists_url":"https://api.github.com/users/ronen/gists{/gist_id}","starred_url":"https://api.github.com/users/ronen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ronen/subscriptions","organizations_url":"https://api.github.com/users/ronen/orgs","repos_url":"https://api.github.com/users/ronen/repos","events_url":"https://api.github.com/users/ronen/events{/privacy}","received_events_url":"https://api.github.com/users/ronen/received_events","type":"User","site_admin":false},"created_at":"2015-10-02T16:25:45Z","updated_at":"2015-10-02T16:25:45Z","body":"@searls I'm kinda inbetween, and I think @nitro52 might actually be on to something...\r\n\r\nI agree with `Then { expect(2+2).toEqual 4 }`  and that's what I do pretty much 100% of the time.  But that said, the current code *does* allow you provide labels to Then clauses if you really want to (https://github.com/searls/jasmine-given#it-style-test-labels).  I never bother with it, since I'd just as soon look at the ugly code as have to make up words.\r\n\r\nLooking though at Givens and Whens, I have found that I do still have to type a bunch of words for contexts.  Standard pattern is\r\n\r\n```coffeescript\r\ncontext \"given foo is true\", ->\r\n  Given -> @foo = true \r\n  \r\n  context \"when I click on a bug\", ->\r\n      When -> $.find(\".bug\").click()\r\n```\r\n\r\nSince words are still needed to describe what's happening with the Given's and When's, maybe something like @nitro52's proposal could make that cleaner?  This does actually seem cleaner:\r\n\r\n```coffeescript\r\ncontext ->\r\n    Given \"foo is true\" -> @foo = true\r\n\r\n    context ->\r\n      When \"I click on a bug\", -> $.find(\".bug\").click()\r\n\r\n      Then -> expect(@happiness()).to beTrue\r\n```\r\n\r\nAnd once we've done that...  There are some times the Given or When code is clear and terse, and then you should be able to leave off the label and it'd be autogenerated same as for Then's.  E.g.\r\n\r\n```coffeescript\r\ncontext ->\r\n    Given -> @foo = true\r\n\r\n    context ->\r\n      When \"I click on a bug\", -> $.find(\".bug\").click()\r\n\r\n      Then -> expect(@happiness()).to beTrue\r\n```\r\n\r\nwould autogenerate\r\n```\r\n--- Given @foo = true\r\n  --- When I click on a bug\r\n    --- Then expect(@happiness()).to beTrue\r\n```\r\n\r\nAnd voila!  A step closer to the utopian ideal of English-free tests!\r\n\r\nBTW another benefit to allowing labels everywhere is that it will make the library and methodology more accessible to newbies.  I suspect many people who first encounter Given/When/Then, either here or in @jimweirich's rspec gem can be put off by the lack of text labels.  In fact one of the first things I did was submit a PR to allow them, which @jimwerich rejected.   I think that's actually being overly principled.... it does little harm to allow people to use them (trivial code addition), and provides a gentle introduction to Given/When/Then.  And many people (like myself) would quickly enough discover that their English labels aren't necessary, and laziness (if nothing else) would take over and they'd stop bothering, and their tests would become better.  That's what happened to me, anyway.\r\n\r\n\r\n\r\n\r\n\r\n    "}}