There is probably an easy solution to this but I am new to rails and
rspec and after searching I cannot seem to find an answer. When I try
the following code:
response.should have_selector("#logo", :src =>
"/images/logo.jpg")
it fails because rails appends a ? and timestamp to the end of the
image name. If I put the full name it passes.
response.should have_selector("#logo", :src =>
"/images/logo.jpg?
1243997048")
when I run the following matcher bellow it fails because rails adds
the timestamp after the file name. I''ve looked around but have not
found anyone else having this problem. I am new to rails and rspec so
maybe I am completely missing something obvious.
response.should have_selector("#logo", :src =>
"/images/logo.jpg")
I found the answer to my own question. Just needed to use image_path
("logo.jpg"). Incase anyone else has this is I hope this helps.
response.should have_selector("#logo", :src =>
image_path("logo.jpg"))
On Jun 4, 9:19?pm, amkirwan <amkir... at gmail.com>
wrote:> when I run the following matcher bellow it fails because rails adds
> the timestamp after the file name. I''ve looked around but have not
> found anyone else having this problem. I am new to rails and rspec so
> maybe I am completely missing something obvious.
>
> ?response.should have_selector("#logo", :src =>
"/images/logo.jpg")
> _______________________________________________
> rspec-users mailing list
> rspec-us... at
rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
On 5 Jun 2009, at 02:54, amkirwan wrote:> I found the answer to my own question. Just needed to use image_path > ("logo.jpg"). Incase anyone else has this is I hope this helps. > > response.should have_selector("#logo", :src => image_path("logo.jpg"))I''d have thought there''s a marginal risk (if your page renders slowly in the test, for example) that the timestamp might change between rendering the page and running this assertion. Another other way is to use a looser CSS selector, something like response.should have_selector("#logo[src*=logo.jpg]") I can''t quite remember the syntax, but the idea is to search for a tag whose src attributes *begins with* ''logo.jpg'', thereby ignoring the timestamp entirely.> On Jun 4, 9:19 pm, amkirwan <amkir... at gmail.com> wrote: >> when I run the following matcher bellow it fails because rails adds >> the timestamp after the file name. I''ve looked around but have not >> found anyone else having this problem. I am new to rails and rspec so >> maybe I am completely missing something obvious. >> >> response.should have_selector("#logo", :src => "/images/logo.jpg") >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-usersMatt Wynne http://beta.songkick.com http://blog.mattwynne.net