dotemacs

My Emacs configuration
git clone git://git.entf.net/dotemacs
Log | Files | Refs | LICENSE

ruby-mode-expansions.feature (5157B)


      1 Feature: ruby-mode expansions
      2   In order to quickly and precisely mark ruby code blocks
      3   As an Emacs user
      4   I want to expand to them
      5 
      6   Scenario: Mark instance variable
      7     Given I turn on ruby-mode
      8     When I insert:
      9     """
     10     class Bar
     11       def initialize
     12          @foo = 123
     13       end
     14     end
     15     """
     16     And I place the cursor before "@foo"
     17     And I press "C-@"
     18     Then the region should be "@foo"
     19 
     20   Scenario: Mark ruby block
     21     Given I turn on ruby-mode
     22     And there is no region selected
     23     When I insert:
     24     """
     25     module Bar
     26       something do
     27         foo
     28       end
     29     end
     30     """
     31     And I place the cursor after "something"
     32     And I press "C-@"
     33     And I press "C-@"
     34     Then the region should be:
     35     """
     36     something do
     37         foo
     38       end
     39 
     40     """
     41 
     42   Scenario: Mark ruby block from end
     43     Given I turn on ruby-mode
     44     And there is no region selected
     45     When I insert:
     46     """
     47     module Bar
     48       something do
     49         foo
     50       end
     51     end
     52     """
     53     And I place the cursor after "end"
     54     And I press "C-@"
     55     And I press "C-@"
     56     Then the region should be:
     57     """
     58     something do
     59         foo
     60       end
     61 
     62     """
     63 
     64   Scenario: Mark ruby block from within
     65     Given I turn on ruby-mode
     66     And there is no region selected
     67     When I insert:
     68     """
     69     module Bar
     70       something do
     71         foo
     72       end
     73     end
     74     """
     75     And I go to line "2"
     76     And I press "C-@"
     77     And I press "C-@"
     78     Then the region should be:
     79     """
     80     something do
     81         foo
     82       end
     83 
     84     """
     85 
     86   Scenario: Mark empty ruby block from within
     87     Given I turn on ruby-mode
     88     And there is no region selected
     89     When I insert:
     90     """
     91     module Bar
     92       something do
     93 
     94       end
     95     end
     96     """
     97     And I go to line "3"
     98     And I press "C-@"
     99     And I press "C-@"
    100     Then the region should be:
    101     """
    102     something do
    103 
    104       end
    105 
    106     """
    107 
    108   Scenario: Mark ruby block with using curly brackets
    109     Given I turn on ruby-mode
    110     And there is no region selected
    111     When I insert:
    112     """
    113     module Bar
    114       something {
    115         foo
    116       }
    117     end
    118     """
    119     And I go to line "3"
    120     And I press "C-@"
    121     And I press "C-@"
    122     And I press "C-@"
    123     Then the region should be:
    124     """
    125     something {
    126         foo
    127       }
    128 
    129     """
    130 
    131   Scenario: Mark ruby function at the beginning
    132     Given I turn on ruby-mode
    133     And there is no region selected
    134     When I insert:
    135     """
    136     module Bar
    137       def foo
    138         bar
    139       end
    140     end
    141     """
    142     And I go to word "def"
    143     And I press "C-@"
    144     And I press "C-@"
    145     Then the region should be:
    146     """
    147     def foo
    148         bar
    149       end
    150 
    151     """
    152 
    153   Scenario: Mark ruby function at definition
    154     Given I turn on ruby-mode
    155     And there is no region selected
    156     When I insert:
    157     """
    158     module Bar
    159       def foo
    160         bar
    161       end
    162     end
    163     """
    164     And I go to line "3"
    165     And I press "C-@"
    166     And I press "C-@"
    167     Then the region should be:
    168     """
    169     def foo
    170         bar
    171       end
    172 
    173     """
    174 
    175   Scenario: Mark ruby expand up 1 level
    176     Given I turn on ruby-mode
    177     And there is no region selected
    178     When I insert:
    179     """
    180     #comment foo
    181     module Bar
    182       def foo
    183         bar
    184       end
    185     end
    186 
    187     """
    188     And I go to line "3"
    189     And I press "C-@"
    190     And I press "C-@"
    191     And I press "C-@"
    192     Then the region should be:
    193     """
    194     module Bar
    195       def foo
    196         bar
    197       end
    198     end
    199 
    200     """
    201 
    202   Scenario: Mark ruby expand up 3 levels
    203     Given I turn on ruby-mode
    204     And there is no region selected
    205     When I insert:
    206     """
    207     #comment foo
    208     module Bar
    209 
    210       attr_reader :blah
    211 
    212       foo_arr.each do |element|
    213         blah {
    214           puts something
    215         }
    216       end
    217 
    218       def foo
    219         bar
    220       end
    221     end
    222 
    223     """
    224     And I go to line "8"
    225     And I press "C-@"
    226     And I press "C-@"
    227     And I press "C-@"
    228     And I press "C-@"
    229     And I press "C-@"
    230     And I press "C-@"
    231     Then the region should be:
    232     """
    233     module Bar
    234 
    235       attr_reader :blah
    236 
    237       foo_arr.each do |element|
    238         blah {
    239           puts something
    240         }
    241       end
    242 
    243       def foo
    244         bar
    245       end
    246     end
    247 
    248     """
    249 
    250   Scenario: Mark ruby expand heredoc
    251     Given I turn on ruby-mode
    252     And there is no region selected
    253     When I insert:
    254     """
    255     def foo
    256       blah(<<-end_block)
    257         CONTENT
    258       end_block
    259     end
    260     """
    261     And I place the cursor before "CONTENT"
    262     And I press "C-@"
    263     And I press "C-@"
    264     Then the region should be:
    265     """
    266         CONTENT
    267 
    268     """
    269 
    270   Scenario: Mark ruby expand to whole buffer
    271     Given I turn on ruby-mode
    272     And there is no region selected
    273     When I insert:
    274     """
    275     class Foo
    276       def blah
    277         [1,2,3].each do |num|
    278           puts num
    279         end
    280       end
    281     end
    282 
    283     #comment foo
    284     module Bar
    285       def foo
    286         bar
    287       end
    288     end
    289 
    290     """
    291     And I go to line "12"
    292     And I press "C-@"
    293     And I press "C-@"
    294     And I press "C-@"
    295     And I press "C-@"
    296     Then the region should be:
    297     """
    298     class Foo
    299       def blah
    300         [1,2,3].each do |num|
    301           puts num
    302         end
    303       end
    304     end
    305 
    306     #comment foo
    307     module Bar
    308       def foo
    309         bar
    310       end
    311     end
    312 
    313     """