Capybara:设置summernote textarea的值

时间:2016-06-15 12:15:28

标签: ruby-on-rails rspec capybara summernote

我正在尝试在我的Rails应用程序中测试summernote 0.8.1.0的实现。

我意识到fill_in无效,因为fill_in仅适用于html表单元素,而summernote使用的是带有contenteditable属性的DIV。

我从这里找到了一个解决方案:https://stackoverflow.com/a/30921215/1713912,但它对我不起作用。

非常感谢任何解决方案的想法!

我的测试:

it "allows admins to add text blocks to events", js: true, focus: true do
    click_on "Add text block"
    expect(page).to have_content "Text block content"
    all("div[contenteditable]").last.set("Dummy text")
    click_on "Publish now"
    expect(page).to have_content "Event created successfully"
    expect(Event.last.text_blocks.last.text_attachment.content).to eq "Dummy text"
end

更新:添加了测试日志

1) events feature event creation adding content blocks allows admins to add text blocks to events
     Failure/Error: expect(Event.last.text_blocks.last.text_attachment.content).to eq "Dummy text"

       expected: "Dummy text"
            got: ""

       (compared using ==)
     # ./spec/features/event_feature_spec.rb:76:in `block (4 levels) in <top (required)>'
     # -e:1:in `<main>'

0 个答案:

没有答案