|
1 | 1 | require "rails_helper" |
2 | 2 |
|
3 | 3 | RSpec.describe "/casa_cases/:casa_case_id/court_dates/:id", type: :request do |
| 4 | + include DownloadHelpers |
4 | 5 | let(:admin) { create(:casa_admin) } |
5 | 6 | let(:casa_case) { court_date.casa_case } |
6 | 7 | let(:court_date) { create(:court_date) } |
|
66 | 67 | it "displays the court date" do |
67 | 68 | show |
68 | 69 |
|
69 | | - document_inspector = DocxInspector.new(docx_contents: response.body) |
| 70 | + docx_response = Docx::Document.open(StringIO.new(response.body)) |
70 | 71 |
|
71 | | - expect(document_inspector.word_list_document_contains?("December 25, 2020")).to eq(true) |
| 72 | + expect(docx_response.paragraphs.map(&:to_s)).to include(/December 25, 2020/) |
72 | 73 | end |
73 | 74 |
|
74 | 75 | context "when a judge is attached" do |
|
78 | 79 | it "includes the judge's name in the document" do |
79 | 80 | show |
80 | 81 |
|
81 | | - document_inspector = DocxInspector.new(docx_contents: response.body) |
| 82 | + docx_response = Docx::Document.open(StringIO.new(response.body)) |
| 83 | + |
| 84 | + expect(docx_response.paragraphs.map(&:to_s)).to include(/#{judge.name}/) |
82 | 85 |
|
83 | | - expect(document_inspector.word_list_document_contains?(judge.name)).to eq(true) |
84 | 86 | end |
85 | 87 | end |
86 | 88 |
|
|
91 | 93 | it "includes None for the judge's name in the document" do |
92 | 94 | show |
93 | 95 |
|
94 | | - document_inspector = DocxInspector.new(docx_contents: response.body) |
| 96 | + docx_response = Docx::Document.open(StringIO.new(response.body)) |
95 | 97 |
|
96 | | - expect(document_inspector.word_list_document_contains?(judge.name)).to eq(false) |
97 | | - expect(document_inspector.word_list_document_contains?("Judge:")).to eq(true) # Judge: None |
98 | | - expect(document_inspector.word_list_document_contains?("None")).to eq(true) |
| 98 | + expect(docx_response.paragraphs.map(&:to_s)).not_to include(/#{judge.name}/) |
| 99 | + expect(docx_response.paragraphs.map(&:to_s)).to include(/Judge\:/) |
| 100 | + expect(docx_response.paragraphs.map(&:to_s)).to include(/None/) |
99 | 101 | end |
100 | 102 | end |
101 | 103 |
|
|
106 | 108 | it "includes the hearing type in the document" do |
107 | 109 | show |
108 | 110 |
|
109 | | - document_inspector = DocxInspector.new(docx_contents: response.body) |
| 111 | + docx_response = Docx::Document.open(StringIO.new(response.body)) |
110 | 112 |
|
111 | | - expect(document_inspector.word_list_document_contains?(hearing_type.name)).to eq(true) |
| 113 | + expect(docx_response.paragraphs.map(&:to_s)).to include(/#{hearing_type.name}/) |
112 | 114 | end |
113 | 115 | end |
114 | 116 |
|
|
119 | 121 | it "includes None for the hearing type in the document" do |
120 | 122 | show |
121 | 123 |
|
122 | | - document_inspector = DocxInspector.new(docx_contents: response.body) |
| 124 | + docx_response = Docx::Document.open(StringIO.new(response.body)) |
123 | 125 |
|
124 | | - expect(document_inspector.word_list_document_contains?(hearing_type.name)).to eq(false) |
125 | | - expect(document_inspector.word_list_document_contains?("Hearing Type:")).to eq(true) # Hearing Type: None |
126 | | - expect(document_inspector.word_list_document_contains?("None")).to eq(true) |
| 126 | + expect(docx_response.paragraphs.map(&:to_s)).not_to include(/#{hearing_type.name}/) |
| 127 | + expect(docx_response.paragraphs.map(&:to_s)).to include(/Hearing Type\:/) |
| 128 | + expect(docx_response.paragraphs.map(&:to_s)).to include(/None/) |
127 | 129 | end |
128 | 130 | end |
129 | 131 |
|
|
134 | 136 | it "includes court order info" do |
135 | 137 | show |
136 | 138 |
|
137 | | - document_inspector = DocxInspector.new(docx_contents: response.body) |
| 139 | + docx_response = Docx::Document.open(StringIO.new(response.body)) |
138 | 140 |
|
139 | | - expect(document_inspector.word_list_document_contains?("Court Orders:")).to eq(true) # Court Orders: |
140 | | - expect(document_inspector.word_list_document_contains?(court_date.case_court_orders.first.text)).to eq(true) |
141 | | - expect(document_inspector.word_list_document_contains?(court_date.case_court_orders.first.implementation_status.humanize)).to eq(true) |
| 141 | + expect(docx_response.paragraphs.map(&:to_s)).to include(/Court Orders/) |
| 142 | + expect(table_text(docx_response)).to include(/#{court_date.case_court_orders.first.text}/) |
| 143 | + expect(table_text(docx_response)).to include(/#{court_date.case_court_orders.first.implementation_status.humanize}/) |
142 | 144 | end |
143 | 145 | end |
144 | 146 |
|
|
149 | 151 | it "does not include court orders section" do |
150 | 152 | show |
151 | 153 |
|
152 | | - document_inspector = DocxInspector.new(docx_contents: response.body) |
| 154 | + docx_response = Docx::Document.open(StringIO.new(response.body)) |
153 | 155 |
|
154 | | - expect(document_inspector.word_list_document_contains?("Court Orders:")).to eq(false) # Court Orders: |
| 156 | + expect(docx_response.paragraphs.map(&:to_s)).not_to include(/Court Orders/) |
155 | 157 | end |
156 | 158 | end |
157 | 159 | end |
|
0 commit comments