Skip to content

Instantly share code, notes, and snippets.

@MaryKuz
Created March 28, 2019 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaryKuz/b38d06dac256e41cd42e876b37975720 to your computer and use it in GitHub Desktop.
Save MaryKuz/b38d06dac256e41cd42e876b37975720 to your computer and use it in GitHub Desktop.
Write tests for the decorator
require 'rails_helper'
describe ProductDecorator do
describe '#as_json' do
let(:product) { stub_model Product, id: 1, name: 'apple', price: 10.0, description: 'green' }
subject { product.decorate.as_json }
its([:id]) { should eq 1 }
its([:name]) { should eq 'apple' }
its([:price]) { should eq 10.0 }
its([:description]) { should eq 'green' }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment