Skip to content

Commit

Permalink
Fix bug in spec (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
gangelo authored Aug 24, 2022
1 parent e160e57 commit b545193
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 0.2.3
* Bug fix
* Fix bug in specs that failed to add criteria for passing tests (e.g. ".to eq true/false") so tests could not fail.

### 0.2.2
* Changes
* Restructure modules under lib/immutable_structure_ex folder.
Expand Down
2 changes: 1 addition & 1 deletion lib/immutable_struct_ex/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ImmutableStructEx
VERSION = '0.2.2'
VERSION = '0.2.3'
end
14 changes: 5 additions & 9 deletions spec/immutable_struct_ex_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,24 @@
end

describe '#[]=' do
it 'undefines :[]=' do
expect(subject.respond_to?(:[]=)).to eq false
it 'overrides :[]= and raises an error if used' do
expect { subject[:key1] = :boom! }.to raise_error NoMethodError
end
end

describe '#[]' do
it 'can be accessed using :[]' do
expect(hash.keys.each.all? { |key, value| subject[key] == value })
expect(hash.all? { |key, value| subject[key] == value }).to eq true
end
end

describe 'getters/setters' do
it 'defines getters from the hash keys' do
expect(hash.keys.all? { |key| subject.respond_to? key })
expect(hash.keys.all? { |key| subject.respond_to? key }).to eq true
end

it 'undefines setters created from the hash keys' do
expect(hash.keys.none? { |key| subject.respond_to? :"#{key}=" })
end

it 'sets the values using the setters' do
expect(hash.keys.each.all? { |key, value| subject.public_send(key) == value })
expect(hash.keys.none? { |key| subject.respond_to? :"#{key}=" }).to eq true
end
end

Expand Down

0 comments on commit b545193

Please sign in to comment.