28 Feb '17, 8pm

Here's an easy way to test an uploaded file in @rspec. #ruby #rails #testing

I recently wrote a unit test for a bit of code that saves an uploaded file from a controller to the database before pushing it off to a job. I had an example file in spec/fixtures that I wanted to use. Throwing code at the wall, I came up with: # Does not work! file = File.new(Rails.root.join("spec/fixtures/filename.xlsx")) save_uploaded_file_to_db(file) Then, #save_uploaded_file_to_db gets the parts of the file that we care about, and saves it to the database. def save_uploaded_file_to_db(file) Upload.create( filename: File.basename(file.original_filename), content_type: file.content_type, data: file.read, ) end Looks pretty straightforward, but I got a NoMethodError when calling original_filename . Turns out, this method is unique to UploadedFile . That brought me to the question: “How can I have an uploaded file without uploading something?” I have the answer for you. W...

Full article: https://collectiveidea.com/blog/archives/2017/01/16/testi...

Tweets

Here's a status report on the latest version of...

everydayrails.com 20 Feb '17, 3pm

Status report: Everyday Rails Testing with RSpec for RSpec 3.5 and Rails 5 February 20, 2017 Hello friends, I wanted to gi...

Faster RSpec: Profiling FactoryGirl

rubyflow.com 20 Feb '17, 9am

× The Ruby and Rails community linklog Made a library? Written a blog post? Found a useful tutorial? Share it with the Rub...

Your Guide to testing in Ruby on Rails 5 { auth...

dev.to 06 Mar '17, 9pm

The last alternative I'll mention is the gem FactoryGirl. The default method of test objects within Rails is fixtures. Fix...

#wp_Dev #ajax #stackoverflow Ruby on rails live...

stackoverflow.com 28 Feb '17, 4pm

Okay, what i am looking for is a way to get an ajax script to run in the background of a page and look to see if there is ...

Beginning Ruby on Rails

landmatus.com 01 Mar '17, 1pm

Ruby on Rails is the revolutionary online programming tool that makes creating functional e-commerce web sites faster and ...

A new @pragprog RSpec 3 book has been in the words for 2 years. Today, we're happy to announce it's in beta:

A new @pragprog RSpec 3 book has been in the wo...

rspec.info 15 Feb '17, 6pm

Now in Beta: Effective Testing with RSpec 3 Myron Marston Feb 15, 2017 Six years ago, The RSpec Book introduced thousands ...

Ruby Web Apps Testing Survey

rubyflow.com 22 Feb '17, 7pm

× The Ruby and Rails community linklog Made a library? Written a blog post? Found a useful tutorial? Share it with the Rub...

Slicing up Rails Application.js for Faster Load Times

Slicing up Rails Application.js for Faster Load...

robots.thoughtbot.com 27 Feb '17, 12am

When using a fast device it’s easy to forget that page load times are impacted by not just network speed but processing po...

“Web Scraping With Ruby on Rails” by @yomieluwa...

medium.com 25 Feb '17, 6pm

Web Scraping With Ruby on Rails I had always wanted to learn how to code with Ruby on Rails and late last year (November),...

I just published “Web Scraping With Ruby on Rai...

medium.com 25 Feb '17, 6pm

Web Scraping With Ruby on Rails I had always wanted to learn how to code with Ruby on Rails and late last year (November),...