Skip to content

Commit

Permalink
more descriptive steps for extract let
Browse files Browse the repository at this point in the history
  • Loading branch information
despo committed May 28, 2011
1 parent f6e1256 commit cd76a95
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 28 deletions.
28 changes: 24 additions & 4 deletions features/extract_let.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
Feature: Extract RSpec Let
Feature: Extract RSpec Let :RExtractLet
Take an assignment in an rspec specfication and convert it into a let declaration

Scenario: Extract to rspec let declaration
Given I have an rspec specification with an assignment
When I extract to rspec let
Then I see that there is now an rspec let declaration
Given I have the following code:
"""
describe "something" do
it "does stuff" do
bar = 10
bar.should == 10
end
end
"""
When I select the variable assignment and execute:
"""
:RExtractLet
"""
Then I should see:
"""
describe "something" do
let(:bar) { 10 }
it "does stuff" do
bar.should == 10
end
end
"""
30 changes: 6 additions & 24 deletions features/step_definitions/extract_let_steps.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
Given /^I have an rspec specification with an assignment$/ do
@input = <<-DOC
describe "something" do
it "does stuff" do
bar = 10
bar.should == 10
end
end
DOC
When /^I select the variable assignment and execute:$/ do |command|
select_variable_assignment
add_to_commands command
end

When /^I extract to rspec let$/ do
@commands = <<-DOC
:normal 3G
:RExtractLet
DOC
def select_variable_assignment
@commands = ':normal 3G'
add_return_key
end

Then /^I see that there is now an rspec let declaration$/ do
result_of_executing_the_commands.should == <<-DOC
describe "something" do
let(:bar) { 10 }
it "does stuff" do
bar.should == 10
end
end
DOC
end

0 comments on commit cd76a95

Please sign in to comment.