Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing spec with Rails 5 #136

Closed
dgmstuart opened this issue Jul 16, 2016 · 3 comments
Closed

Failing spec with Rails 5 #136

dgmstuart opened this issue Jul 16, 2016 · 3 comments

Comments

@dgmstuart
Copy link
Collaborator

After installing Rails 5 and freshly installing this gem, the following spec fails:

1) FoundationRailsHelper::FormHelper input generators should generate datetime_field input
     Failure/Error: expect(node).to have_css('input[type="datetime"][name="author[forty_two]"]')
       expected #has_css?("input[type=\"datetime\"][name=\"author[forty_two]\"]") to return true, got false

It's failing because the type is now datetime-local (see below). This has been introduced in Rails 5
(Old behaviour was to set type as datetime)

Here's what the capybara node looks like:

?> a = node.find('input')
=> <Capybara::Node::Simple tag="input" path="/html/body/input">

?> a.native
=> #(Element:0x3ff2ad56bf14 {
  name = "input",
  attributes = [
    #(Attr:0x3ff2ad7d94b8 { name = "value", value = "2011-06-18T20:30:00" }),
    #(Attr:0x3ff2ad7d94a4 { name = "type", value = "datetime-local" }),
    #(Attr:0x3ff2ad7d9490 { name = "name", value = "author[forty_two]" }),
    #(Attr:0x3ff2ad7d947c { name = "id", value = "author_forty_two" })]
  })
@dgmstuart
Copy link
Collaborator Author

@dsandstrom I guess we can treat this one of two ways:

  1. Treat it as a breaking change and decide that we need a separate branch for Rails 5
  2. Decide it doesn't matter much and do a fuzzy match:
expect(node).to have_css('input[type^="datetime"]')

(matches inputs with types beginning with "datetime")

I'll submit a PR for the latter

@dsandstrom
Copy link
Collaborator

I went with option 1 for the foundation-6 branch. I never commited the same fix to master, thinking we would stop development on master and focus on foundation-6 only. Using the fuzzy search is probably better anyhow.

@dgmstuart
Copy link
Collaborator Author

Cool - if you think it's OK, would you mind merging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants