2007/10/1, Jarkko Laine <[EMAIL PROTECTED]>:
> On 1.10.2007, at 18.25, Jesper Laursen wrote:
> > Okay, now it seems til work.
> > The problem has what I have to place:
> >      @domain.virtual_hosts.should_receive(:find).with
> > ("1").and_return(@virtual_host)
> > in the before, because the  "do_get" method was using it, in all it-
> > blocks.
> >
> > I just think that my before are pretty big.
> > And I have to copy it for every describtion.
>
> You could wrap it in a helper method in a module that you can include
> and call in the specs instead of repeating all the lines.

Yes, I know, but not all the code have to be used every time.
Now I have a new problem. It know work in a browser, but if i am
running autotest, this error raise:

<cite>
/opt/local/bin/ruby -S script/spec -O spec/spec.opts
spec/views/virtual_hosts/show.rhtml_spec.rb
F

1)
ActionView::TemplateError in '/virtual_hosts/show.rhtml should render
attributes in <p>'
edit_virtual_host_url failed to generate from
{:controller=>"virtual_hosts", :domain_id=>"1001", :action=>"edit"},
expected: {:controller=>"virtual_hosts", :action=>"edit"}, diff:
{:domain_id=>"1001"}
On line #92 of app/views/virtual_hosts/show.rhtml

    89: </p>
    90:
    91:
    92: <%= link_to 'Edit', edit_virtual_host_path(@virtual_host) %> |
    93: <%= link_to 'Back', virtual_hosts_path %>
</cite>

my before do in show.rhtml_sprec.rb looks like this
<cite>
  before do
    @domain = mock_model(Domain)
    @domain.stub!(:domain_id).and_return("1")

    @virtual_host = mock_model(VirtualHost)
    @virtual_host.stub!(:servername).and_return("MyString")

    assigns[:domains] = @domain
    assigns[:virtual_host] = @virtual_host
  end
</cite>
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to