aruba-doubles 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.2@aruba-doubles --create
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'aruba-doubles'
5
- s.version = '0.2.0'
5
+ s.version = '0.2.1'
6
6
  s.authors = ["Björn Albers"]
7
7
  s.email = ["bjoernalbers@googlemail.com"]
8
8
  s.description = 'Stub command line applications with Cucumber'
9
9
  s.summary = "#{s.name}-#{s.version}"
10
- s.homepage = 'https://github.com/bjoernalbers/aruba-doubles'
10
+ s.homepage = "https://github.com/bjoernalbers/#{s.name}"
11
11
 
12
12
  s.add_dependency 'cucumber', '>= 1.0.2'
13
-
13
+
14
14
  s.add_development_dependency 'aruba', '>= 0.4.6'
15
15
  s.add_development_dependency 'guard-cucumber', '>= 0.7.3'
16
16
  s.add_development_dependency 'guard-rspec', '>= 0.5.1'
@@ -58,14 +58,17 @@ Feature: Double command line applications
58
58
  And the stderr should be empty
59
59
 
60
60
  Scenario: Run with unexpected arguments
61
- Given I could run `foo --bar` with stdout:
62
- """
63
- hello, world.
64
- """
65
- When I run `foo --baz`
61
+ Given I could run `foo --bar 'hello, world.'`
62
+ When I successfully run `foo --bar 'hello, world.'`
63
+ Then the stdout should be empty
64
+ And the stderr should be empty
65
+ When I run `foo --bar hello world`
66
66
  Then the exit status should not be 0
67
67
  And the stdout should be empty
68
- And the stderr should contain "Unexpected arguments"
68
+ And the stderr should contain:
69
+ """
70
+ Unexpected arguments: ["--bar", "hello", "world"]
71
+ """
69
72
 
70
73
  Scenario: Stub multiple calls
71
74
  Given I could run `foo --bar` with stdout:
@@ -20,4 +20,10 @@ Feature: Environment-friendly
20
20
  Scenario: ...and check that it was deleted
21
21
  Then the previous doubles directory should not exist
22
22
 
23
-
23
+ @no-clobber
24
+ Scenario: Create doubles directory...
25
+ Given I could run `ls`
26
+ When I keep the doubles directory in mind
27
+
28
+ Scenario: ...and check that it was not deleted
29
+ Then the previous doubles directory should exist
@@ -14,6 +14,10 @@ Then /^the previous doubles directory should not exist$/ do
14
14
  File.should_not be_exist(@@previous_doubles_dir)
15
15
  end
16
16
 
17
+ Then /^the previous doubles directory should exist$/ do
18
+ File.should be_exist(@@previous_doubles_dir)
19
+ end
20
+
17
21
  Then /^the (stdout|stderr) should be empty$/ do |stdout_stderr|
18
22
  steps %Q{
19
23
  Then the #{stdout_stderr} should contain exactly:
@@ -1,4 +1,5 @@
1
1
  require 'aruba-doubles/double'
2
+ require 'shellwords'
2
3
 
3
4
  module ArubaDoubles
4
5
  module Api
@@ -7,8 +8,8 @@ module ArubaDoubles
7
8
  end
8
9
 
9
10
  def create_double_by_cmd(cmd, options = {})
10
- filename = cmd.split.first
11
- arguments = cmd.split[1..-1]
11
+ arguments = Shellwords.split(cmd)
12
+ filename = arguments.shift
12
13
  create_double(filename, arguments, options)
13
14
  end
14
15
 
@@ -25,6 +26,7 @@ module ArubaDoubles
25
26
  File.open(fullpath, 'w') do |f|
26
27
  f.puts "#!/usr/bin/env ruby"
27
28
  f.puts "# Doubled command line application by aruba-doubles\n"
29
+ f.puts "require 'rubygems'"
28
30
  f.puts "require 'aruba-doubles/double'"
29
31
  f.puts "double = ArubaDoubles::Double.new(#{double.expectations.inspect})"
30
32
  f.puts "double.run"
@@ -7,14 +7,12 @@ module ArubaDoubles
7
7
  end
8
8
 
9
9
  def could_receive(args, options = {})
10
- args = args.join(' ') if args.respond_to?(:join)
11
10
  @expectations[args] = options
12
11
  self
13
12
  end
14
13
 
15
14
  def run(argv = ARGV)
16
- argv = argv.join(' ')
17
- raise "Unexpected arguments" unless @expectations.has_key?(argv)
15
+ raise "Unexpected arguments: #{argv.inspect}" unless @expectations.has_key?(argv)
18
16
  @stdout = @expectations[argv][:stdout]
19
17
  @stderr = @expectations[argv][:stderr]
20
18
  @exit_status = @expectations[argv][:exit_status]
@@ -1,3 +1,3 @@
1
- After do
1
+ After('~@no-clobber') do
2
2
  remove_doubles if doubled?
3
3
  end
@@ -5,16 +5,7 @@ describe ArubaDoubles::Double, '#could_receive' do
5
5
  @double = ArubaDoubles::Double.new
6
6
  end
7
7
 
8
- it "should set expected arguments" do
9
- @double.could_receive("--foo", :stdout => "foo")
10
- @double.could_receive("--bar", :stdout => "bar")
11
- @double.run(["--foo"])
12
- @double.stdout.should eql("foo")
13
- @double.run(["--bar"])
14
- @double.stdout.should eql("bar")
15
- end
16
-
17
- it "should accept expected arguments as array" do
8
+ it "should set expected arguments like ARGV" do
18
9
  @double.could_receive(["--foo"], :stdout => "foo")
19
10
  @double.could_receive(["--bar"], :stdout => "bar")
20
11
  @double.run(["--foo"])
@@ -24,11 +15,11 @@ describe ArubaDoubles::Double, '#could_receive' do
24
15
  end
25
16
 
26
17
  it "should return self" do
27
- @double.could_receive("").should be(@double)
18
+ @double.could_receive([]).should be(@double)
28
19
  end
29
20
 
30
21
  it "should set defaults when called without options" do
31
- @double.could_receive("")
22
+ @double.could_receive([])
32
23
  @double.run([])
33
24
  @double.stdout.should be_nil
34
25
  @double.stderr.should be_nil
@@ -36,19 +27,19 @@ describe ArubaDoubles::Double, '#could_receive' do
36
27
  end
37
28
 
38
29
  it "should set optional stdout" do
39
- @double.could_receive("", :stdout => "hi")
30
+ @double.could_receive([], :stdout => "hi")
40
31
  @double.run([])
41
32
  @double.stdout.should eql("hi")
42
33
  end
43
34
 
44
35
  it "should set optional stderr" do
45
- @double.could_receive("", :stderr => "HO!")
36
+ @double.could_receive([], :stderr => "HO!")
46
37
  @double.run([])
47
38
  @double.stderr.should eql("HO!")
48
39
  end
49
40
 
50
41
  it "should set optional exit status" do
51
- @double.could_receive("", :exit_status => 1)
42
+ @double.could_receive([], :exit_status => 1)
52
43
  @double.run([])
53
44
  @double.exit_status.should eql(1)
54
45
  end
@@ -62,7 +53,7 @@ describe ArubaDoubles::Double, '#run' do
62
53
  it "should read ARGV by default" do
63
54
  original_arguments = ARGV
64
55
  ARGV = ["--foo"]
65
- @double.could_receive("--foo", :stdout => "foo")
56
+ @double.could_receive(["--foo"], :stdout => "foo")
66
57
  @double.run
67
58
  @double.stdout.should eql("foo")
68
59
  ARGV = original_arguments
@@ -71,16 +62,16 @@ describe ArubaDoubles::Double, '#run' do
71
62
  it "should raise when called with unexpected arguments" do
72
63
  lambda {
73
64
  @double.run(["--unexpected"])
74
- }.should raise_error("Unexpected arguments")
65
+ }.should raise_error('Unexpected arguments: ["--unexpected"]')
75
66
  end
76
67
  end
77
68
 
78
69
  describe ArubaDoubles::Double do
79
70
  it "should be serializable" do
80
71
  double = ArubaDoubles::Double.new
81
- double.could_receive("")
82
- double.could_receive("--foo", :stdout=>"foo")
83
- double.could_receive("--bar", :stderr=>"OOPS!", :exit_status=>255)
72
+ double.could_receive([])
73
+ double.could_receive(["--foo"], :stdout => "foo")
74
+ double.could_receive(["--bar"], :stderr => "OOPS!", :exit_status => 255)
84
75
  loaded_double = ArubaDoubles::Double.new(double.expectations)
85
76
  loaded_double.run([])
86
77
  loaded_double.stdout.should be_nil
metadata CHANGED
@@ -1,97 +1,69 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: aruba-doubles
3
- version: !ruby/object:Gem::Version
4
- hash: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 0
10
- version: 0.2.0
11
6
  platform: ruby
12
- authors:
13
- - "Bj\xC3\xB6rn Albers"
7
+ authors:
8
+ - Björn Albers
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-11-02 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2011-11-13 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: cucumber
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70225278399380 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 19
29
- segments:
30
- - 1
31
- - 0
32
- - 2
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
33
21
  version: 1.0.2
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: aruba
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70225278399380
25
+ - !ruby/object:Gem::Dependency
26
+ name: aruba
27
+ requirement: &70225278398360 !ruby/object:Gem::Requirement
40
28
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- - 4
48
- - 6
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
49
32
  version: 0.4.6
50
33
  type: :development
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: guard-cucumber
54
34
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70225278398360
36
+ - !ruby/object:Gem::Dependency
37
+ name: guard-cucumber
38
+ requirement: &70225278397520 !ruby/object:Gem::Requirement
56
39
  none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 5
61
- segments:
62
- - 0
63
- - 7
64
- - 3
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
65
43
  version: 0.7.3
66
44
  type: :development
67
- version_requirements: *id003
68
- - !ruby/object:Gem::Dependency
69
- name: guard-rspec
70
45
  prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *70225278397520
47
+ - !ruby/object:Gem::Dependency
48
+ name: guard-rspec
49
+ requirement: &70225278393980 !ruby/object:Gem::Requirement
72
50
  none: false
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- hash: 9
77
- segments:
78
- - 0
79
- - 5
80
- - 1
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
81
54
  version: 0.5.1
82
55
  type: :development
83
- version_requirements: *id004
56
+ prerelease: false
57
+ version_requirements: *70225278393980
84
58
  description: Stub command line applications with Cucumber
85
- email:
59
+ email:
86
60
  - bjoernalbers@googlemail.com
87
61
  executables: []
88
-
89
62
  extensions: []
90
-
91
63
  extra_rdoc_files: []
92
-
93
- files:
64
+ files:
94
65
  - .gitignore
66
+ - .rvmrc
95
67
  - Gemfile
96
68
  - Guardfile
97
69
  - LICENSE
@@ -111,38 +83,29 @@ files:
111
83
  - spec/spec_helper.rb
112
84
  homepage: https://github.com/bjoernalbers/aruba-doubles
113
85
  licenses: []
114
-
115
86
  post_install_message:
116
87
  rdoc_options: []
117
-
118
- require_paths:
88
+ require_paths:
119
89
  - lib
120
- required_ruby_version: !ruby/object:Gem::Requirement
90
+ required_ruby_version: !ruby/object:Gem::Requirement
121
91
  none: false
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- hash: 3
126
- segments:
127
- - 0
128
- version: "0"
129
- required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
97
  none: false
131
- requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- hash: 3
135
- segments:
136
- - 0
137
- version: "0"
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
138
102
  requirements: []
139
-
140
103
  rubyforge_project:
141
- rubygems_version: 1.8.8
104
+ rubygems_version: 1.8.10
142
105
  signing_key:
143
106
  specification_version: 3
144
- summary: aruba-doubles-0.2.0
145
- test_files:
107
+ summary: aruba-doubles-0.2.1
108
+ test_files:
146
109
  - features/double.feature
147
110
  - features/environment-friendly.feature
148
111
  - features/step_definitions/dev_steps.rb