Uninitialized constant Twitter: Rails RSpec Twitter example in README.md

346 views
Skip to first unread message

Simon Males

unread,
Sep 20, 2014, 7:50:29 AM9/20/14
to ruby-...@googlegroups.com
Hello,

I'm following the README.md example and I'm failing to get RSpec to see the Twitter constant in app/api/twitter/api.rb

$ rspec spec/requests/twitter_spec.rb
spec/requests/twitter_spec.rb:1:in `<top (required)>': uninitialized constant Twitter (NameError)

But it seems to load in Routes:

$ rake routes
     Prefix Verb URI Pattern Controller#Action
twitter_api      /           Twitter::API


--
Simon Males

Daniel Doubrovkine

unread,
Sep 20, 2014, 2:45:11 PM9/20/14
to ruby-...@googlegroups.com
You should have a file called api.rb somewhere in the autoload path that contains module Twitter, class API < Grape::API. 

I would love a sample app on Github that basically has this implementation, if you upload that I am happy to help fix.


--
You received this message because you are subscribed to the Google Groups "Grape Framework Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-grape+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

dB. | Moscow - Geneva - Seattle - New York
code.dblock.org - @dblockdotorg - artsy.net - github/dblock

Simon Males

unread,
Sep 21, 2014, 10:24:47 AM9/21/14
to ruby-grape
I started a new project from scratch and followed the README. So no more Uninitialized constant errors.

Though the first test fails due to an routing error, do I need to do anything else other mount Twitter::API in routes.rb?
Simon Males

Daniel Doubrovkine

unread,
Sep 25, 2014, 8:41:45 AM9/25/14
to ruby-...@googlegroups.com
https://github.com/sime/grape-rails-rspec/pull/1

It's just the routes were not matching.

Can you please check the Grape README and update it? I suspect we say one thing for the API and another for example tests.

Simon Males

unread,
Sep 26, 2014, 2:45:54 PM9/26/14
to ruby-grape
Yes, API and the tests don't match up.

Daniel Doubrovkine

unread,
Sep 26, 2014, 4:03:19 PM9/26/14
to ruby-...@googlegroups.com
Looking forward to a PR, please!
Reply all
Reply to author
Forward
0 new messages