Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Inline variable

#2

To increase reduce complexity for my code As a multi-variable programmer I want to inline a variable on its scope

Scenario: Invalid Selection
    Given a text "dirname = File.dirname '/tmp/file.txt'; puts dirname; dirname + 'my_other_file.txt'"
    And I selected "irname"
    When I ask for refactoring options
    Then I should not be able to "Inline Variable"

Scenario: Valid Selection
    Given a text "dirname = File.dirname '/tmp/file.txt'; puts dirname; dirname + 'my_other_file.txt'"
    And I selected "dirname"
    When I ask for refactoring options
    Then I should be able to "Inline Variable"

Scenario: Inlining a variable once
    Given a text "dirname = File.dirname '/tmp/file.txt'; puts dirname; File.dirname('/tmp/file.txt') + 'my_other_file.txt'"
    And I selected "dirname"
    When I run "Inline Variable"
    Then I should get "puts File.dirname '/tmp/file.txt'; File.dirname('/tmp/file.txt') + 'my_other_file.txt'"

Scenario: Inlining a variable more than once equally
    Given a text "dirname = File.dirname '/tmp/file.txt'; puts dirname; dirname"
    And I selected "dirname"
    When I run "Inline Variable"
    Then I should get "puts File.dirname '/tmp/file.txt'; File.dirname '/tmp/file.txt'"

Scenario: Inlining a variable more than once keeping code sexy
    Given a text "dirname = File.dirname '/tmp/file.txt'; puts dirname; dirname + '/other_file.txt'"
    And I selected "dirname"
    When I run "Inline Variable"
    Then I should get "puts File.dirname '/tmp/file.txt'; File.dirname('/tmp/file.txt') + '/other_file.txt'"

Scenario: Inlining a variable more according to scope (not invading smaller scope)
    Given a text "dirname = File.dirname '/tmp/file.txt'; variable = lambda {|dirname| puts dirname}; dirname + '/other_file.txt'"
    And I selected "dirname"
    When I run "Inline Variable"
    Then I should get "variable = lambda {|dirname| puts dirname}; File.dirname('/tmp/file.txt') + '/other_file.txt'"

Scenario: Inlining a variable more according to scope (not invading bigger scope)
    Given a text "def method\ndirname = File.dirname '/tmp/file.txt'; puts dirname; dirname + '/other_file.txt'\nend\ndef other_method\ndirname = 'a'\nend"
    And I selected "dirname"
    When I run "Inline Variable"
    Given a text "def method\n puts File.dirname '/tmp/file.txt'; File.dirname('/tmp/file.txt') + '/other_file.txt'\nend\ndef other_method\ndirname = 'a'\nend"

Reported by Hugo Corbucci · March 26th, 2009 @ 04:27 PM

State: new
Milestone: none
Assigned to: Fabio Kung Fabio Kung

Activity

No comments yet.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.