Created
September 12, 2014 18:52
-
-
Save davidpaulhunt/39900fb08af492604cc1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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