Skip to content

Commit

Permalink
Manual corrections, mostly RSpec. TODO now under 100 lines, good enough
Browse files Browse the repository at this point in the history
  • Loading branch information
atz committed Sep 27, 2018
1 parent d91b0bd commit 1614c8f
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 52 deletions.
29 changes: 0 additions & 29 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,51 +76,22 @@ RSpec/ExampleLength:
Exclude:
- 'spec/lib/pre_assembly/bundle_spec.rb'

# Offense count: 1
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Exclude:
- 'spec/lib/pre_assembly/object_file_spec.rb'

# Offense count: 2
RSpec/LetSetup:
Exclude:
- 'spec/views/bundle_contexts/new.html.erb_spec.rb'
- 'spec/views/job_runs/index.json.jbuilder_spec.rb'

# Offense count: 1
# Configuration parameters: AggregateFailuresByDefault.
RSpec/MultipleExpectations:
Max: 7

# Offense count: 1
RSpec/NamedSubject:
Exclude:
- 'spec/controllers/bundle_contexts_controller_spec.rb'

# Offense count: 10
RSpec/SubjectStub:
Exclude:
- 'spec/models/bundle_context_spec.rb'
- 'spec/services/discovery_report_spec.rb'

# Offense count: 4
# Configuration parameters: IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
- 'spec/lib/pre_assembly/bundle_spec.rb'
- 'spec/models/job_run_spec.rb'

# Offense count: 1
Style/ClassVars:
Exclude:
- 'app/lib/pre_assembly/logging.rb'

# Offense count: 6
Style/CommentedKeyword:
Exclude:
- 'app/lib/pre_assembly/smpl.rb'

# Offense count: 19
Style/Documentation:
Enabled: false
8 changes: 4 additions & 4 deletions app/lib/pre_assembly/smpl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ def generate_cm(druid)
xml.checksum(checksum, type: 'md5') if checksum && checksum != ''
end
end
end # end resource
end # end loop over resources
end # end CM tag
end # end XML tag
end
end
end
end
FileUtils.cd(current_directory)
builder.to_xml
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/bundle_contexts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
before { sign_in(create(:user)) }

it 'has current_user' do
expect(subject.current_user).not_to be_nil
expect(controller.current_user).not_to be_nil
end

context 'GET new' do
Expand Down
12 changes: 6 additions & 6 deletions spec/lib/pre_assembly/bundle_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
let(:exp_workflow_svc_url) { Regexp.new("^#{Dor::Config.dor_services.url}/objects/.*/apo_workflows/assemblyWF$") }

before do
allow(RestClient).to receive(:post).with(a_string_matching(exp_workflow_svc_url), {}).and_return(instance_double(RestClient::Response, code: 200))
allow(RestClient).to receive(:post)
.with(a_string_matching(exp_workflow_svc_url), {})
.and_return(instance_double(RestClient::Response, code: 200))
allow(Dor::Item).to receive(:find).with(any_args)
end

Expand All @@ -19,9 +21,7 @@
bc.save
b = described_class.new bc
pids = []
expect do
pids = b.run_pre_assembly
end.not_to raise_error
expect { pids = b.run_pre_assembly }.not_to raise_error
expect(pids).to eq ['druid:jy812bp9403', 'druid:tz250tk7584', 'druid:gn330dv6119']
end
end
Expand All @@ -44,7 +44,7 @@
describe '#processed_pids' do
it 'pulls pids from digital_objects' do
exp_pids = [11, 22, 33]
flat_dir_images.digital_objects = exp_pids.map { |p| double('dobj', pid: p) }
flat_dir_images.digital_objects = exp_pids.map { |p| instance_double(PreAssembly::DigitalObject, pid: p) }
expect(flat_dir_images.processed_pids).to eq(exp_pids)
end
end
Expand Down Expand Up @@ -112,7 +112,7 @@
describe 'object discovery: other' do
it 'is able to exercise all_object_files()' do
fake_files = [[1, 2], [3, 4], [5, 6]]
fake_dobjs = fake_files.map { |fs| double('dobj', object_files: fs) }
fake_dobjs = fake_files.map { |fs| instance_double(PreAssembly::DigitalObject, object_files: fs) }
flat_dir_images.digital_objects = fake_dobjs
expect(flat_dir_images.all_object_files).to eq(fake_files.flatten)
end
Expand Down
8 changes: 2 additions & 6 deletions spec/lib/pre_assembly/object_file_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
RSpec.describe PreAssembly::ObjectFile do
before do
@f = described_class.new(
path: 'spec/test_data/flat_dir_images/image1.tif'
)
end
let(:object_file) { described_class.new(path: 'spec/test_data/flat_dir_images/image1.tif') }

describe 'initialization' do
it 'can initialize an ObjectFile' do
expect(@f).to be_kind_of described_class
expect(object_file).to be_a(described_class) # useless test ("Does Ruby Work??")
end
end
end
4 changes: 2 additions & 2 deletions spec/models/job_run_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
end

describe 'send_notification' do
let(:mock_mailer) { double JobMailer }
let(:mock_delivery) { double ActionMailer::MessageDelivery }
let(:mock_mailer) { instance_double JobMailer }
let(:mock_delivery) { instance_double ActionMailer::MessageDelivery }

before { job_run.save }

Expand Down
4 changes: 2 additions & 2 deletions spec/views/bundle_contexts/new.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
RSpec.describe 'bundle_contexts/new.html.erb', type: :view do
let!(:job_runs) { create_list(:job_run, 2) }
let(:job_runs) { create_list(:job_run, 2) }

it 'displays a list of job_runs in side panel' do
assign(:bundle_context, BundleContext.new)
assign(:job_runs, JobRun.all.page(1))
assign(:job_runs, job_runs)
render
expect(rendered).to include('<tbody id="job-history-table">') # the element we will render into
expect(rendered).to include('<script type="text/x-tmpl" id="tmpl-job-history-table">') # the JS template that will be used
Expand Down
4 changes: 2 additions & 2 deletions spec/views/job_runs/index.json.jbuilder_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
RSpec.describe 'job_runs/index.json.jbuilder' do
let!(:job_runs) { create_list(:job_run, 2) }
let(:job_runs) { create_list(:job_run, 2) }

it 'renders a list of job_runs' do
assign(:job_runs, JobRun.all.page(1))
assign(:job_runs, job_runs)
render
json = JSON.parse(rendered)
expect(json.class).to eq Array
Expand Down

0 comments on commit 1614c8f

Please sign in to comment.