-
-
Save pd/4495802 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p read_window_layout/features/support | |
curl https://gist.github.com/raw/4495802/9d28d175fc1808e86e29248df793c01460cf7119/read-layout.feature > read_window_layout/features/read-layout.feature | |
curl https://gist.github.com/raw/4495802/ba67bac9506bda4522883f19c118fef23604db9e/features-support-env.rb > read_window_layout/features/support/env.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_layout(string) | |
# Dumbest implementation | |
rows = string.split("\n").select { |s| s.start_with?('|') } | |
[:rows] + rows.map { |s| [:cols] + s.split(/[ |]+/).reject { |c| c == '' } } | |
end | |
When 'I read the window layout:' do |s| | |
@layout = read_layout(s.to_s) | |
end | |
Then 'the layout should be $struct' do |structure| | |
structure.gsub!('(', '[') | |
structure.gsub!(')', ']') | |
structure.gsub!('] ', '], ') | |
structure.gsub!(/(rows|cols) /, ':\1, ') | |
structure.gsub!('" ', '", ') | |
@layout.should == eval(structure) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Reading window layouts | |
Scenario: one window | |
When I read the window layout: | |
""" | |
+---+ | |
| A | | |
+---+ | |
""" | |
Then the layout should be (rows (cols "A")) | |
Scenario: A|B | |
When I read the window layout: | |
""" | |
+---+---+ | |
| A | B | | |
+---+---+ | |
""" | |
Then the layout should be (rows (cols "A" "B")) | |
Scenario: A|B--C | |
When I read the window layout: | |
""" | |
+---+---+ | |
| A | B | | |
+-------+ | |
| C | | |
+-------+ | |
""" | |
Then the layout should be (rows (cols "A" "B") (cols "C")) | |
Scenario: A|B--C|D | |
When I read the window layout: | |
""" | |
+---+---+ | |
| A | B | | |
+-------+ | |
| C | D | | |
+-------+ | |
""" | |
Then the layout should be (rows (cols "A" "B") (cols "C" "D")) | |
Scenario: 3 rows | |
When I read the window layout: | |
""" | |
+---+ | |
| A | | |
+---+ | |
| B | | |
+---+ | |
| C | | |
+---+ | |
""" | |
Then the layout should be (rows (cols "A") (cols "B") (cols "C")) | |
Scenario: Inner horizontal split | |
When I read the window layout: | |
""" | |
+---+---+ | |
| A | | | |
+---+ B | | |
| F | | | |
+---+---+ | |
| C | | |
+-------+ | |
| D | E | | |
+---+---+ | |
""" | |
Then the layout should be (rows (cols (rows "A" "F") "B") (cols "C") (cols "D" "E")) | |
Scenario: Inner vertical split | |
When I read the window layout: | |
""" | |
+---+---+---+ | |
| | B | C | | |
| A +---+---+ | |
| | D | | |
+---+---+---+ | |
| E | | |
+-----------+ | |
""" | |
Then the layout should be (rows (cols "A" (rows (cols "B" "C") (cols "D"))) (cols "E")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment