Skip to content

Instantly share code, notes, and snippets.

@davidpaulhunt
Created September 12, 2014 18:52
Show Gist options
  • Select an option

  • Save davidpaulhunt/39900fb08af492604cc1 to your computer and use it in GitHub Desktop.

Select an option

Save davidpaulhunt/39900fb08af492604cc1 to your computer and use it in GitHub Desktop.
require 'rails_helper'
RSpec.describe Recipe, :type => :model do
context 'validations' do
it 'should validate name' do
recipe = FactoryGirl.build_stubbed(:recipe)
expect(recipe).to be_valid
recipe.name = nil
expect(recipe).to be_invalid
end
it 'should validate ingredients' do
recipe = FactoryGirl.build_stubbed(:recipe)
expect(recipe).to be_valid
recipe.ingredients = nil
expect(recipe).to be_invalid
end
it 'should validate directions' do
recipe = FactoryGirl.build_stubbed(:recipe)
expect(recipe).to be_valid
recipe.directions = nil
expect(recipe).to be_invalid
end
end
context 'instance methods' do
it 'should return web preview from ImageUploader' do
recipe = FactoryGirl.create(:recipe_with_image)
url = recipe.list_image
expect(url.include?('web_preview')).to eq true
end
it 'should return an array' do
recipe = FactoryGirl.build_stubbed(:recipe_with_ingredients)
ings = recipe.ingredients_list
expect(ings.is_a?(Array)).to eq true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment