I''m developing another view test. Relevant example: it "should show the item''s url" do rendered.should contain("http://www.example.com") end I''m calling render in a before block. I have other similar examples on the page in which I''m simply using: rendered.should =~ "..." These all work fine, as does the first example I posted here. However, when trying to express that first example with a regex (which I prefer), the example fails: it "should show the item''s url" do rendered.should =~ /http:\/\/www.example.com/ end Am I missing something? Thanks, Brennon Bortz Software Researcher Dundalk Institute of Technology brennon.bortz at casala.ie Ph.D. Researcher & Composer - Sonic Arts Research Centre Queen''s University, Belfast brennon at brennonbortz.com / bbortz01 at qub.ac.uk -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100906/00819742/attachment-0001.html>
On Sep 6, 2010, at 8:15 AM, Brennon Bortz wrote:> I''m developing another view test. Relevant example: > > it "should show the item''s url" do > rendered.should contain("http://www.example.com") > end > > I''m calling render in a before block. I have other similar examples on the page in which I''m simply using: > > rendered.should =~ "..." > > These all work fine, as does the first example I posted here. However, when trying to express that first example with a regex (which I prefer), the example fails: > > it "should show the item''s url" do > rendered.should =~ /http:\/\/www.example.com/ > end > > Am I missing something?Please post the failure message. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100906/38120890/attachment.html>
On 6 Sep 2010, at 14:55, David Chelimsky wrote:> On Sep 6, 2010, at 8:15 AM, Brennon Bortz wrote: > >> I''m developing another view test. Relevant example: >> >> it "should show the item''s url" do >> rendered.should contain("http://www.example.com") >> end >> >> I''m calling render in a before block. I have other similar examples on the page in which I''m simply using: >> >> rendered.should =~ "..." >> >> These all work fine, as does the first example I posted here. However, when trying to express that first example with a regex (which I prefer), the example fails: >> >> it "should show the item''s url" do >> rendered.should =~ /http:\/\/www.example.com/ >> end >> >> Am I missing something?Failures: 1) widgets/show.html.erb widget details should show the widget''s url Failure/Error: rendered.should =~ /http:\/\/www.example.com/ expected: /http:\/\/www.example.com/, got: "http://www.example.com" (using =~) I realise this is because of the escaped HTML output, but I''m not quite sure what to do about it... -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100906/c9eebf91/attachment.html>
On Sep 6, 2010, at 9:20 AM, Brennon Bortz wrote:> On 6 Sep 2010, at 14:55, David Chelimsky wrote: > >> On Sep 6, 2010, at 8:15 AM, Brennon Bortz wrote: >> >>> I''m developing another view test. Relevant example: >>> >>> it "should show the item''s url" do >>> rendered.should contain("http://www.example.com") >>> end >>> >>> I''m calling render in a before block. I have other similar examples on the page in which I''m simply using: >>> >>> rendered.should =~ "..." >>> >>> These all work fine, as does the first example I posted here. However, when trying to express that first example with a regex (which I prefer), the example fails: >>> >>> it "should show the item''s url" do >>> rendered.should =~ /http:\/\/www.example.com/ >>> end >>> >>> Am I missing something? > > > Failures: > 1) widgets/show.html.erb widget details should show the widget''s url > Failure/Error: rendered.should =~ /http:\/\/www.example.com/ > expected: /http:\/\/www.example.com/, > got: "http://www.example.com" (using =~) > > I realise this is because of the escaped HTML output, but I''m not quite sure what to do about it...I think contain is your best bet here, unless you actually want to change the expectation so it includes the escaped characters. FWIW, David -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100906/7d58ffcf/attachment.html>
On 6 Sep 2010, at 15:39, David Chelimsky wrote:> On Sep 6, 2010, at 9:20 AM, Brennon Bortz wrote: > >> On 6 Sep 2010, at 14:55, David Chelimsky wrote: >> >>> On Sep 6, 2010, at 8:15 AM, Brennon Bortz wrote: >>> >>>> I''m developing another view test. Relevant example: >>>> >>>> it "should show the item''s url" do >>>> rendered.should contain("http://www.example.com") >>>> end >>>> >>>> I''m calling render in a before block. I have other similar examples on the page in which I''m simply using: >>>> >>>> rendered.should =~ "..." >>>> >>>> These all work fine, as does the first example I posted here. However, when trying to express that first example with a regex (which I prefer), the example fails: >>>> >>>> it "should show the item''s url" do >>>> rendered.should =~ /http:\/\/www.example.com/ >>>> end >>>> >>>> Am I missing something? >> >> >> Failures: >> 1) widgets/show.html.erb widget details should show the widget''s url >> Failure/Error: rendered.should =~ /http:\/\/www.example.com/ >> expected: /http:\/\/www.example.com/, >> got: "http://www.example.com" (using =~) >> >> I realise this is because of the escaped HTML output, but I''m not quite sure what to do about it... > > I think contain is your best bet here, unless you actually want to change the expectation so it includes the escaped characters.I''ve got no problem doing that. On a related note, though, is there any possibility that Capybara matchers will ever be available in view/helper examples? should_contain is a little bit open-ended for my taste. Thanks, BB -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100906/af021229/attachment.html>
On Sep 6, 2010, at 9:51 AM, Brennon Bortz wrote:> On 6 Sep 2010, at 15:39, David Chelimsky wrote: > >> On Sep 6, 2010, at 9:20 AM, Brennon Bortz wrote: >> >>> On 6 Sep 2010, at 14:55, David Chelimsky wrote: >>> >>>> On Sep 6, 2010, at 8:15 AM, Brennon Bortz wrote: >>>> >>>>> I''m developing another view test. Relevant example: >>>>> >>>>> it "should show the item''s url" do >>>>> rendered.should contain("http://www.example.com") >>>>> end >>>>> >>>>> I''m calling render in a before block. I have other similar examples on the page in which I''m simply using: >>>>> >>>>> rendered.should =~ "..." >>>>> >>>>> These all work fine, as does the first example I posted here. However, when trying to express that first example with a regex (which I prefer), the example fails: >>>>> >>>>> it "should show the item''s url" do >>>>> rendered.should =~ /http:\/\/www.example.com/ >>>>> end >>>>> >>>>> Am I missing something? >>> >>> >>> Failures: >>> 1) widgets/show.html.erb widget details should show the widget''s url >>> Failure/Error: rendered.should =~ /http:\/\/www.example.com/ >>> expected: /http:\/\/www.example.com/, >>> got: "http://www.example.com" (using =~) >>> >>> I realise this is because of the escaped HTML output, but I''m not quite sure what to do about it... >> >> I think contain is your best bet here, unless you actually want to change the expectation so it includes the escaped characters. > > I''ve got no problem doing that. On a related note, though, is there any possibility that Capybara matchers will ever be available in view/helper examples? should_contain is a little bit open-ended for my taste.I''d like that very much, but, as things stand today, they''re bound to the Capybara session, so they won''t work in view specs (which don''t have a full request cycle). I''ve chatted w/ Jonas about this and he''s interested in decoupling the matchers so we could use them against an arbitrary string, but there''s no definite commitment to that or an ETA. Wish I had better news than that, but that''s the state of things. Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100906/906b60c7/attachment.html>
Capybara matchers I think will stay Capybara specific. However, you can use this gem to test any kind of string containing html: http://github.com/grimen/rspec_tag_matchers. David: Maybe you should consider adding that gem to the rspec-rails core or at least mention it in the docs. Need for it seems to be popping up everywhere. - Toni On Mon, Sep 6, 2010 at 5:51 PM, Brennon Bortz <brennon at brennonbortz.com> wrote:> On 6 Sep 2010, at 15:39, David Chelimsky wrote: > > On Sep 6, 2010, at 9:20 AM, Brennon Bortz wrote: > > On 6 Sep 2010, at 14:55, David Chelimsky wrote: > > On Sep 6, 2010, at 8:15 AM, Brennon Bortz wrote: > > I''m developing another view test. ?Relevant example: > it "should show the item''s url" do > ?? ? ?rendered.should contain("http://www.example.com") > end > I''m calling render in a before block. ?I have other similar examples on the > page in which I''m simply using: > rendered.should =~ "..." > These all work fine, as does the first example I posted here. ?However, when > trying to express that first example with a regex (which I prefer), the > example fails: > it "should show the item''s url" do > ?? ? ?rendered.should =~ /http:\/\/www.example.com/ > end > Am I missing something? > > Failures: > ??1) widgets/show.html.erb widget details should show the widget''s url > ?? ? Failure/Error: rendered.should =~ /http:\/\/www.example.com/ > ?? ? expected: /http:\/\/www.example.com/, > ?? ? ? ? ?got: "http://www.example.com" (using =~) > I realise this is because of the escaped HTML output, but I''m not quite sure > what to do about it... > > I think contain is your best bet here, unless you actually want to change > the expectation so it includes the escaped characters. > > I''ve got no problem doing that. ?On a related note, though, is there any > possibility that Capybara matchers will ever be available in view/helper > examples? ?should_contain is a little bit open-ended for my taste. > Thanks, > BB > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >