Simple use of EM::Synchrony#sync causes 'root fiber' FiberError -- my fault? - ruby

This program
require 'em-synchrony' ## v1.0.0
require 'em-hiredis' ## v0.1.0
module EventMachine
module Hiredis
class Client
def self.connect(host = 'localhost', port = 6379)
conn = new(host, port)
EM::Synchrony.sync conn.connect
conn
end
alias :old_method_missing :method_missing
def method_missing(sym, *args)
EM::Synchrony.sync old_method_missing(sym, *args)
end
end
end
end
EventMachine.synchrony do
redis = EM::Hiredis.connect
redis.set('foo', 'bar')
puts redis.get('foo')
EM.stop
end
dies like this
$ ruby /tmp/reddy.rb
/home/blt/.rvm/gems/ruby-1.9.3-p0/gems/em-synchrony-1.0.0/lib/em-synchrony.rb:58:in `yield': can't yield from root fiber (FiberError)
from /home/blt/.rvm/gems/ruby-1.9.3-p0/gems/em-synchrony-1.0.0/lib/em-synchrony.rb:58:in `sync'
from /tmp/reddy.rb:16:in `method_missing'
from /home/blt/.rvm/gems/ruby-1.9.3-p0/gems/em-hiredis-0.1.0/lib/em-hiredis/client.rb:119:in `select'
from /home/blt/.rvm/gems/ruby-1.9.3-p0/gems/em-hiredis-0.1.0/lib/em-hiredis/client.rb:38:in `block in connect'
from /home/blt/.rvm/gems/ruby-1.9.3-p0/gems/em-hiredis-0.1.0/lib/em-hiredis/event_emitter.rb:8:in `call'
from /home/blt/.rvm/gems/ruby-1.9.3-p0/gems/em-hiredis-0.1.0/lib/em-hiredis/event_emitter.rb:8:in `block in emit'
from /home/blt/.rvm/gems/ruby-1.9.3-p0/gems/em-hiredis-0.1.0/lib/em-hiredis/event_emitter.rb:8:in `each'
from /home/blt/.rvm/gems/ruby-1.9.3-p0/gems/em-hiredis-0.1.0/lib/em-hiredis/event_emitter.rb:8:in `emit'
from /home/blt/.rvm/gems/ruby-1.9.3-p0/gems/em-hiredis-0.1.0/lib/em-hiredis/connection.rb:15:in `connection_completed'
from /home/blt/.rvm/gems/ruby-1.9.3-p0/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:179:in `run_machine'
from /home/blt/.rvm/gems/ruby-1.9.3-p0/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:179:in `run'
from /home/blt/.rvm/gems/ruby-1.9.3-p0/gems/em-synchrony-1.0.0/lib/em-synchrony.rb:27:in `synchrony'
from /tmp/reddy.rb:22:in `<main>'
I find this deeply confusing. Why doesn't it work and am I at fault? If so, what can I do differently? Unless I've glossed over something, this is kosher, per the em-synchrony README.

I think your code can work if you find the correct version of em-hiredis it is trying to monkey patch, that is one problem with loose dependencies.
Here is a fully working code but based on the master branch of em-synchrony:
Gemfile:
source :rubygems
gem 'em-synchrony', :git => "git://github.com/igrigorik/em-synchrony.git"
gem 'em-hiredis', '~> 0.1.0'
test.rb:
require 'rubygems'
require 'bundler/setup'
require 'em-synchrony'
require 'em-synchrony/em-hiredis'
EventMachine.synchrony do
redis = EM::Hiredis.connect
redis.set('foo', 'bar')
puts redis.get('foo')
EM.stop
end
and then run it with:
$ bundle
$ ruby test.rb
Monkey patching is an inherently flawed way of patching gems unless you ensure the exact version of the gem you patched is used which is something em-synchrony should enforce or at least detect.

Related

Using gems in Ruby *basic*

I'm a complete newbie.
I have a gem I want to install and use, let's say it's this one:
https://rubygems.org/gems/linkedindata/versions/0.0.22
I'm using cmd:
gem install linkedindata
#1 gem installed
After that I add it to my gemfile:
gemrat 'linkedindata'
#gem 'linkedindata', '0.0.22' added to your Gemfile.
Now to use linkedindata I have to create a new object and specify my search. So I do:
**test.rb**
l = LinkedinData.new(1, "c:/users/proxylist.txt", true, true)
searchTerms = ['First', 'Second', 'Third']
l.getByKeywords(searchTerms)
Now I run the test.rb from command prompt:
test.rb:1:in `<main>': undefined local variable or meth
od `linkedindata' for main:Object (NameError)
So, I obviously need to require the 'linkedindata' gem here. I added:
**test.rb**
require 'LinkedinData'
l = LinkedinData.new(1, "c:/users/proxylist.txt", true, true)
searchTerms = ['First', 'Second', 'Third']
l.getByKeywords(searchTerms)
I get the following error:
C:/Ruby22/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `re
quire': cannot load such file -- linkedin-scraper (LoadError)
from C:/Ruby22/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require
.rb:54:in `require'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/linkedindata-0.0.22/lib/linkedin
data.rb:1:in `<top (required)>'
from C:/Ruby22/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require
.rb:128:in `require'
from C:/Ruby22/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require
.rb:128:in `rescue in require'
from C:/Ruby22/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require
.rb:39:in `require'
from C:/Users/test.rb:1:in `<main>'
Am I doing something fundamentally wrong here? Or is there a problem with this gem?
UPDATE
The problem was within the gem, see Doon's answer below.
require 'rubygems'
require 'bundler/setup'
require 'linkedindata'
l = LinkedinData.new(1, "proxylist.txt", true, true)
searchTerms = ['First', 'Second', 'Third']
l.getByKeywords(searchTerms)
++++ correct how the gem requires "linkedin_scraper" in linkedindata.rb
Next problem occurs
C:/Ruby22/lib/ruby/gems/2.2.0/gems/linkedindata-0.0.22/lib/linkedin.rb:6:in `<cl
ass:Profile>': uninitialized constant Linkedin::Profile::ProxyManager (NameError
)
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/linkedindata-0.0.22/lib/linkedin
.rb:5:in `<module:Linkedin>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/linkedindata-0.0.22/lib/linkedin
.rb:4:in `<top (required)>'
from linkedinscrape.rb:4:in `require'
from linkedinscrape.rb:4:in `<main>'
Which obviously has to do with the proxy settings. The list:
**proxylist.txt**
220.248.224.242:8089
165.139.179.225:8080
54.207.114.172:3333
190.63.174.246:8081
The way I load it:
l = LinkedinData.new(1, "c:/users/proxylist.txt")
As you are using a Gemfile, you are using bundler. In your script you will need to include rubygems and bundler to make it work. Try this
require 'rubygems'
require 'bundler/setup'
require 'linkedindata'
l = LinkedinData.new(1, "c:/users/proxylist.txt", true, true)
searchTerms = ['First', 'Second', 'Third']
l.getByKeywords(searchTerms)
You have run bundle install, sorry not familiar with gemrat, so not sure how much it does for you.
if you are not actually using bundler, just remove require 'bundler/setup' from the code above, you will still need to require rubygems though in your script.
in looks like the gem itself is kind of broken in the way it declare dependencies, and the other gems that it relies on. I appear to be able to make it work as follows:
Gemfile:
source 'https://rubygems.org'
gem 'linkedin-scraper'
gem 'linkedindata'
gem 'generalscraper'
gem 'uploadconvert'
gem 'docsplit'
gem 'crack'
gem 'pry'
gem 'activesupport'
gem 'selenium-webdriver'
It also appears that it the linkedin-scraper needs to required as linkedin_scraper but not sure why that is. So editing.
{GEMPATH}/linkedindata-0.0.22/lib/linkedindata.rb to require 'linkedin_scraper' as opposed to require 'linkedin-scraper' seems to make it work.
So with the above changes and using bundler
require 'rubygems'
require 'bundler/setup'
require 'linkedindata'
l = LinkedinData.new(1, "proxylist.txt", true, true)
searchTerms = ['First', 'Second', 'Third']
l.getByKeywords(searchTerms)
now runs (I don't have a proxylist.txt so it blows up looking for it, but it doesn't get anymore library errors).

trying to include sunlight congress gem in my project

So I am simply trying to run this code below with sunlight congress gem, but I seem to be doing something wrong. I am trying to include the gem in the project however something is off.
I am trying to implement this using RubyMine 7.1.2(if version matters), Ruby 2.2.2.
sunlight congress can be found here: https://github.com/sunlightlabs/ruby-sunlight.
Also, I am working on windows 8.1.
require 'csv'
require 'sunlight-congress'
require 'erb'
Sunlight::Congress.api_key = "e179a6973728c4dd3fb1204283aaccb5"
def neat_zip(zipcode)
zipcode.to_s.rjust(5,"0")[0..4]
end
def legislator_by_zip(zipcode)
Sunlight::Congress::Legislator.by_zipcode(zipcode)
end
def save_thank_you_letters(id,form_letter)
Dir.mkdir("output") unless Dir.exists?("output")
filename = "output/thanks_#{id}.html"
File.open(filename,'w') do |file|
file.puts form_letter
end
end
puts "EventManager initialized."
contents = CSV.open 'event_attendees.csv', headers: true, header_converters: :symbol
template_letter = File.read "form_letter.erb"
erb_template = ERB.new template_letter
contents.each do |row|
id = row[0]
name = row[:first_name]
zipcode = neat_zip(row[:zipcode])
legislators = legislator_by_zip(zipcode)
form_letter = erb_template.result(binding)
save_thank_you_letters(id,form_letter)
end
I am getting this error:
C:\Ruby22\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/Ruby22/event_manager/sunlight-congress-master/lib/event_manager.rb
C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- sunlight-congress (LoadError)
from C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from C:/Ruby22/event_manager/sunlight-congress-master/lib/event_manager.rb:2:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
Do i simply have the path wrong? gem isnt installed?
You need to gem install sunlight-congress.
Update: Resources to install gems in Windows / RubyMine
Installing gems with RubyMine
Installing Ruby Gem in Windows
http://rubyinstaller.org/

LoadError on require './primes.rb' in terminal

When I do require './primes.rb' in irb I get this:
1.9.3-p392 :004 > require './primes.rb'
LoadError: cannot load such file -- ./primes.rb
from /Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from (irb):4
from /Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/bin/irb:16:in `<main>'
Here is the primes.rb document:
# primes.rb
require 'debugger'
def prime?(num)
debugger
(1..num).each do |i|
if (num % i) == 0
return false
end
end
end
def primes(num_primes)
ps = []
num = 1
while ps.count < num_primes
primes << num if prime?(num)
end
end
if __FILE__ == $PROGRAM_NAME
puts primes(100)
end
Any suggestions of how to get this to work would be greatly appreciated!
When I do require relative it gives me this:
1.9.3-p392 :010 > require_relative 'primes.rb'
LoadError: cannot infer basepath
from (irb):10:in `require_relative'
from (irb):10
from /Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/bin/irb:16:in `<main>'
When I do the second solution below it gives me this:
1.9.3-p392 :013 > $LOAD_PATH << "."
=> ["/Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1", "/Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/x86_64-darwin11.4.2", "/Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby", "/Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/vendor_ruby/1.9.1", "/Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/vendor_ruby/1.9.1/x86_64-darwin11.4.2", "/Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/vendor_ruby", "/Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1", "/Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/x86_64-darwin11.4.2", "."]
1.9.3-p392 :014 > require 'primes.rb'
LoadError: cannot load such file -- primes.rb
from /Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from (irb):14
from /Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/bin/irb:16:in `<main>'
1.9.3-p392 :015 >
When I try it in pry:
[4] pry(main)> require_relative 'primes.rb'
LoadError: cannot infer basepath
from (pry):2:in `require_relative'
[5] pry(main)> require 'primes.rb'
LoadError: cannot load such file -- primes.rb
from /Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
[6] pry(main)> .ls
Applications Movies git-completion.bash
Desktop Music rails_projects
Documents Pictures ruby
Downloads Public runwithfriends
Dropbox code shopify
Library dev sites
[7] pry(main)> require 'ruby/app_acad_mini_curriculum/debugging/primes.rb'
LoadError: cannot load such file -- ruby/app_acad_mini_curriculum/debugging/primes.rb
from /Users/RBonhardt/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
Try require_relative
require_relative 'primes.rb'
EDIT:
Note that this will only work from within a script. If you are trying to require this script into an irb session then you will need to provide the full path to primes.rb. The reason is where irb's location is. For instance, try Dir.pwd inside irb and you will see where require_relative is attempting to search for primes.rb.
There are a couple things you could do:
# Just need to require the one file.
require_relative File.join('users', 'yourusername', 'prime_folder', 'prime.rb')
# Many files in the same folder
$LOAD_PATH << File.join('users', 'yourusername', 'prime_folder')
require 'prime.rb'
require 'another_file.rb'
Another option, one that I use, is Pry. It is like irb and is very easy to call from a script. It is a gem so:
gem install pry
At the end of your script, you could do:
if $0 == __FILE__
require 'pry'
binding.pry
end
You would then drop into an irb like REPL where you can test and debug your methods. I can't survive without it.
unlike ruby 1.8, you can't require a file that is in the same folder, because the current folder is not on the load path any longer.
To emulate the behavior of ruby 1.8, you could try
$LOAD_PATH << "."
require 'primes.rb'
However, the correct way to do in ruby 1.9, as #CharlesCaldwell pointed, is using relative_require.
Here is a good discussion of the best way to deal with this.
note that relative_require does not work in irb. You can check the motive on #CharlesCaldwell answer.
But looking in your task question, you should not use irb, you should use pry:
We're going to use two gems. One is called Pry, which is a replacement for irb. You'll have to gem install pry. It's not essential for debugging that you use Pry, but it will make life nicer.
Here is an example using relative require:
[fotanus#thing ~]$ cat primes.rb
# primes.rb
def prime?(num)
(1..num).each do |i|
if (num % i) == 0
return false
end
end
end
def primes(num_primes)
ps = []
num = 1
while ps.count < num_primes
primes << num if prime?(num)
end
end
if __FILE__ == $PROGRAM_NAME
puts primes(100)
end
[fotanus#thing ~]$ cat a.rb
require_relative 'primes.rb'
[fotanus#thing ~]$ ruby a.rb

Sinatra, Mongoid, Heroku, MongoHQ: connecting to Mongodb

Trying to get Mongoid up and running with Sinatra on Heroku (MongoHQ). Previous experience with Rails but first time with the stack and Sinatra.
Started with one of the simple examples on the web (app.rb):
require 'rubygems'
require 'sinatra'
require 'mongo'
require 'mongoid'
configure do
Mongoid.load!('mongoid.yml')
Mongoid.configure do |config|
if ENV['MONGOHQ_URL']
conn = Mongo::Connection.from_uri(ENV['MONGOHQ_URL'])
uri = URI.parse(ENV['MONGOHQ_URL'])
# problem happens here
config.master = conn.db(uri.path.gsub(/^\//, ''))
else
config.master = Mongo::Connection.from_uri("mongodb://localhost:27017").db('test')
end
end
end
# Models
class Counter
include Mongoid::Document
field :count, :type => Integer
def self.increment
c = first || new({:count => 0})
c.inc(:count, 1)
c.save
c.count
end
end
# Controllers
get '/' do
"Hello visitor n" + Counter.increment.to_s
end
For reference, mongoid.yml looks like:
development:
sessions:
default:
database: localhost
production:
sessions:
default:
uri: <%= ENV['MONGOHQ_URL'] %>
As per app.rb (# problem happens here), my logs say:
/app/app.rb:15:in `block (2 levels) in <top (required)>': undefined method `master=' for Mongoid::Config:Module (NoMethodError)
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.3/lib/mongoid.rb:112:in `configure'
from /app/app.rb:11:in `block in <top (required)>'
from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:1273:in `configure'
from /app/app.rb:8:in `<top (required)>'
I have also tried variants, including:
config.master = Mongo::Connection.from_uri(ENV['MONGOHQ_URL']).db('appXXXXX')
Mongoid.database = Mongo::Connection.from_uri(ENV['MONGOHQ_URL']).db('appXXXXXXX')
But get the same error:
undefined method `master` for Mongoid::Config:Module (NoMethodError)
or:
undefined method `database=` for Mongoid::Config:Module (NoMethodError)
What am I missing?
Shouldn't be
configure do
Mongoid.load!('mongoid.yml')
end
enough?
That's what the mongid docs are saying. The MONGOHQ_URL environment variable already contains every information to initialize the connection to the db.
So was using Mongoid 3.x ... which:
Doesn't use 10gen driver: uses Moped
Doesn't use config.master
The canonical sample code above which is all over the web works out of the box with Mongoid 2.x so have dropped back to that for the time being.
Thanks!

rails 3.1.3 / cucumber / database_cleaner / mongo_mapper

does anybody have also trouble running the cucumber tests in that envirounment?
Error
Exception encountered by DatabaseCleaner in Cucumber After block: ActiveRecord::ConnectionNotEstablished
ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:409:in `retrieve_connection'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `retrieve_connection'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-rails-1.2.1/lib/cucumber/rails/hooks/active_record.rb:6:in `connection'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.7.1/lib/database_cleaner/active_record/truncation.rb:130:in `clean'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.7.1/lib/database_cleaner/base.rb:77:in `clean'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.7.1/lib/database_cleaner/configuration.rb:56:in `block in clean'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.7.1/lib/database_cleaner/configuration.rb:56:in `each'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.7.1/lib/database_cleaner/configuration.rb:56:in `clean'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-rails-1.2.1/lib/cucumber/rails/hooks/database_cleaner.rb:9:in `After'
features/support/env.rb
7 require 'cucumber/rails'
8 require 'database_cleaner'
9 require 'database_cleaner/cucumber'
10 require 'database_cleaner/mongo_mapper/truncation'
...
41 # Remove/comment out the lines below if your app doesn't have a database.
42 # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
43 begin
44 DatabaseCleaner.strategy = :truncation
45 rescue NameError
46 raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
47 end
I got no idea what to do.
I'm getting the same problem, all my 'steps' pass but my Scenario fails due to the ActiveRecord mixup with Database Cleaner.
Scenario: User is not signed up # features/users/sign_in.feature:6
Given I am not logged in # features/step_definitions/user_steps.rb:86
And no user exists with an email of "user#invalidemail.com" # features/step_definitions/user_steps.rb:1
When I go to the sign in page # features/step_definitions/web_steps.rb:48
And I sign in as "user#invalidemail.com/please" # features/step_definitions/user_steps.rb:61
Then I should see "Invalid email or password." # features/step_definitions/web_steps.rb:105
And I go to the home page # features/step_definitions/web_steps.rb:48
And I should be signed out # features/step_definitions/user_steps.rb:81
ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `retrieve_connection'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/cucumber-rails-1.3.0/lib/cucumber/rails/hooks/active_record.rb:6:in `connection'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/database_cleaner-0.7.2/lib/database_cleaner/active_record/truncation.rb:130:in `clean'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/database_cleaner-0.7.2/lib/database_cleaner/base.rb:77:in `clean'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/database_cleaner-0.7.2/lib/database_cleaner/configuration.rb:56:in `block in clean'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/database_cleaner-0.7.2/lib/database_cleaner/configuration.rb:56:in `each'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/database_cleaner- 0.7.2/lib/database_cleaner/configuration.rb:56:in `clean'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/cucumber-rails- 1.3.0/lib/cucumber/rails/hooks/database_cleaner.rb:9:in `After'
Failing Scenarios:
cucumber features/users/sign_in.feature:6 # Scenario: User is not signed up
1 scenario (1 failed)
7 steps (7 passed)
I am getting what may be a hint when executing my cucumber tests:
$bundle exec cucumber --verbose features/users/sign_in.feature:15
WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb).
https://rspec.lighthouseapp.com/projects/16211/tickets/165 (related ticket)
Oddly it doesn't fail on the Before step.
spec_helper.rb
RSpec.configure do |config|
# == Mock Framework
config.mock_with :rspec
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
...
end
...
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
...
end
features/support/config.rb
Class ...
...
End
begin
DatabaseCleaner.strategy = :truncation, { :except => %w[oauth_tokens client_applications] }
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
I had to remove DatebaseCleaner

Resources