I am having an issue where a feature works fine but the corresponding test fails, and I can''t understand why. I created a mock application to demonstrate the problem. https://github.com/assafshomer/clear_button All it does is show an input form with a clear button. The clearing happens by redirecting back to the same form. It does clear it when you run the app, but the test for it fails. If you feel inclined to help, please clone the repo and run the test mentioned in the readme (or the full suite, which is very short). The test fails (at least for me) but if you run the app (http://localhost:3000/pages/input) the ''Clear'' button does seem to be doing the right thing. Help? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On Sun, May 12, 2013 at 3:11 PM, Assaf Shomer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I am having an issue where a feature works fine but the corresponding > test fails, and I can''t understand why. > I created a mock application to demonstrate the problem. > > https://github.com/assafshomer/clear_button > > All it does is show an input form with a clear button. The clearing > happens by redirecting back to the same form. It does clear it when you > run the app, but the test for it fails. > > If you feel inclined to help, please clone the repo and run the test > mentioned in the readme (or the full suite, which is very short). The > test fails (at least for me) but if you run the app > (http://localhost:3000/pages/input) the ''Clear'' button does seem > to be doing the right thing. > > Help?Just a quick glance, but you probably should move lines 10-16 (the before and it blocks) inside their own describe block, as the before block at line 10 is also running before every it in the other describe blocks. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
tamouse mailing lists wrote in post #1108701:> On Sun, May 12, 2013 at 3:11 PM, Assaf Shomer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: >> If you feel inclined to help, please clone the repo and run the test >> mentioned in the readme (or the full suite, which is very short). The >> test fails (at least for me) but if you run the app >> (http://localhost:3000/pages/input) the ''Clear'' button does seem >> to be doing the right thing. >> >> Help? > > Just a quick glance, but you probably should move lines 10-16 (the > before and it blocks) inside their own describe block, as the before > block at line 10 is also running before every it in the other describe > blocks.Thanks. Moved test inside a describe block. Problem still remains though. Any other ideas? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On Sun, May 12, 2013 at 4:46 PM, Assaf Shomer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> tamouse mailing lists wrote in post #1108701: >> On Sun, May 12, 2013 at 3:11 PM, Assaf Shomer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> >> wrote: >>> If you feel inclined to help, please clone the repo and run the test >>> mentioned in the readme (or the full suite, which is very short). The >>> test fails (at least for me) but if you run the app >>> (http://localhost:3000/pages/input) the ''Clear'' button does seem >>> to be doing the right thing. >>> >>> Help? >> >> Just a quick glance, but you probably should move lines 10-16 (the >> before and it blocks) inside their own describe block, as the before >> block at line 10 is also running before every it in the other describe >> blocks. > > Thanks. Moved test inside a describe block. > Problem still remains though.Both the before at line 10 through the end of the it test at line 16 need to be in their own describe block, not just the test. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
tamouse mailing lists wrote in post #1108719:> On Sun, May 12, 2013 at 4:46 PM, Assaf Shomer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: >>> >>> Just a quick glance, but you probably should move lines 10-16 (the >>> before and it blocks) inside their own describe block, as the before >>> block at line 10 is also running before every it in the other describe >>> blocks. >> >> Thanks. Moved test inside a describe block. >> Problem still remains though. > > Both the before at line 10 through the end of the it test at line 16 > need to be in their own describe block, not just the test.I think this is what I did in the last push, isn''t it? Before: ------------------------------------------------------- require ''spec_helper'' describe "Pages" do subject { page } before { visit ''/pages/input''} describe "search" do it { should have_selector(''input#show_button'') } it { should have_selector(''input#clear_button'') } end before do fill_in ''input_field'', with: ''blah'' click_button ''Show'' end it "should display the string ''blah''" do page.should have_selector(''h3'', text: ''blah'') end describe ''clear button'' do before { click_button ''Clear'' } it "should not show the string ''blah''" do page.should_not have_selector(''h3'', text: ''blah'') end end end ----------------------------------------------------- now: ----------------------------------------------------- require ''spec_helper'' describe "Pages" do subject { page } before { visit ''/pages/input''} describe "input form" do it { should have_selector(''input#show_button'') } it { should have_selector(''input#clear_button'') } end describe "show button" do before do fill_in ''input_field'', with: ''blah'' click_button ''Show'' end it "should display the string ''blah''" do page.should have_selector(''h3'', text: ''blah'') end end describe ''clear button'' do before do fill_in ''input_field'', with: ''blah'' click_button ''Show'' click_button ''Clear'' end it "should not show the string ''blah''" do page.should_not have_selector(''h3'', text: ''blah'') end end end ----------------------------------------------------- Bottom line, test still fails. any other suggestions? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
let me push my change up and do a PR and see if you can see a diff: it works for me. On Mon, May 13, 2013 at 12:28 AM, Assaf Shomer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> tamouse mailing lists wrote in post #1108719: >> On Sun, May 12, 2013 at 4:46 PM, Assaf Shomer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> >> wrote: >>>> >>>> Just a quick glance, but you probably should move lines 10-16 (the >>>> before and it blocks) inside their own describe block, as the before >>>> block at line 10 is also running before every it in the other describe >>>> blocks. >>> >>> Thanks. Moved test inside a describe block. >>> Problem still remains though. >> >> Both the before at line 10 through the end of the it test at line 16 >> need to be in their own describe block, not just the test. > > I think this is what I did in the last push, isn''t it? > > Before: > > ------------------------------------------------------- > require ''spec_helper'' > > describe "Pages" do > subject { page } > before { visit ''/pages/input''} > describe "search" do > it { should have_selector(''input#show_button'') } > it { should have_selector(''input#clear_button'') } > end > before do > fill_in ''input_field'', with: ''blah'' > click_button ''Show'' > end > it "should display the string ''blah''" do > page.should have_selector(''h3'', text: ''blah'') > end > describe ''clear button'' do > before { click_button ''Clear'' } > it "should not show the string ''blah''" do > page.should_not have_selector(''h3'', text: ''blah'') > end > end > end > ----------------------------------------------------- > > now: > > ----------------------------------------------------- > > require ''spec_helper'' > > describe "Pages" do > subject { page } > before { visit ''/pages/input''} > describe "input form" do > it { should have_selector(''input#show_button'') } > it { should have_selector(''input#clear_button'') } > end > describe "show button" do > before do > fill_in ''input_field'', with: ''blah'' > click_button ''Show'' > end > it "should display the string ''blah''" do > page.should have_selector(''h3'', text: ''blah'') > end > end > describe ''clear button'' do > before do > fill_in ''input_field'', with: ''blah'' > click_button ''Show'' > click_button ''Clear'' > end > it "should not show the string ''blah''" do > page.should_not have_selector(''h3'', text: ''blah'') > end > end > end > > ----------------------------------------------------- > > Bottom line, test still fails. > > any other suggestions? > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
https://github.com/assafshomer/clear_button/pull/1 On Mon, May 13, 2013 at 11:20 PM, tamouse mailing lists <tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> let me push my change up and do a PR and see if you can see a diff: it > works for me. > > On Mon, May 13, 2013 at 12:28 AM, Assaf Shomer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> tamouse mailing lists wrote in post #1108719: >>> On Sun, May 12, 2013 at 4:46 PM, Assaf Shomer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> >>> wrote: >>>>> >>>>> Just a quick glance, but you probably should move lines 10-16 (the >>>>> before and it blocks) inside their own describe block, as the before >>>>> block at line 10 is also running before every it in the other describe >>>>> blocks. >>>> >>>> Thanks. Moved test inside a describe block. >>>> Problem still remains though. >>> >>> Both the before at line 10 through the end of the it test at line 16 >>> need to be in their own describe block, not just the test. >> >> I think this is what I did in the last push, isn''t it? >> >> Before: >> >> ------------------------------------------------------- >> require ''spec_helper'' >> >> describe "Pages" do >> subject { page } >> before { visit ''/pages/input''} >> describe "search" do >> it { should have_selector(''input#show_button'') } >> it { should have_selector(''input#clear_button'') } >> end >> before do >> fill_in ''input_field'', with: ''blah'' >> click_button ''Show'' >> end >> it "should display the string ''blah''" do >> page.should have_selector(''h3'', text: ''blah'') >> end >> describe ''clear button'' do >> before { click_button ''Clear'' } >> it "should not show the string ''blah''" do >> page.should_not have_selector(''h3'', text: ''blah'') >> end >> end >> end >> ----------------------------------------------------- >> >> now: >> >> ----------------------------------------------------- >> >> require ''spec_helper'' >> >> describe "Pages" do >> subject { page } >> before { visit ''/pages/input''} >> describe "input form" do >> it { should have_selector(''input#show_button'') } >> it { should have_selector(''input#clear_button'') } >> end >> describe "show button" do >> before do >> fill_in ''input_field'', with: ''blah'' >> click_button ''Show'' >> end >> it "should display the string ''blah''" do >> page.should have_selector(''h3'', text: ''blah'') >> end >> end >> describe ''clear button'' do >> before do >> fill_in ''input_field'', with: ''blah'' >> click_button ''Show'' >> click_button ''Clear'' >> end >> it "should not show the string ''blah''" do >> page.should_not have_selector(''h3'', text: ''blah'') >> end >> end >> end >> >> ----------------------------------------------------- >> >> Bottom line, test still fails. >> >> any other suggestions? >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> -- >> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. >> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >>-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On Mon, May 13, 2013 at 11:23 PM, tamouse mailing lists <tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> https://github.com/assafshomer/clear_button/pull/1 > > On Mon, May 13, 2013 at 11:20 PM, tamouse mailing lists > <tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> let me push my change up and do a PR and see if you can see a diff: it >> works for me. >> >> On Mon, May 13, 2013 at 12:28 AM, Assaf Shomer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> tamouse mailing lists wrote in post #1108719: >>>> On Sun, May 12, 2013 at 4:46 PM, Assaf Shomer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> >>>> wrote: >>>>>> >>>>>> Just a quick glance, but you probably should move lines 10-16 (the >>>>>> before and it blocks) inside their own describe block, as the before >>>>>> block at line 10 is also running before every it in the other describe >>>>>> blocks. >>>>> >>>>> Thanks. Moved test inside a describe block. >>>>> Problem still remains though. >>>> >>>> Both the before at line 10 through the end of the it test at line 16 >>>> need to be in their own describe block, not just the test. >>> >>> I think this is what I did in the last push, isn''t it? >>> >>> Before: >>> >>> ------------------------------------------------------- >>> require ''spec_helper'' >>> >>> describe "Pages" do >>> subject { page } >>> before { visit ''/pages/input''} >>> describe "search" do >>> it { should have_selector(''input#show_button'') } >>> it { should have_selector(''input#clear_button'') } >>> end >>> before do >>> fill_in ''input_field'', with: ''blah'' >>> click_button ''Show'' >>> end >>> it "should display the string ''blah''" do >>> page.should have_selector(''h3'', text: ''blah'') >>> end >>> describe ''clear button'' do >>> before { click_button ''Clear'' } >>> it "should not show the string ''blah''" do >>> page.should_not have_selector(''h3'', text: ''blah'') >>> end >>> end >>> end >>> ----------------------------------------------------- >>> >>> now: >>> >>> ----------------------------------------------------- >>> >>> require ''spec_helper'' >>> >>> describe "Pages" do >>> subject { page } >>> before { visit ''/pages/input''} >>> describe "input form" do >>> it { should have_selector(''input#show_button'') } >>> it { should have_selector(''input#clear_button'') } >>> end >>> describe "show button" do >>> before do >>> fill_in ''input_field'', with: ''blah'' >>> click_button ''Show'' >>> end >>> it "should display the string ''blah''" do >>> page.should have_selector(''h3'', text: ''blah'') >>> end >>> end >>> describe ''clear button'' do >>> before do >>> fill_in ''input_field'', with: ''blah'' >>> click_button ''Show'' >>> click_button ''Clear'' >>> end >>> it "should not show the string ''blah''" do >>> page.should_not have_selector(''h3'', text: ''blah'') >>> end >>> end >>> end >>> >>> ----------------------------------------------------- >>> >>> Bottom line, test still fails. >>> >>> any other suggestions?Okay, as near as I can figure out, capybara is choking on the fact that you have commit=Show in your query string, you''re using method=GET in your form, and commit=Clear is coming in the request body. Somehow, when rails is called by the browser, this is handled in the way you want (which is the request body''s commit=Clear overrides the one in the query string), but in capybara, it isn''t. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
tamouse mailing lists wrote in post #1108881:> https://github.com/assafshomer/clear_button/pull/1 > > On Mon, May 13, 2013 at 11:20 PM, tamouse mailing listsTamouse, thank you. However, your pull nullifies the test. Your test clicks the clear button without first writing anything in the input field, so obviously clearing the empty input field leaves you with an empty input field. In order that the test actually tests something, it must first write something into the input field and then try to clear it. any other ideas? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/42695ad05dd16b831fc84d9e40debf18%40ruby-forum.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
maybe read my follow up On Fri, May 17, 2013 at 1:44 AM, Assaf Shomer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> tamouse mailing lists wrote in post #1108881: >> https://github.com/assafshomer/clear_button/pull/1 >> >> On Mon, May 13, 2013 at 11:20 PM, tamouse mailing lists > > Tamouse, thank you. > However, your pull nullifies the test. > Your test clicks the clear button without first writing anything in the > input field, so obviously clearing the empty input field leaves you with > an empty input field. > In order that the test actually tests something, it must first write > something into the input field and then try to clear it. > > any other ideas? > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/42695ad05dd16b831fc84d9e40debf18%40ruby-forum.com?hl=en-US. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
and now i''m not going to bother spending any more time on it On Fri, May 17, 2013 at 11:58 PM, tamouse mailing lists <tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> maybe read my follow up > > > On Fri, May 17, 2013 at 1:44 AM, Assaf Shomer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> tamouse mailing lists wrote in post #1108881: >>> https://github.com/assafshomer/clear_button/pull/1 >>> >>> On Mon, May 13, 2013 at 11:20 PM, tamouse mailing lists >> >> Tamouse, thank you. >> However, your pull nullifies the test. >> Your test clicks the clear button without first writing anything in the >> input field, so obviously clearing the empty input field leaves you with >> an empty input field. >> In order that the test actually tests something, it must first write >> something into the input field and then try to clear it. >> >> any other ideas? >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> -- >> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. >> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/42695ad05dd16b831fc84d9e40debf18%40ruby-forum.com?hl=en-US. >> For more options, visit https://groups.google.com/groups/opt_out. >> >>-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.