Skip to content

Commit

Permalink
renaming ruby-warrior directory to rubywarrior so it goes with gem name
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanb committed Jan 2, 2010
1 parent 5d78387 commit 3945748
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.rdoc
Expand Up @@ -9,7 +9,7 @@ NOTE: The player directory structure changed on July 18, 2009. If you have an ol

== Getting Started

Run the "rubywarrior" executable (contained in the bin directory) to setup your profile which will create a ruby-warrior directory in your current location. There you will find a player.rb file in your profile's directory which looks like this:
Run the "rubywarrior" executable (contained in the bin directory) to setup your profile which will create a rubywarrior directory in your current location. There you will find a player.rb file in your profile's directory which looks like this:

class Player
def play_turn(warrior)
Expand Down
28 changes: 14 additions & 14 deletions features/command_options.feature
@@ -1,46 +1,46 @@
Feature: Command Options
In order to play the game the way I want
As a player
I want to customize ruby-warrior with options
I want to customize rubywarrior with options

Background:
Given no profile at "tmp"

Scenario: Run ruby warrior in specified directory with -d option
Given a profile named "Joe" on "beginner"
When I copy fixture "walking_player.rb" to "tmp/ruby-warrior/joe-beginner/player.rb"
And I run rubywarrior with options "-d tmp/ruby-warrior/joe-beginner -t 0"
When I copy fixture "walking_player.rb" to "tmp/rubywarrior/joe-beginner/player.rb"
And I run rubywarrior with options "-d tmp/rubywarrior/joe-beginner -t 0"
And I answer "y" to "next level"
Then I should see "the updated README in the ruby-warrior/joe-beginner directory"
Then I should see "the updated README in the rubywarrior/joe-beginner directory"

Scenario: Skip user input with -s option
Given a profile named "Joe" on "beginner"
When I copy fixture "walking_player.rb" to "tmp/ruby-warrior/joe-beginner/player.rb"
And I run rubywarrior with options "-d tmp/ruby-warrior/joe-beginner -t 0 -s"
When I copy fixture "walking_player.rb" to "tmp/rubywarrior/joe-beginner/player.rb"
And I run rubywarrior with options "-d tmp/rubywarrior/joe-beginner -t 0 -s"
Then I should see "current level"
When I run rubywarrior with options "-d tmp/ruby-warrior/joe-beginner -t 0"
When I run rubywarrior with options "-d tmp/rubywarrior/joe-beginner -t 0"
And I answer "y" to "next level"
Then I should see "the updated README in the ruby-warrior/joe-beginner directory"
When I run rubywarrior with options "-d tmp/ruby-warrior/joe-beginner -t 0 -s"
Then I should see "the updated README in the rubywarrior/joe-beginner directory"
When I run rubywarrior with options "-d tmp/rubywarrior/joe-beginner -t 0 -s"
Then I should see "failed level 2"

Scenario: Unable to practice level if not epic
Given a profile named "Joe" on "beginner"
When I copy fixture "walking_player.rb" to "tmp/ruby-warrior/joe-beginner/player.rb"
And I run rubywarrior with options "-d tmp/ruby-warrior/joe-beginner -l 2"
When I copy fixture "walking_player.rb" to "tmp/rubywarrior/joe-beginner/player.rb"
And I run rubywarrior with options "-d tmp/rubywarrior/joe-beginner -l 2"
Then I should see "Unable"

Scenario: Practice specific level when epic
When I copy fixture "short-tower" to "towers/short"
Given a profile named "Bill" on "short"
When I copy fixture "walking_player.rb" to "tmp/ruby-warrior/bill-short/player.rb"
When I copy fixture "walking_player.rb" to "tmp/rubywarrior/bill-short/player.rb"
And I run rubywarrior
And I choose "Bill - short - level 1" for "profile"
Then I answer "y" to "next level"
And I should see "the updated README in the ruby-warrior/bill-short directory"
And I should see "the updated README in the rubywarrior/bill-short directory"
When I run rubywarrior
And I choose "Bill - short - level 2" for "profile"
Then I answer "y" to "epic"
And I should see "epic mode"
When I run rubywarrior with options "-d tmp/ruby-warrior/bill-short -l 2"
When I run rubywarrior with options "-d tmp/rubywarrior/bill-short -l 2"
Then I should not see "Level 1" before "Total Score: 17"
10 changes: 5 additions & 5 deletions features/levels.feature
Expand Up @@ -8,19 +8,19 @@ Feature: Play levels

Scenario: Pass first level, fail second level
Given a profile named "Joe" on "beginner"
When I copy fixture "walking_player.rb" to "tmp/ruby-warrior/joe-beginner/player.rb"
When I copy fixture "walking_player.rb" to "tmp/rubywarrior/joe-beginner/player.rb"
And I run rubywarrior
And I choose "Joe - beginner - level 1" for "profile"
And I answer "y" to "next level"
Then I should see "the updated README in the ruby-warrior/joe-beginner directory"
Then I should see "the updated README in the rubywarrior/joe-beginner directory"
When I run rubywarrior
And I choose "Joe - beginner - level 2" for "profile"
And I answer "y" to "clues"
Then I should see "warrior.feel.empty?"

Scenario: Retry first level
Given a profile named "Joe" on "beginner"
When I copy fixture "walking_player.rb" to "tmp/ruby-warrior/joe-beginner/player.rb"
When I copy fixture "walking_player.rb" to "tmp/rubywarrior/joe-beginner/player.rb"
And I run rubywarrior
And I choose "Joe - beginner - level 1" for "profile"
And I answer "n" to "next level"
Expand All @@ -32,11 +32,11 @@ Feature: Play levels
Scenario: Replay levels as epic when finishing last level with grades
When I copy fixture "short-tower" to "towers/short"
Given a profile named "Bill" on "short"
When I copy fixture "walking_player.rb" to "tmp/ruby-warrior/bill-short/player.rb"
When I copy fixture "walking_player.rb" to "tmp/rubywarrior/bill-short/player.rb"
And I run rubywarrior
And I choose "Bill - short - level 1" for "profile"
Then I answer "y" to "next level"
And I should see "the updated README in the ruby-warrior/bill-short directory"
And I should see "the updated README in the rubywarrior/bill-short directory"
When I run rubywarrior
And I choose "Bill - short - level 2" for "profile"
Then I answer "y" to "epic"
Expand Down
18 changes: 14 additions & 4 deletions features/profiles.feature
Expand Up @@ -12,7 +12,7 @@ Feature: Manage Profiles
And I choose "beginner" for "tower"
And I answer "Joe" to "name"
Then I should see "generated"
And I should find file at "tmp/ruby-warrior"
And I should find file at "tmp/rubywarrior"
When I run rubywarrior
Then I should see "Joe - beginner - level 1 - score 0"

Expand All @@ -39,8 +39,18 @@ Feature: Manage Profiles

Scenario: Auto select profile at given path
Given a profile named "Joe" on "beginner"
And current directory is "tmp/ruby-warrior/joe-beginner"
When I copy fixture "walking_player.rb" to "tmp/ruby-warrior/joe-beginner/player.rb"
And current directory is "tmp/rubywarrior/joe-beginner"
When I copy fixture "walking_player.rb" to "tmp/rubywarrior/joe-beginner/player.rb"
And I run rubywarrior
And I answer "y" to "next level"
Then I should see "the updated README in the ruby-warrior/joe-beginner directory"
Then I should see "the updated README in the rubywarrior/joe-beginner directory"

Scenario: Move legacy ruby-warrior profile
Given a directory at "tmp/ruby-warrior"
And no directory at "tmp/rubywarrior"
When I run rubywarrior
And I choose "beginner" for "tower"
And I answer "Joe" to "name"
Then I should see "generated"
And I should find file at "tmp/rubywarrior"
And I should find no file at "tmp/ruby-warrior"
12 changes: 12 additions & 0 deletions features/step_definitions/common_steps.rb
@@ -1,7 +1,19 @@
Given /^a directory at "([^\"]*)"$/ do |path|
Dir.mkdir(path) unless File.exist? path
end

Given /^no directory at "([^\"]*)"$/ do |path|
Dir.rmdir(path) if File.exist? path
end

When /^I copy fixture "([^\"]*)" to "([^\"]*)"$/ do |from, to|
FileUtils.cp_r("spec/fixtures/" + from, to)
end

Then /^I should find file at "([^\"]*)"$/ do |path|
File.exist?(path).should be_true
end

Then /^I should find no file at "([^\"]*)"$/ do |path|
File.exist?(path).should be_false
end
2 changes: 1 addition & 1 deletion features/step_definitions/interaction_steps.rb
Expand Up @@ -8,7 +8,7 @@

Given /^no profile at "([^\"]*)"$/ do |path|
RubyWarrior::Config.path_prefix = path
FileUtils.rm_rf("#{path}/ruby-warrior")
FileUtils.rm_rf("#{path}/rubywarrior")
end

Given /^current directory is "([^\"]*)"$/ do |path|
Expand Down
17 changes: 10 additions & 7 deletions lib/ruby_warrior/game.rb
Expand Up @@ -4,18 +4,21 @@ class Game
def start
UI.puts "Welcome to Ruby Warrior"

if File.exists?(Config.path_prefix + '/.profile')
if File.exist?(Config.path_prefix + '/.profile')
@profile = Profile.load(Config.path_prefix + '/.profile')
else
make_game_directory unless File.exists?(Config.path_prefix + '/ruby-warrior')
if File.exist?(Config.path_prefix + '/ruby-warrior')
FileUtils.mv(Config.path_prefix + '/ruby-warrior', Config.path_prefix + '/rubywarrior')
end
make_game_directory unless File.exist?(Config.path_prefix + '/rubywarrior')
end

profile.epic? ? play_epic_mode : play_normal_mode
end

def make_game_directory
if UI.ask("No ruby-warrior directory found, would you like to create one?")
Dir.mkdir(Config.path_prefix + '/ruby-warrior')
if UI.ask("No rubywarrior directory found, would you like to create one?")
Dir.mkdir(Config.path_prefix + '/rubywarrior')
else
UI.puts "Unable to continue without directory."
exit
Expand Down Expand Up @@ -47,7 +50,7 @@ def play_normal_mode
else
if current_level.number.zero?
prepare_next_level
UI.puts "First level has been generated. See the ruby-warrior/#{profile.directory_name}/README for instructions."
UI.puts "First level has been generated. See the rubywarrior/#{profile.directory_name}/README for instructions."
else
play_current_level
end
Expand Down Expand Up @@ -86,7 +89,7 @@ def request_next_level
if !Config.skip_input? && (next_level.exists? ? UI.ask("Would you like to continue on to the next level?") : UI.ask("Would you like to continue on to epic mode?"))
if next_level.exists?
prepare_next_level
UI.puts "See the updated README in the ruby-warrior/#{profile.directory_name} directory."
UI.puts "See the updated README in the rubywarrior/#{profile.directory_name} directory."
else
prepare_epic_mode
UI.puts "Run rubywarrior again to play epic mode."
Expand Down Expand Up @@ -116,7 +119,7 @@ def profiles
end

def profile_paths
Dir[Config.path_prefix + '/ruby-warrior/**/.profile']
Dir[Config.path_prefix + '/rubywarrior/**/.profile']
end

def profile
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_warrior/profile.rb
Expand Up @@ -37,7 +37,7 @@ def self.load(path)
end

def player_path
@player_path || Config.path_prefix + "/ruby-warrior/#{directory_name}"
@player_path || Config.path_prefix + "/rubywarrior/#{directory_name}"
end

def directory_name
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby_warrior/game_spec.rb
Expand Up @@ -9,7 +9,7 @@

it "should make game directory if player says so" do
RubyWarrior::UI.stubs(:ask).returns(true)
Dir.expects(:mkdir).with('./ruby-warrior')
Dir.expects(:mkdir).with('./rubywarrior')
@game.make_game_directory
end

Expand All @@ -30,7 +30,7 @@
end

it "should find profile paths using Dir[] search" do
Dir.expects(:[]).with("./ruby-warrior/**/.profile")
Dir.expects(:[]).with("./rubywarrior/**/.profile")
@game.profile_paths
end

Expand Down
2 changes: 1 addition & 1 deletion spec/ruby_warrior/profile_spec.rb
Expand Up @@ -128,7 +128,7 @@
end

it "should guess at the player path" do
@profile.player_path.should == './ruby-warrior/john-smith-tower'
@profile.player_path.should == './rubywarrior/john-smith-tower'
end

it "should use specified player path" do
Expand Down

0 comments on commit 3945748

Please sign in to comment.