Permalink
Browse files

refactor examples not to use use_steps

  • Loading branch information...
1 parent 91a42f9 commit a23f8c065c555467a2b3a03ffaa8715a3daf7df1 @jnicklas committed Apr 24, 2012
@@ -1,7 +1,25 @@
-steps_for :alignment do
+module Alignment
+ extend Turnip::Define
+
attr_accessor :alignment
step "that alignment should be :alignment" do |expected_alignment|
alignment.should eq(expected_alignment)
end
end
+
+steps_for :evil do
+ include Alignment
+
+ step "the monster has an alignment" do
+ self.alignment = 'Evil'
+ end
+end
+
+steps_for :neutral do
+ include Alignment
+
+ step "the monster has an alignment" do
+ self.alignment = 'Neutral'
+ end
+end
@@ -1,7 +1,9 @@
require_relative "knight_steps"
-steps_for :dragon do
- use_steps :knight
+module DragonSteps
+ extend Turnip::Define
+
+ include KnightSteps
attr_accessor :dragon
@@ -17,3 +19,27 @@ def dragon_attack
knight.attacked_for(dragon_attack)
end
end
+
+module RedDragonSteps
+ extend Turnip::Define
+
+ include DragonSteps
+
+ attr_accessor :red_dragon
+
+ def dragon_attack
+ attack = super
+ if red_dragon
+ attack + 15
+ else
+ attack
+ end
+ end
+
+ step "the dragon breathes fire" do
+ self.red_dragon = 1
+ end
+end
+
+RSpec.configure { |c| c.include DragonSteps, :dragon => true }
+RSpec.configure { |c| c.include RedDragonSteps, :red_dragon => true }
@@ -1,7 +0,0 @@
-steps_for :evil do
- use_steps :alignment
-
- step "the monster has an alignment" do
- self.alignment = 'Evil'
- end
-end
@@ -1,4 +1,6 @@
-steps_for :knight do
+module KnightSteps
+ extend Turnip::Define
+
attr_accessor :knight
class Knight
@@ -27,3 +29,5 @@ def attacked_for(amount)
knight.should_not be_alive
end
end
+
+RSpec.configure { |c| c.include KnightSteps, :knight => true }
@@ -1,7 +0,0 @@
-steps_for :neutral do
- use_steps :alignment
-
- step "the monster has an alignment" do
- self.alignment = 'Neutral'
- end
-end
@@ -1,20 +0,0 @@
-require_relative "knight_steps"
-
-steps_for :red_dragon do
- use_steps :dragon
-
- attr_accessor :red_dragon
-
- def dragon_attack
- attack = super
- if red_dragon
- attack + 15
- else
- attack
- end
- end
-
- step "the dragon breathes fire" do
- self.red_dragon = 1
- end
-end

0 comments on commit a23f8c0

Please sign in to comment.