$ruby --version
ruby 1.9.3dev (2011-09-23 revision 33323) [i686-linux]
gem 'rails', '3.2.9'
group :test do
gem 'cucumber-rails', require: false
gem 'capybara', '~> 2.0.3'
gem 'rspec-rails'
gem 'database_cleaner'
gem 'factory_girl'
gem "ffaker"
gem "capybara-firebug", "~> 1.3.0"
gem 'ruby-debug19'
end
In one of my Cucumber Step I am trying to assert that a drop-down element (<select> tag) has a particular option selected using Capybara API with the following code.
within('#myForm') do
page.has_select?("#event_type", selected: @event_type).should be_true
end
However I am getting this error:
expected: true value
got: false (RSpec::Expectations::ExpectationNotMetError)
I inspected the DOM using @firebug tag of (capybara-firebug) on my scenario and found that the desired option (held by @event_type) is getting selected in the drop-down however in the DOM the "selected" attribute is not getting added to the select tag which I guess is causing the expectation to fail.
I found a similar reference here: https://github.com/jnicklas/capybara/issues/171 which mentions about the commit having the fix but I guess the commit is not merged to the capybara version I am using.I trying digging in the source code and found that the fixes mentioned at https://github.com/jnicklas/capybara/issues/171 are not present in the Capybara's codebase.
Can any body please let me know how to assert that a select tag has a particular option selected?
Note: When using capybara in my Gem file without any version:
gem 'capybara'
Capybara Version 2.1.0 is initiated to be installed however it fails with error:
capybara requires Ruby version >= 1.9.3
though I have the required ruby version.
Following is the output of
$ rvm info
ruby-1.9.3-rc1:
system:
uname: "Linux jigneshgohel-Inspiron-N5110 3.2.0-40-generic-pae #64-Ubuntu SMP Mon Mar 25 21:44:41 UTC 2013 i686 i686 i386 GNU/Linux"
bash: "/bin/bash => GNU bash, version 4.2.24(1)-release (i686-pc-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.13.4 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]"
updated: "11 months 4 days 14 hours 20 minutes 18 seconds ago"
ruby:
interpreter: "ruby"
version: "1.9.3dev"
date: "2011-09-23"
platform: "i686-linux"
patchlevel: "2011-09-23 revision 33323"
full_version: "ruby 1.9.3dev (2011-09-23 revision 33323) [i686-linux]"
homes:
gem: "/home/jigneshgohel/.rvm/gems/ruby-1.9.3-rc1"
ruby: "/home/jigneshgohel/.rvm/rubies/ruby-1.9.3-rc1"
binaries:
ruby: "/home/jigneshgohel/.rvm/rubies/ruby-1.9.3-rc1/bin/ruby"
irb: "/home/jigneshgohel/.rvm/rubies/ruby-1.9.3-rc1/bin/irb"
gem: "/home/jigneshgohel/.rvm/rubies/ruby-1.9.3-rc1/bin/gem"
rake: "/home/jigneshgohel/.rvm/gems/ruby-1.9.3-rc1/bin/rake"
environment:
PATH: "/home/jigneshgohel/.rvm/gems/ruby-1.9.3-rc1/bin:/home/jigneshgohel/.rvm/gems/ruby-1.9.3-rc1@global/bin:/home/jigneshgohel/.rvm/rubies/ruby-1.9.3-rc1/bin:/home/jigneshgohel/.rvm/bin:/usr/local/heroku/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/media/work/Environment/Languages/Java/jdk1.7.0_04/bin:/media/work/Environment/BuildTools/apache-maven-3.0.4/bin:/media/work/Environment/BuildTools/apache-ant-1.8.3/bin"
GEM_HOME: "/home/jigneshgohel/.rvm/gems/ruby-1.9.3-rc1"
GEM_PATH: "/home/jigneshgohel/.rvm/gems/ruby-1.9.3-rc1:/home/jigneshgohel/.rvm/gems/ruby-1.9.3-rc1@global"
MY_RUBY_HOME: "/home/jigneshgohel/.rvm/rubies/ruby-1.9.3-rc1"
IRBRC: "/home/jigneshgohel/.rvm/rubies/ruby-1.9.3-rc1/.irbrc"
RUBYOPT: ""
gemset: "
Following is the output of:
$rvm list
rvm rubies
=* ruby-1.9.3-rc1 [ i686 ]
# => - current
# =* - current && default
# * - default