Problem
You would like to set up your vim editor to use 2 spaces for the tab character.
Solution
Add the following to your ~/.vimrc file:
set ts=2
Problem
You would like to set up your vim editor to use 2 spaces for the tab character.
Solution
Add the following to your ~/.vimrc file:
set ts=2
Problem
According to the ‘Cucumber book’ the gems required to start using cucumber with a rails application are the following:
group :test do gem 'cucumber-rails', '1.2.1' gem 'rspec-rails', '2.7.0' gem 'database_cleaner', '0.7.0' end
On the most recent rails version (currently 3.2.9) the gems need to be updated and also include the javascript runtime gem ‘therubyracer’
Solution
The following gems are working with Rails 3.2.9
group :test do gem 'cucumber-rails', '~> 1.3.0' gem 'rspec-rails', '~> 2.12.0' gem 'database_cleaner', '~> 0.9.1' # Add javascript runtime environment gem "therubyracer", "~> 0.10.2" end
You can then run the
$ rails g cucumber:install
command to generate the files and folders necessary for cucumber.
Problem
You have a problem with aapt and adb after installing the android-sdk tools in an Ubuntu 64 installation.
Solution
Make sure you install the 32-bit libraries with:
sudo apt-get install ia32-libs
Problem
You are trying to use the Android Debug Bridge (adb), but running it from the command line trying to list the connected devices you get the error:
insufficient permissions for device
Solution
You would need to start the adb server with su permissions, so you can try the following:
adb kill-server sudo adb start-server adb devices adb logcat
Problem
You would like to see how many commits per author you have in your git repository.
Solution
Just run the following command to get commits per author in your git:
git shortlog -s -n
Problem
You have a location search in your application that uses google maps auto suggest, and you want to be able to select the first item, so that it can be used in your cucumber tests.
Solution
You can create a step as in the code below, and put it in one of your cucumber step definitions:
When /^I do a map search$/ do
item = page.find(".pac-container .pac-item:first")
item.click
end
and then you can call this step from any other step in your cucumber tests by:
step "I do a map search"
Problem
You are using cucumber for your tests and you would like to use the modal dialog confirmation box in a rails application, with capybara but you are getting the following error:
Modal dialog present Selenium::WebDriver::Error::UnhandledAlertError)
Solution
In your steps file use the following to accept (press OK), in the confirmation dialog that pops up:
page.driver.wait_until(page.driver.browser.switch_to.alert.accept)
NOTE: Or in more recent versions when the above complains for ‘undefined method wait_until’
page.driver.browser.switch_to.alert.accept
NOTE: Taken from the second comment made here
Problem
You are trying to use page.has_content? inside a cucumber step definition, but it doesn’t work as it matches all text, and returns always true.
Solution
Change the page.has_content? to page.should have_content instead and the tests should be failing when the text doesn’t match.
Problem
Your application is ussing force_ssl to redirect all calls to ‘https’, but when you try to use your cucumber tests they fail.
Solution
By using the suggestion here, you can add a file in your initializers to bypass the ssl in development and test environment as follows:
module ActionController
module ForceSSL
module ClassMethods
def force_ssl(options = {})
before_filter(options) do
if !request.ssl? && !Rails.env.development? && !Rails.env.test?
redirect_to :protocol => 'https://', :status => :moved_permanently
end
end
end
end
end
end
Problem
You want to deploy your rails 3.2 application to another environment except production, but the default capistrano recipe for precompiling the assets keeps using the production environment as in:
* executing `deploy:assets:precompile'
* executing "cd /var/www/dev/app/releases/20120816130649 && rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["server.name.com"]
Solution
Add the following environment option in your deploy/other_env.rb file:
set :rails_env, "other_env"