Skip to content
4 changes: 2 additions & 2 deletions .github/workflows/exercise-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
ruby-version: [3.2, 3.3]

steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd

- name: Set up Ruby
uses: ruby/setup-ruby@4c24fa5ec04b2e79eb40571b1cee2a0d2b705771
uses: ruby/setup-ruby@8d27f39a5e7ad39aebbcbd1324f7af020229645c
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/generator-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
name: Check Generator Templates
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set up Ruby
uses: ruby/setup-ruby@4c24fa5ec04b2e79eb40571b1cee2a0d2b705771
uses: ruby/setup-ruby@8d27f39a5e7ad39aebbcbd1324f7af020229645c
with:
ruby-version: "3.3"
bundler-cache: true
Expand All @@ -24,9 +24,9 @@ jobs:
name: Test Generator
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set up Ruby
uses: ruby/setup-ruby@4c24fa5ec04b2e79eb40571b1cee2a0d2b705771
uses: ruby/setup-ruby@8d27f39a5e7ad39aebbcbd1324f7af020229645c
with:
ruby-version: "3.3"
bundler-cache: true
Expand Down
6 changes: 3 additions & 3 deletions concepts/advanced-enumeration/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ fibonacci.none? { |number| number > 20 } #=> true
fibonacci.select { |number| number.odd? } #=> [1, 1, 3, 5, 13]
fibonacci.all? { |number| number < 20 } #=> true
fibonacci.map { |number| number * 2 } #=> [0, 2, 2, 4, 6, 10, 16, 26]
fibonacci.select { |number| number >= 5} #=> [5, 8, 13]
fibonacci.find { |number| number >= 5} #=> 5
fibonacci.select { |number| number >= 5 } #=> [5, 8, 13]
fibonacci.find { |number| number >= 5 } #=> 5

# Some methods work with or without a block
fibonacci.sum #=> 33
fibonacci.sum {| number | number * number } #=> 273
fibonacci.sum { |number| number * number } #=> 273

# There are also methods to help with nested arrays:
animals = [ ['cat', 'bob'], ['horse', 'caris'], ['mouse', 'arya'] ]
Expand Down
6 changes: 3 additions & 3 deletions concepts/advanced-enumeration/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ fibonacci.none? { |number| number > 20 } #=> true
fibonacci.select { |number| number.odd? } #=> [1, 1, 3, 5, 13]
fibonacci.all? { |number| number < 20 } #=> true
fibonacci.map { |number| number * 2 } #=> [0, 2, 2, 4, 6, 10, 16, 26]
fibonacci.select { |number| number >= 5} #=> [5, 8, 13]
fibonacci.find { |number| number >= 5} #=> 5
fibonacci.select { |number| number >= 5 } #=> [5, 8, 13]
fibonacci.find { |number| number >= 5 } #=> 5

# Some methods work with or without a block
fibonacci.sum #=> 33
fibonacci.sum {| number | number * number } #=> 273
fibonacci.sum { |number| number * number } #=> 273

# There are also methods to help with nested arrays:
animals = [ ['cat', 'bob'], ['horse', 'caris'], ['mouse', 'arya'] ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Instructions

You're continuing to work on the stock management system you built previously. Since discovering `OpenStruct` and block shortcuts, you've decided to refactor the code a little. Rather than storing the items as hashes, you're going to utilize your newfound skills.
You're continuing to work on the stock management system you built previously.
Since discovering `OpenStruct` and block shortcuts, you've decided to refactor the code a little.
Rather than storing the items as hashes, you're going to utilize your newfound skills.

## 1. Allow retrievable of items

Expand All @@ -24,7 +26,7 @@ inventory.items.size
# => 4
```

# 2. Refactor `item_names`
## 2. Refactor `item_names`

Refactor `item_names` to use the new block shortcut you've learnt rather than hashes.
As a reminder, the method should return:
Expand All @@ -40,11 +42,10 @@ BoutiqueInventory.new([
# => ["Bamboo Socks Cats", "Black Short Skirt", "Maxi Brown Dress", "Red Short Skirt"]
```

## 3. Refactor `total_stock`

# 2. Refactor `total_stock`

Refactor `total_stock` to use the openstruct's method, rather than referencing a hash.
As a reminder, the method should return::
Refactor `total_stock` to use the OpenStruct's method, rather than referencing a hash.
As a reminder, the method should return:

```ruby
BoutiqueInventory.new([
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/boutique-inventory/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ fibonacci.none? { |number| number > 20 } #=> true
fibonacci.select { |number| number.odd? } #=> [1, 1, 3, 5, 13]
fibonacci.all? { |number| number < 20 } #=> true
fibonacci.map { |number| number * 2 } #=> [0, 2, 2, 4, 6, 10, 16, 26]
fibonacci.select { |number| number >= 5} #=> [5, 8, 13]
fibonacci.find { |number| number >= 6} #=> 8
fibonacci.select { |number| number >= 5 } #=> [5, 8, 13]
fibonacci.find { |number| number >= 6 } #=> 8

# Some methods work with or without a block
fibonacci.sum #=> 33
fibonacci.sum {| number | number * number } #=> 273
fibonacci.sum { |number| number * number } #=> 273

# There are also methods to help with nested arrays:
animals = [ ['cat', 'bob'], ['horse', 'caris'], ['mouse', 'arya'] ]
Expand Down
3 changes: 2 additions & 1 deletion exercises/concept/moviegoer/moviegoer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def test_members_get_free_popcorn
end

def test_regular_moviegoers_dont_get_free_popcorn
assert_raises NotMovieClubMemberError do
expected_exception = Moviegoer.include?(NotMovieClubMemberError) ? Moviegoer::NotMovieClubMemberError : NotMovieClubMemberError
assert_raises expected_exception do
Moviegoer.new(25, member: false).claim_free_popcorn!
end
end
Expand Down
9 changes: 6 additions & 3 deletions exercises/concept/simple-calculator/simple_calculator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ def test_no_number_second_operand_raises_exception
end

def test_raises_exception_for_non_valid_operations
assert_raises(SimpleCalculator::UnsupportedOperation) { SimpleCalculator.calculate(1, 2, '**') }
expected_exception = SimpleCalculator.include?(UnsupportedOperation) ? SimpleCalculator::UnsupportedOperation : UnsupportedOperation
assert_raises(expected_exception) { SimpleCalculator.calculate(1, 2, '**') }
end

def test_raises_exception_when_operation_is_nil
assert_raises(SimpleCalculator::UnsupportedOperation) { SimpleCalculator.calculate(1, 2, nil) }
expected_exception = SimpleCalculator.include?(UnsupportedOperation) ? SimpleCalculator::UnsupportedOperation : UnsupportedOperation
assert_raises(expected_exception) { SimpleCalculator.calculate(1, 2, nil) }
end

def test_raises_exception_when_operation_is_an_empty_string
assert_raises(SimpleCalculator::UnsupportedOperation) { SimpleCalculator.calculate(1, 2, '') }
expected_exception = SimpleCalculator.include?(UnsupportedOperation) ? SimpleCalculator::UnsupportedOperation : UnsupportedOperation
assert_raises(expected_exception) { SimpleCalculator.calculate(1, 2, '') }
end
end
Loading