<br>Oh that was my post a few days ago.<br>
I was trying to emulate the following:<br>
<br>Jon is logging onto the forum so he can create a new topic.<br>
When Jon logs on he is redirected the home page by default.<br>
Jon then clicks on the general forum<br>so he go create a topic.<br>
<br>
This following seemed out of place.<br>I thought it was necessary to emulate a user clicking a link on the home page to the forums/1 <br>I thought thats the path the user takes.<br>
<br>
And &quot;user is looking at&quot;, &quot;/forums/1&quot; do |path|<br>
&nbsp; get path<br>
&nbsp; response.should be_success<br>
end<br><br>It just seemed that I was suppose to include the user going to that page before creating the topic.<br><br><br><div><span class="gmail_quote">On 9/25/07, <b class="gmail_sendername">Pat Maddox</b> &lt;<a href="mailto:pergesu@gmail.com">
pergesu@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On 9/25/07, David Chelimsky &lt;<a href="mailto:dchelimsky@gmail.com">
dchelimsky@gmail.com</a>&gt; wrote:<br>&gt; On 9/25/07, Jonathan Linowes &lt;<a href="mailto:jonathan@parkerhill.com">jonathan@parkerhill.com</a>&gt; wrote:<br>&gt; &gt; hi,<br>&gt; &gt;<br>&gt; &gt; I just started fooling around with story runner, thought I&#39;d start
<br>&gt; &gt; with a dead simple scenario:<br>&gt; &gt; The first thing I do when describing a site to someone is go to the<br>&gt; &gt; home page, and begin exploring public pages from there.<br>&gt; &gt; So, that seems like a good first story to spec out.
<br>&gt; &gt;<br>&gt; &gt; And I&#39;d really like to extract the actual link from the rendered page<br>&gt; &gt; (rather than just &quot;assuming&quot; in the spec), but I&#39;m not sure how to do<br>&gt; &gt; that<br>&gt; &gt; Something like:
<br>&gt; &gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# alink = find tag &#39;div#home-banner-links a &#39;&nbsp;&nbsp;where<br>&gt; &gt; content==&quot;About&quot;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# url = extract the href attribute from alink<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;get url
<br>&gt; &gt;<br>&gt; &gt; Here&#39;s the story so far: <a href="http://pastie.caboo.se/100810">http://pastie.caboo.se/100810</a><br>&gt;<br>&gt; Some comments:<br>&gt;<br>&gt; The second scenario seems more like the right level of abstraction
<br>&gt; than the first. Using &quot;should render_template&quot; in a Story seems too<br>&gt; low level to me. What&#39;s interesting is what is being displayed, not<br>&gt; what template is being used to display it.<br>
<br>I see what you&#39;re getting at.&nbsp;&nbsp;I&#39;ve thought about it a bit myself, and<br>have decided that expecting a certain template is a pragmatic way of<br>knowing that the user is on the right page.<br><br><br>&gt; The second scenario does a nicer job of that.
<br>&gt;<br>&gt; One thing is that you won&#39;t be able to use the full URL. RailsStory<br>&gt; wraps rails integration tests, which provide access to routing, but as<br>&gt; paths, not URLs. So for href=&quot;<a href="http://0.0.0.0:3000/site_pages/about">
http://0.0.0.0:3000/site_pages/about</a>&quot;,<br>&gt; you&#39;d need to extract the &quot;/site_pages/about&quot; part and get that.<br>&gt;<br>&gt; Thoughts?<br><br>I was planning on implementing a<br>click_link &quot;Follow me!&quot;
<br><br>sorta thing in the next couple days.&nbsp;&nbsp;One problem I have is that right<br>now you still need to know too much about the underlying structure<br>(and golly if I didn&#39;t just contradict the first part of my reply!).
<br>There was a thread a few days ago [1] where I hinted at that.&nbsp;&nbsp;He<br>wanted to go directly to a URL, when he should have been following a<br>redirect.<br><br>I think there needs to be some mechanism for following links /
<br>submitting forms so that you can really follow the path a user takes.<br>That leaves you with something like:<br><br>Story &quot;Create an auction&quot;, %{<br>&nbsp;&nbsp;As a seller<br>&nbsp;&nbsp;I want to create a new auction<br>&nbsp;&nbsp;So that I can get filthy rich
<br>} do<br><br>&nbsp;&nbsp;Scenario &quot;Successful listing&quot; do<br>&nbsp;&nbsp;&nbsp;&nbsp;Given &quot;A user&quot; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;User.create! :login =&gt; &quot;pat&quot;, :password =&gt; &quot;password&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;And &quot;user visits the login page&quot; do
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;get &quot;/login&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;And &quot;user logs in&quot; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;submit_form :login, :login =&gt; &quot;pat&quot;, :password =&gt; &quot;password&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;And &quot;user visits new auction page&quot; do
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;click_link &quot;Create an auction&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;When &quot;user creates auction&quot; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;submit_form :auction, :auction =&gt; { :item_name =&gt; &quot;Ruby for<br>Rails&quot;, :price =&gt; 50 }
<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;Then &quot;new auction should be listed&quot; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.should have_text(/Item successfully created!/)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.should have_text(/Ruby for Rails/)<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;end<br>end<br><br>That requires you to know
<br>1. Point of entry<br>2. IDs of forms and links (or text for links, if you prefer)<br>3. The fields that a form uses<br><br>So really all we&#39;ve gotten away from is dependency on knowing certain<br>URLs, which I&#39;m not positive is a huge benefit...otoh, this is closer
<br>to tracing a user&#39;s path through the app which is nice.<br><br>wdyt?<br><br>Pat<br><br>[1] <a href="http://rubyforge.org/pipermail/rspec-users/2007-September/003344.html">http://rubyforge.org/pipermail/rspec-users/2007-September/003344.html
</a><br>_______________________________________________<br>rspec-users mailing list<br><a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/rspec-users">
http://rubyforge.org/mailman/listinfo/rspec-users</a><br></blockquote></div><br>