ruby - In Capybara, does :exact or Capybara.exact apply to have_selector? -


I'm having trouble using CapAbra's has_selector , actually < / Em>. I know that this can be done using a regular expression, but by my reading I came to believe that I : exact arg or set Capybara.exact = true I can use. I am currently using CapAbara 2.2.1. Here's what I have:

Believing that I have a page (called "test page"). On this page is:

  & lt; Div id = "my_div" & gt; Abcdef & lt; / Div & gt;   

I have a cucumber feature test that looks like this:

  Feature: Exact text matches Test has_selector scenario for: I am on the test page, then I should get a partial text match "bcde" in my div and I should get partial text match "abcdef" in my div and I get an exact text match using regexp "abcdef Should be "in my div and use a regexp in my div" bcde "using an exact form The match should not be met and I should get an exact text match using "abcdef" RG in my div and I should not get an exact text match using "bcde" in my div   

The definition of my motion looks like this:

  then / ^ I should partially get the text matching "([^ \"] *) "My div $ / do | Text | in page.should_selector ('div # my_div', text = & gt; text) end then / ^ i should get an exact text match using regexp "([^ \"] *) "my div $ / do | text | in | Page.should_selector ('div # my_div',: text = & gt; / ^ # {text} $ /) end then / ^ exact text using me "regexp" ([^ \ "] *)" Should not match my div $ / do | Text | page.should_not has_selector ('div # my_div',: text = & gt; / ^ # {text} $ /) end then / ^ i should get an exact text using arg "([^ \"] *) " In my div $ / do | text | in | Page.should_selector ('div # my_div',: text = & gt; text, exact = & gt; true) end then / ^ me arg ("[^ \"] * ) "Should not match exact text, contrary to my expectations, my div $ / do | Text | page.should_not has_selector ('div # my_div', text = & gt; text, exact => true) end   

I get the following error:

  and I should not get an exact text match using "bcde" in my div which will not match the CSS "div # my_div" with the text "bcde" 1 match: "abcdef" (cappa :: Expectation Notmat)   

This makes me believe that : exact => True is not doing anything in my my_silcutor call I have tried to set Capybara.exact = true in my test setup configuration like this, but this also does not affect my tests, the way I expected

Am I missing something? Or is there a misunderstanding that how should this option be used? I know that I can always use regular expression syntax for matte hing an exact text string, but I would have thought that the : exact option is specifically for this kind of situation.

is an open feature request, is_selector (and others) Near to exact text matching

However, it does not apply to the current (in CapeBara 2.x), : exact option : text if I miss it correctly , Then this is the following code (from) that filters text options. As you can see, the : exact option has no argument or idea

  def match_filters? (Node) if option [: text] regexp = options [: text] .is_a? (Regexp)? Option [: Text]: Regexp.escape (option [: text] .to_s) does not return false if node is not (visible) .mail (regexp) termination   

Accordingly, the : Precise option is actually:

Control that is accurately or partially in the match / Block>>

This is basically used only in that location, where text (or id, name, etc.) is not specified as an option - eg:

  # 'password The word 'password' - 'password confirmation' click_link ('password', exact = & gt; incorrect) will be the word 'click' link_link ('password', = exact = & gt; true) # link will match; / Code>   

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -