Skip to content

Commit

Permalink
Replaced capybara-webkit with poltergeist to get better support for T…
Browse files Browse the repository at this point in the history
…ravis. It was not without cons though, had to set some values in the spec with jquery since poltergeist gave me all sorts of trouble.
  • Loading branch information
Johannes Baldursson authored and mshibuya committed Oct 8, 2013
1 parent b8dbf69 commit bd14276
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -28,6 +28,5 @@ before_script:
- bundle install
- bundle exec rake rails_admin:prepare_ci_env db:create db:migrate
- cd ../../
script: xvfb-run rspec
services:
- mongodb
3 changes: 2 additions & 1 deletion Gemfile
Expand Up @@ -55,7 +55,8 @@ group :test do
gem 'simplecov', :require => false
gem 'strong_parameters', '>= 0.1.6'
gem 'timecop', '>= 0.5'
gem 'capybara-webkit'
gem 'faye-websocket', '0.4.4'
gem 'poltergeist', '~> 1.0.2'
end

gemspec
12 changes: 8 additions & 4 deletions spec/integration/config/edit/rails_admin_config_edit_spec.rb
Expand Up @@ -699,17 +699,21 @@ class HelpTest < Tableless

page.find('#field_test_comment_attributes_field .add_nested_fields').click()
fill_in "field_test_comment_attributes_content", :with => 'nested comment content'

# Poltergeist fails to set the value of the invisible elements, have to do it with jquery
page.execute_script('$("#field_test_nested_field_tests_attributes_0_title").val("nested field test title 1 edited")')
page.execute_script('$("#field_test_nested_field_tests_attributes_1__destroy").val("true")')

fill_in "field_test_nested_field_tests_attributes_0_title", :with => 'nested field test title 1 edited'
page.find('#field_test_nested_field_tests_attributes_1__destroy').set('true')
#fill_in "field_test_nested_field_tests_attributes_0_title", :with => 'nested field test title 1 edited'
#page.find('#field_test_nested_field_tests_attributes_1__destroy').set('true')

click_button "Save" # first(:button, "Save").click

@record.reload

sleep 1 # Without the sleep, the nested attributes are not loaded yet when the subsequent asserts are executed.
#sleep 1 # Without the sleep, the nested attributes are not loaded yet when the subsequent asserts are executed.

expect(@record.comment.content).to eq('nested comment content')
expect(@record.comment.content.strip).to eq('nested comment content')
expect(@record.nested_field_tests.length).to eq(1)
expect(@record.nested_field_tests[0].title).to eq('nested field test title 1 edited')
end
Expand Down
4 changes: 3 additions & 1 deletion spec/spec_helper.rb
Expand Up @@ -49,6 +49,8 @@ def password_digest(password)
config.stretches = 0
end

require 'capybara/poltergeist'

RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = :expect
Expand Down Expand Up @@ -93,5 +95,5 @@ def password_digest(password)
end
end

Capybara.javascript_driver = :webkit
Capybara.javascript_driver = :poltergeist
end

0 comments on commit bd14276

Please sign in to comment.