08 Mar 2012, 21:33
Twitter_picture_pragsmall

Charles Feduke (8 posts)

Was butting up against Twitter’s rate limit while running rspec spec:

1) CompanyController GET 'index' should be successful
 Failure/Error: get 'index'
 Twitter::BadRequest:
   GET https://api.twitter.com/1/statuses/user_timeline.json?count=20&screen_name=cfeduke: 400: Rate limit exceeded. Clients may not make more than 150 requests per hour.

Fixed by adding:

Twitter.stub(:user_timeline) { [ ] }

above line 15 of company_controller_spec.rb.

09 Mar 2012, 16:18
Jruby-conf-profile-mug_pragsmall

Joe Kutner (81 posts)

Great suggestion. thanks!

05 Apr 2012, 16:46
Generic-user-small

Joe Van Dyk (17 posts)

I think VCR would be a better solution.

09 May 2013, 14:36
Generic-user-small

Owen Murphy (11 posts)

I needed to comment out the added line before rspec would complete successfully.

$ rspec spec/
F......

Failures:

  1) CompanyController GET 'index' should be successful
     Failure/Error: Twitter.stub(:user_timeline) { [ ] }
     NameError:
       uninitialized constant Twitter
     # ./spec/controllers/company_controller_spec.rb:15:in `(root)'

Finished in 0.594 seconds
7 examples, 1 failure

Failed examples:

rspec ./spec/controllers/company_controller_spec.rb:14 # CompanyController GET 'index' should be successful

Commenting out the line in ‘company_controller_spec.rb’ makes my world a better place.

$ rspec spec/
.......

Finished in 0.685 seconds
7 examples, 0 failures
  You must be logged in to comment