Skip to content

Commit

Permalink
Merge pull request telus-agcg#99 from syngenta/feat/add-description-s…
Browse files Browse the repository at this point in the history
…etter-to-major-object

feat: add description setter to MajorObject
  • Loading branch information
tindron authored May 9, 2024
2 parents 039dfca + 1af87e5 commit 297dba4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/gdal/major_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ def description
desc
end

# @param description [String]
# @return [String]
def description=(description)
FFI::GDAL::GDAL.GDALSetDescription(@c_pointer, description)
end

def null?
@c_pointer.null?
end
Expand Down
31 changes: 29 additions & 2 deletions spec/unit/gdal/major_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,34 @@
require "gdal/major_object"

RSpec.describe GDAL::MajorObject do
subject { Object.new.extend(described_class) }
subject { band.extend(described_class) }

pending "Add some tests!"
let(:driver) { GDAL::Driver.by_name("GTiff") }
let(:dataset) { driver.create_dataset("/vsimem/test-#{SecureRandom.uuid}.tif", 1, 1) }
let(:band) { dataset.raster_band(1) }
after { dataset.close }

describe "#description" do
context "when the object has no description" do
it "returns an empty string" do
expect(subject.description).to eq("")
end
end

context "when the object has a description" do
before { subject.description = "This is a description" }

it "returns the description of the object" do
expect(subject.description).to eq("This is a description")
end
end
end

describe "#description=" do
it "sets the description of the object" do
expect(subject.description).to eq("")
subject.description = "This is a description"
expect(subject.description).to eq("This is a description")
end
end
end

0 comments on commit 297dba4

Please sign in to comment.