cukesalad 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/cucumber.yml +1 -1
- data/features/define_a_task_with_arguments.feature +35 -0
- data/features/lib/tasks/see_the_step_has.rb +1 -0
- data/lib/actor.rb +6 -4
- data/lib/cukesalad.rb +8 -5
- data/lib/specifics.rb +5 -1
- data/spec/actor_spec.rb +1 -1
- data/spec/specifics_spec.rb +31 -0
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/cucumber.yml
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
Feature: Define a Task with arguments
|
2
|
+
As a Step Free Cuker
|
3
|
+
You want to describe a task with additional info
|
4
|
+
So that your task can use that information wisely
|
5
|
+
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given you are a Step Free Cuker
|
9
|
+
And you were able to create a new Cuke Salad project
|
10
|
+
And you were able to create a role: called 'NewCustomer'
|
11
|
+
And you were able to create a task: called 'do something'
|
12
|
+
|
13
|
+
Scenario Outline: A task can accept arguments
|
14
|
+
When you attempt to run a scenario: called 'something' containing
|
15
|
+
"""
|
16
|
+
Given I am a New Customer
|
17
|
+
<the_step>
|
18
|
+
"""
|
19
|
+
Then you should see it has 'passed'
|
20
|
+
|
21
|
+
Examples:
|
22
|
+
| the_step |
|
23
|
+
| When I attempt to do something: with 'information' |
|
24
|
+
| When I attempt to do something, with 'information' |
|
25
|
+
|
26
|
+
Scenario: A task accepts tables
|
27
|
+
When you attempt to run a scenario, called 'something' containing
|
28
|
+
"""
|
29
|
+
Given I am a New Customer
|
30
|
+
When I attempt to do something, with
|
31
|
+
| information |
|
32
|
+
| first item |
|
33
|
+
| second item |
|
34
|
+
"""
|
35
|
+
Then you should see it has 'passed'
|
data/lib/actor.rb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
|
-
require 'specifics'
|
2
1
|
require 'director'
|
3
2
|
|
4
3
|
class Actor
|
5
|
-
include Specifics
|
6
4
|
|
7
5
|
def initialize this_type_of_role, directed_by=Director.new
|
8
6
|
@director = directed_by
|
9
7
|
get_into_character_for this_type_of_role
|
10
8
|
end
|
11
9
|
|
12
|
-
def perform described_task,
|
10
|
+
def perform described_task, details = {}
|
13
11
|
get_ready_to_perform described_task
|
14
|
-
|
12
|
+
@info = details
|
15
13
|
perform_task
|
16
14
|
end
|
17
15
|
alias :answer :perform
|
@@ -29,4 +27,8 @@ class Actor
|
|
29
27
|
def see_how_to_do something
|
30
28
|
extend something
|
31
29
|
end
|
30
|
+
|
31
|
+
def value_of(symbol)
|
32
|
+
@info[symbol]
|
33
|
+
end
|
32
34
|
end
|
data/lib/cukesalad.rb
CHANGED
@@ -3,8 +3,11 @@ require 'rubygems'
|
|
3
3
|
require 'bundler'
|
4
4
|
require 'actor'
|
5
5
|
require 'task_author'
|
6
|
+
require 'specifics'
|
6
7
|
Bundler.setup
|
7
8
|
|
9
|
+
World(Specifics)
|
10
|
+
|
8
11
|
When /^I say hello CukeSalad$/ do
|
9
12
|
puts "CukeSalad says: Hello!!"
|
10
13
|
end
|
@@ -13,11 +16,11 @@ Given /^(?:I am|you are) a ([a-zA-Z ]+)$/ do |role|
|
|
13
16
|
@actor = Actor.new(role)
|
14
17
|
end
|
15
18
|
|
16
|
-
When /^(?:I|you) (?:attempt to|was able to|were able to|did)? ([A-Z a-z_-]*)(
|
17
|
-
with_these_details
|
18
|
-
|
19
|
-
@actor.perform this_task,
|
20
|
-
@actor.perform this_task if
|
19
|
+
When /^(?:I|you) (?:attempt to|was able to|were able to|did)? ([A-Z a-z_-]*)(?:[:|,] (.*))?$/ do | this_task, with_these_details, *and_more |
|
20
|
+
info = understand_the with_these_details unless with_these_details.nil?
|
21
|
+
info[info.keys.last] = and_more[0] unless and_more.empty?
|
22
|
+
@actor.perform this_task, info unless info.nil?
|
23
|
+
@actor.perform this_task if info.nil?
|
21
24
|
end
|
22
25
|
|
23
26
|
Then /^(?:I|you) should ([^':]*)(?: '([^']*)')$/ do | this_question, expect_value |
|
data/lib/specifics.rb
CHANGED
@@ -15,6 +15,10 @@ module Specifics
|
|
15
15
|
result
|
16
16
|
end
|
17
17
|
|
18
|
+
def set_last value
|
19
|
+
@info[@info.keys.last] = value
|
20
|
+
end
|
21
|
+
|
18
22
|
def names_and_values_in details
|
19
23
|
specifics_pattern = /('[^']+')/
|
20
24
|
details.split(specifics_pattern)
|
@@ -25,6 +29,6 @@ module Specifics
|
|
25
29
|
end
|
26
30
|
|
27
31
|
def the_value_from_the item
|
28
|
-
item.gsub(/(^'|'$)/, '')
|
32
|
+
item.gsub(/(^'|'$)/, '') unless item.nil?
|
29
33
|
end
|
30
34
|
end
|
data/spec/actor_spec.rb
CHANGED
@@ -58,7 +58,7 @@ describe Actor do
|
|
58
58
|
role_description = "Butler"
|
59
59
|
|
60
60
|
task_description = "Lay The Table"
|
61
|
-
details =
|
61
|
+
details = { with_places_for: '5' }
|
62
62
|
|
63
63
|
director = double("director")
|
64
64
|
director.should_receive( :explain_the_role ).with( role_description ).and_return( Butler )
|
data/spec/specifics_spec.rb
CHANGED
@@ -33,4 +33,35 @@ describe Specifics do
|
|
33
33
|
something.value_of(:first_thing).should == "item"
|
34
34
|
something.value_of(:second_thing).should == "another thing"
|
35
35
|
end
|
36
|
+
|
37
|
+
context 'the last item' do
|
38
|
+
it "can be empty" do
|
39
|
+
something = NeedingSpecifics.new
|
40
|
+
something.understand_the "containing"
|
41
|
+
something.value_of(:containing).should be_nil
|
42
|
+
end
|
43
|
+
|
44
|
+
it "can be the only item and have a value assigned" do
|
45
|
+
something = NeedingSpecifics.new
|
46
|
+
something.understand_the "containing"
|
47
|
+
something.set_last('some value')
|
48
|
+
something.value_of(:containing).should == 'some value'
|
49
|
+
end
|
50
|
+
|
51
|
+
it "can be the only item and be empty" do
|
52
|
+
something = NeedingSpecifics.new
|
53
|
+
something.understand_the "called 'something' containing"
|
54
|
+
something.value_of(:called).should == 'something'
|
55
|
+
something.value_of(:containing).should be_nil
|
56
|
+
end
|
57
|
+
|
58
|
+
it "can have a value assigned" do
|
59
|
+
something = NeedingSpecifics.new
|
60
|
+
something.understand_the "called 'something' containing"
|
61
|
+
something.value_of(:called).should == 'something'
|
62
|
+
something.set_last('some value')
|
63
|
+
something.value_of(:containing).should == 'some value'
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
36
67
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cukesalad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.5.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- RiverGlide
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- features/a_new_cukesalad_project.feature
|
113
113
|
- features/define_a_role.feature
|
114
114
|
- features/define_a_task.feature
|
115
|
+
- features/define_a_task_with_arguments.feature
|
115
116
|
- features/lib/roles/step_free_cuker.rb
|
116
117
|
- features/lib/tasks/create_a_file.rb
|
117
118
|
- features/lib/tasks/create_a_new_cukesalad_project.rb
|
@@ -165,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
165
166
|
requirements:
|
166
167
|
- - ">="
|
167
168
|
- !ruby/object:Gem::Version
|
168
|
-
hash:
|
169
|
+
hash: -2598108803398810333
|
169
170
|
segments:
|
170
171
|
- 0
|
171
172
|
version: "0"
|