I was experimenting with the soundcloud gem and suddenly I always get an error with every request I make.
For example this following code:
require 'soundcloud'
client = SoundCloud.new(:client_id => MY_CLIENT_ID)
track_url = 'https://soundcloud.com/sohight/sohight-cheevy-money-is-love-out-now'
track = client.get('/resolve', :url => track_url)
puts track.genre
Anyone knows why I get this error?
/Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:33:in `normalize_param': uninitialized constant HTTParty::HashConversions::ERB (NameError)
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:15:in `block in to_params'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:15:in `each'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:15:in `map'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:15:in `to_params'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/request.rb:148:in `normalize_query'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/request.rb:180:in `query_string'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/request.rb:70:in `uri'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/request.rb:157:in `setup_raw_request'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/request.rb:98:in `perform'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty.rb:521:in `perform_request'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty.rb:459:in `get'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/soundcloud-0.3.2/lib/soundcloud/client.rb:27:in `block in get'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/soundcloud-0.3.2/lib/soundcloud/client.rb:145:in `call'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/soundcloud-0.3.2/lib/soundcloud/client.rb:145:in `handle_response'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/soundcloud-0.3.2/lib/soundcloud/client.rb:26:in `get'
from sound.rb:9:in `<main>'
Possibly a bug in HTTParty.
Line 33 of hash_conversions.rb:
param << "#{key}=#{ERB::Util.url_encode(value.to_s)}&"
Put this at the top of your script and try again:
require 'erb'
Related
I am trying to get cucumber working on my Mac for testing a ruby script. I use cucumber with rails and have never had an issue setting it up there, but seem to be having quite an issue creating it just for a ruby script that I want to test.
Script background: I have created a script that serves mysql data via a TCPServer connection and I want to be able to test this functionality. So ideally I launch the script so that it accepts incoming connections and depending on what I am attempting to get to it presents an error or the data end point.
Here is what I have and the error is below the settings:
features/support/env.rb
require_relative File.expand_path('../../../lib/requirements',FILE)
require "capybara/cucumber"
require 'capybara/dsl'
require "rspec"
# Capybara.default_driver = :selenium
Capybara.app_host = 'http://localhost:7125'
World(Capybara.app = "Api")
World(Capybara::DSL)
World(RSpec::Matchers)
features/rmws.feature
Feature: Test conversion of mysql output to JSON
Scenario:
Given the index page can be reached
And There is MYSQL data
When converted to hash
And and /mysql location is hit
Then the data is show in JSON
features/step_definitions/rwms_step_definitions.rb
Given(/^the index page can be reached$/) do
visit 'http://localhost:7125'
expect(page).to have_content 'This is the index page'
end
Given(/^There is MYSQL data$/) do
pending # express the regexp above with the code you wish you had
end
When(/^converted to hash$/) do
pending # express the regexp above with the code you wish you had
end
When(/^and \/mysql location is hit$/) do
pending # express the regexp above with the code you wish you had
end
Then(/^the data is show in JSON$/) do
pending # express the regexp above with the code you wish you had
end
Output
$ cucumber
Feature: Test conversion of mysql output to JSON
Scenario: # features/rmws.feature:3
wrong argument type String (expected Module) (TypeError)
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/rb_support/rb_language.rb:150:in `extend'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/rb_support/rb_language.rb:150:in `block in extend_world'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/rb_support/rb_language.rb:149:in `each'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/rb_support/rb_language.rb:149:in `extend_world'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/rb_support/rb_language.rb:94:in `begin_rb_scenario'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/rb_support/rb_language.rb:128:in `begin_scenario'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/language_support/language_methods.rb:14:in `before'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/runtime/support_code.rb:112:in `block in fire_hook'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/runtime/support_code.rb:111:in `each'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/runtime/support_code.rb:111:in `fire_hook'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/runtime.rb:107:in `before'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/runtime.rb:98:in `before_and_after'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/runtime.rb:82:in `block in with_hooks'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/runtime/support_code.rb:120:in `call'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/runtime/support_code.rb:120:in `block (3 levels) in around'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/language_support/language_methods.rb:9:in `block in around'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/language_support/language_methods.rb:97:in `call'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/language_support/language_methods.rb:97:in `execute_around'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/language_support/language_methods.rb:8:in `around'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/runtime/support_code.rb:119:in `block (2 levels) in around'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/runtime/support_code.rb:123:in `call'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/runtime/support_code.rb:123:in `around'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/runtime.rb:94:in `around'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/runtime.rb:81:in `with_hooks'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/tree_walker.rb:13:in `execute'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/scenario.rb:32:in `block in accept'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/scenario.rb:79:in `with_visitor'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/scenario.rb:31:in `accept'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/tree_walker.rb:58:in `block in visit_feature_element'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/tree_walker.rb:170:in `broadcast'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/tree_walker.rb:57:in `visit_feature_element'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/feature.rb:38:in `block in accept'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/feature.rb:37:in `each'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/feature.rb:37:in `accept'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/tree_walker.rb:27:in `block in visit_feature'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/tree_walker.rb:170:in `broadcast'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/tree_walker.rb:26:in `visit_feature'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/features.rb:28:in `block in accept'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/features.rb:17:in `each'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/features.rb:17:in `each'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/features.rb:27:in `accept'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/tree_walker.rb:21:in `block in visit_features'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/tree_walker.rb:170:in `broadcast'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/ast/tree_walker.rb:20:in `visit_features'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/runtime.rb:49:in `run!'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/lib/cucumber/cli/main.rb:47:in `execute!'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/gems/cucumber-1.3.11/bin/cucumber:13:in `<top (required)>'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/bin/cucumber:23:in `load'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/bin/cucumber:23:in `<main>'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/bin/ruby_executable_hooks:15:in `eval'
/Users/lovell/.rvm/gems/ruby-2.0.0-p451/bin/ruby_executable_hooks:15:in `<main>'
$
You could use rake to run cucumber tests, I use it for a gem that I wrote. You can find additional doc here
require 'bundler'
require 'rake/clean'
require 'rake/testtask'
require 'cucumber'
require 'cucumber/rake/task'
require 'rspec/core/rake_task'
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
t.fork = false
end
Run cucumber --init to get the testing suite set up.
when i try to run the command 'bundle install' or installing particular gem then ot in gzip format (Zlib::GzipFile::Error) occurs.
i have done googling and find some of the answers
like removing cache ,bundle packages but all fail in my case
i am using rails 3.2.11 and ruby 1.8.7
the code of rubygems line arround 500 is
def self.gunzip(data)
require 'stringio'
require 'zlib'
data = StringIO.new data
Zlib::GzipReader.new(data).read
end
##
# Zlib::GzipWriter wrapper that zips +data+.
def self.gzip(data)
require 'stringio'
require 'zlib'
zipped = StringIO.new
Zlib::GzipWriter.wrap zipped do |io| io.write data end
zipped.string
end
while error in console is
Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:550:in `initialize': not in gzip format (Zlib::GzipFile::Error)
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:550:in `new'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:550:in `gunzip'
from /usr/lib/ruby/site_ruby/1.8/rubygems/remote_fetcher.rb:177:in `fetch_path'
from /usr/lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb:270:in `load_specs'
from /usr/lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb:243:in `list'
from /usr/lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb:239:in `each'
from /usr/lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb:239:in `list'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:104:in `fetch_specs'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:117:in `fetch_all_remote_specs'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/fetcher.rb:262:in `fetch_all_remote_specs'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/fetcher.rb:116:in `specs'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:235:in `remote_specs'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:235:in `each'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:235:in `remote_specs'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:163:in `fetch_specs'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:67:in `specs'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/definition.rb:192:in `index'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/definition.rb:189:in `each'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/definition.rb:189:in `index'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/index.rb:9:in `build'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/definition.rb:185:in `index'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/definition.rb:179:in `resolve'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/definition.rb:109:in `resolve_remotely!'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/installer.rb:83:in `run'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/installer.rb:14:in `install'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/cli.rb:320:in `update'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `__send__'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `run'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/vendor/thor.rb:344:in `dispatch'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/vendor/thor/base.rb:434:in `start'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/bin/bundle:20
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors'
from /usr/lib64/ruby/gems/1.8/gems/bundler-1.3.5/bin/bundle:20
from /usr/bin/bundle:19:in `load'
from /usr/bin/bundle:19
Hope this information will be enough for providing me the right way for solution
I have a ruby web- / data-server application which is built on a Sinatra foundation. I'm adding EventMachine and em-websocket so that I can have async data transfer connections.
#! /usr/bin/env ruby
require 'yajl'
require 'json'
require 'em-websocket'
require 'sinatra/base'
require 'thin'
require './Actors/DataProvider.rb'
my_host = '10.2.56.87'
my_web_port = '4004'
my_web_sock = '8008'
EventMachine.epoll # choose kernel epoll over select for deterministic execution under load
EventMachine.run do
class SinatraApp < Sinatra::Base
configure do
set :bind, '10.2.56.87'
set :port, '4004'
end
encoder = Yajl::Encoder.new
communicator = DataProvider.new( encoder )
get '/' do
redirect '/index-work.html'
end
before do
content_type 'application/json'
end
post '/auth' do
end
post '/data/:id' do
puts 'got d i '
end
end
EventMachine::WebSocket.start( :host => my_host, :port => my_web_sock ) do | ws |
ws.onopen do
end
ws.onmessage do
end
ws.onclose do
end
end
begin
SinatraApp.run!
rescue => ex
puts "#{ ex.class}: #{ ex.message }"
end
end
The Thin server worked fine when just serving Sinatra, but now that I've added the EM foundation the following occurs:
/usr/local/rvm/gems/ruby-1.9.3-p286/gems/thin-2.0.0.pre/lib/thin/server.rb:192:in `block (2 levels) in start': undefined method `attach_server' for EventMachine:Module (NoMethodError)
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/thin-2.0.0.pre/lib/thin/server.rb:191:in `each'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/thin-2.0.0.pre/lib/thin/server.rb:191:in `block in start'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/thin-2.0.0.pre/lib/thin/backends/prefork.rb:30:in `block (2 levels) in start'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `call'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run_machine'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/thin-2.0.0.pre/lib/thin/backends/prefork.rb:23:in `block in start'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/preforker-0.1.1/lib/preforker/worker.rb:52:in `call'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/preforker-0.1.1/lib/preforker/worker.rb:52:in `work'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/preforker-0.1.1/lib/preforker.rb:129:in `block (2 levels) in spawn_missing_workers'
from (eval):6:in `block in fork'
from (eval):6:in `fork'
from (eval):6:in `fork'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/preforker-0.1.1/lib/preforker.rb:126:in `block in spawn_missing_workers'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/preforker-0.1.1/lib/preforker.rb:124:in `times'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/preforker-0.1.1/lib/preforker.rb:124:in `spawn_missing_workers'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/preforker-0.1.1/lib/preforker.rb:44:in `run'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/thin-2.0.0.pre/lib/thin/backends/prefork.rb:37:in `start'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/thin-2.0.0.pre/lib/thin/server.rb:187:in `start'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/handler/thin.rb:13:in `run'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/sinatra-1.3.3/lib/sinatra/base.rb:1350:in `run!'
from /home/devel/ISF_Server/server-work.rb:122:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `call'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run_machine'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run'
from /home/devel/ISF_Server/server-work.rb:15:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/ruby-debug-ide-0.4.17.beta14/lib/ruby-debug-ide.rb:127:in `debug_load'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/ruby-debug-ide-0.4.17.beta14/lib/ruby-debug-ide.rb:127:in `debug_program'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/ruby-debug-ide-0.4.17.beta14/bin/rdebug-ide:118:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
I do notice that the Thin gem was recently updated, but EM has not been. That's my next point of inquiry. Somebody else posted that Thin should not be run from within EM.run block, but the example I am building from had it this way.
Okay. I corresponded with Marc-Andre Cournoyer directly. He says, first, don't spawn This (through Sinatra) inside an EM.run block.
Secondly, the error is generated from Thin 2 (pre) which requires the EventMachine live Edition, or gem eventmachine-le.
Mo' bettah now. :D
So this is kind of baffling me as I can't quite figure out why it's happening. This only happens on my laptop (Ubuntu 11.04), and not elsewhere. I just seem to have something weird with the setup on this one computer.
I keep getting the following error when I run my specs:
be rake spec
Gives me:
NoMethodError: undefined method `belong_to' for #<RSpec::Core::ExampleGroup::Nested_4:0xb4eb2e4>
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-expectations-2.6.0/lib/rspec/matchers/method_missing.rb:9:in `method_missing'
/home/tom/work/ruby/litdistco-sales/spec/models/sales_item_spec.rb:5:in `block (2 levels) in <top (required)>'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:48:in `instance_eval'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:48:in `block in run'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:107:in `with_around_hooks'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:45:in `run'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:294:in `block in run_examples'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:290:in `map'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:290:in `run_examples'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:262:in `run'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in `block (2 levels) in run'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in `map'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in `block in run'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/reporter.rb:12:in `report'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:21:in `run'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in `run'
/home/tom/.rvm/gems/ruby-1.9.2-p290#litdistco/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun'
Here are the relevant lines from my spec file that generates the complaint:
describe SalesItem do
it { should belong_to(:publisher) }
it { should belong_to(:invoice) }
I'm running Rails 3.1.0. Here is ruby -v:
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
Any tips /thoughts/ideas recommendations greatly appreciated.
Try adding this in your rails_helper.rb
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end
RSpec core does not have such matcher. It looks like shoulda-matchers. Just make sure that it's installed and loaded in your spec_helper
I was having a hard time with this for awhile and then changed my spec from:
describe ModelName do
it { should belong_to(:model)}
end
to:
RSpec.describe ModelName, type: :model do
it { should belong_to(:model)}
end
and it suddenly worked
You can write specs like this
describe SalesItem do
describe "Associations" do
it "belongs_to publisher" do
assc = described_class.reflect_on_association(:publisher)
expect(assc.macro).to eq :belongs_to
end
end
end
I found the following problem to use net/sftp:
undefined method `put_file' for #<Net::SFTP::Session:0x00000001b40298>
(NoMethodError)
sftp.rb:17:in `block in <main>': undefined method `put_file' for #<Net::SFTP::Session:0x00000000b70138> (NoMethodError)
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:939:in `call'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:939:in `block in do_version'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:939:in `each'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:939:in `do_version'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:909:in `when_channel_polled'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/channel.rb:311:in `call'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/channel.rb:311:in `process'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/session.rb:214:in `block in preprocess'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/session.rb:214:in `each'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/session.rb:214:in `preprocess'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/session.rb:197:in `process'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/session.rb:161:in `block in loop'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/session.rb:161:in `loop'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/session.rb:161:in `loop'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:802:in `loop'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:787:in `connect!'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/net-sftp-2.0.5/lib/net/sftp.rb:32:in `start'
from sftp.rb:16:in `<main>'
But the module could be loaded without problem:
2011.07.08|17:12:07~/lin/Ruby>irb
irb(main):001:0> require 'net/ssh'
=> true
irb(main):002:0> require 'net/sftp'
=> true
irb(main):003:0>
By the way, my RUBYLIB is:
2011.07.08|17:15:33~/lin/Ruby>echo $RUBYLIB
/opt/ruby/lib/ruby/1.9.1/
Thanks!
Dan
P.S:
require 'net/ssh'
require 'net/sftp'
host="localhost"
src_file="/etc/services"
dst_file="~/services"
Net::SFTP.start(host, ENV["USER"]) do |sftp|
sftp.put_file(src_file, dst_file)
end
......
Net::SFTP does not have a put_file method. See the full documentation for Net::SFTP.
Did you perhaps mean sftp.upload or sftp.upload!?
Check your version. Net::SFTP 2 doesn't have put_file anymore. Use upload instead.