spec: bit less code duplication
This commit is contained in:
parent
fcdb640b9a
commit
6a7e8a3023
|
@ -3,13 +3,7 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe Ajax::AnswerController, type: :controller do
|
describe Ajax::AnswerController, :ajax_controller, type: :controller do
|
||||||
shared_examples "returns the expected response" do
|
|
||||||
it "returns the expected response" do
|
|
||||||
expect(JSON.parse(subject.body)).to match(expected_response)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:user) { FactoryBot.create(:user) }
|
let(:user) { FactoryBot.create(:user) }
|
||||||
let(:question) { FactoryBot.create(:question, user: FactoryBot.build(:user, privacy_allow_stranger_answers: asker_allows_strangers)) }
|
let(:question) { FactoryBot.create(:question, user: FactoryBot.build(:user, privacy_allow_stranger_answers: asker_allows_strangers)) }
|
||||||
let(:asker_allows_strangers) { true }
|
let(:asker_allows_strangers) { true }
|
||||||
|
|
|
@ -3,13 +3,7 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe Ajax::CommentController, type: :controller do
|
describe Ajax::CommentController, :ajax_controller, type: :controller do
|
||||||
shared_examples "returns the expected response" do
|
|
||||||
it "returns the expected response" do
|
|
||||||
expect(JSON.parse(subject.body)).to match(expected_response)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:user) { FactoryBot.create(:user) }
|
let(:user) { FactoryBot.create(:user) }
|
||||||
let(:answer) { FactoryBot.create(:answer, user: FactoryBot.create(:user)) }
|
let(:answer) { FactoryBot.create(:answer, user: FactoryBot.create(:user)) }
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,7 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe Ajax::SmileController, type: :controller do
|
describe Ajax::SmileController, :ajax_controller, type: :controller do
|
||||||
shared_examples "returns the expected response" do
|
|
||||||
it "returns the expected response" do
|
|
||||||
expect(JSON.parse(subject.body)).to match(expected_response)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:user) { FactoryBot.create(:user) }
|
let(:user) { FactoryBot.create(:user) }
|
||||||
|
|
||||||
describe "#create" do
|
describe "#create" do
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
RSpec.shared_context "AjaxController context" do
|
||||||
|
shared_examples "returns the expected response" do
|
||||||
|
it "returns the expected response" do
|
||||||
|
expect(JSON.parse(subject.body)).to match(expected_response)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
RSpec.configure do |c|
|
||||||
|
c.include_context "AjaxController context", ajax_controller: true
|
||||||
|
end
|
Loading…
Reference in New Issue