spec/models/attachy/viewer/value_spec.rb in attachy-0.1.2 vs spec/models/attachy/viewer/value_spec.rb in attachy-0.2.0
- old
+ new
@@ -1,19 +1,21 @@
+# frozen_string_literal: true
+
require 'rails_helper'
RSpec.describe Attachy::Viewer, '.value' do
let!(:object) { create :user }
before { allow(Cloudinary::Uploader).to receive(:remove_tag) }
context 'when has one result' do
context 'as attachament' do
+ subject { described_class.new method, object }
+
let!(:method) { :avatar }
let!(:file) { create :file, attachable: object, scope: method }
- subject { described_class.new method, object }
-
context 'and it is not default' do
let!(:default) { Attachy::File.new public_id: 0 }
before do
allow(Attachy::File).to receive(:default) { default }
@@ -36,15 +38,15 @@
end
end
end
context 'as attachaments' do
+ subject { described_class.new method, object }
+
let!(:method) { :photos }
let!(:file) { create :file, attachable: object, scope: method }
- subject { described_class.new method, object }
-
context 'and it is not default' do
let!(:default) { Attachy::File.new public_id: 0 }
before do
allow(Attachy::File).to receive(:default) { default }
@@ -68,14 +70,14 @@
end
end
end
context 'when has more than one result' do
+ subject { described_class.new method, object }
+
let!(:method) { :photos }
let!(:file_1) { create :file, attachable: object, scope: :photos }
let!(:file_2) { create :file, attachable: object, scope: :photos }
-
- subject { described_class.new method, object }
it 'is represented as json' do
expect(subject.value).to eq [file_1, file_2].to_json
end
end