stendhal 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Readme.md CHANGED
@@ -15,6 +15,7 @@ development.
15
15
  * Mocks (message expectations) with _optionally_ stubbable return values
16
16
  * Nested example groups (declare them with either describe or context)
17
17
  * Pending examples
18
+ * A rake task to run the specs
18
19
  * Matchers (use with object.must or object.must_not)
19
20
 
20
21
  eq() / eql()
@@ -30,6 +31,19 @@ development.
30
31
 
31
32
  ##Usage
32
33
 
34
+ In your Gemfile:
35
+
36
+ gem 'stendhal'
37
+
38
+ If you want the :spec task, in your Rakefile:
39
+
40
+ require 'stendhal'
41
+ Stendhal::RakeTask.new
42
+
43
+ task :default => :spec
44
+
45
+ ##Syntax
46
+
33
47
  # your spec file for some class - foo_spec.rb
34
48
 
35
49
  describe "Foo" do
@@ -0,0 +1,109 @@
1
+ Feature: Command line interpreter
2
+
3
+ Stendhal runs by default all *_spec.rb files inside a spec/ folder,
4
+ unless you specify which specs have to be runned.
5
+
6
+ Scenario: with no arguments
7
+ Given a directory named "stendhal_project"
8
+ And I cd to "stendhal_project"
9
+ And a directory named "spec"
10
+ And a directory named "spec/nested"
11
+ Given a file named "spec/sample_spec.rb" with:
12
+ """
13
+ describe "something" do
14
+ it "does something" do
15
+ # put your code here
16
+ end
17
+ end
18
+ """
19
+ And a file named "spec/another_sample_spec.rb" with:
20
+ """
21
+ describe "something" do
22
+ it "does something" do
23
+ # put your code here
24
+ end
25
+ end
26
+ """
27
+ And a file named "spec/nested/a_nested_spec.rb" with:
28
+ """
29
+ describe "something" do
30
+ it "does something" do
31
+ # put your code here
32
+ end
33
+ end
34
+ """
35
+ When I run "stendhal"
36
+ Then the exit status should be 0
37
+ And the output should contain "3 examples, 0 failures"
38
+
39
+ Scenario: specifying files to be run
40
+ Given a directory named "stendhal_project"
41
+ And I cd to "stendhal_project"
42
+ And a directory named "spec"
43
+ And a directory named "spec/nested"
44
+ Given a file named "spec/sample_spec.rb" with:
45
+ """
46
+ describe "something" do
47
+ it "does something" do
48
+ # put your code here
49
+ end
50
+ end
51
+ """
52
+ And a file named "spec/another_sample_spec.rb" with:
53
+ """
54
+ describe "something" do
55
+ it "does something" do
56
+ # put your code here
57
+ end
58
+ end
59
+ """
60
+ And a file named "spec/nested/a_nested_spec.rb" with:
61
+ """
62
+ describe "something" do
63
+ it "does something" do
64
+ # put your code here
65
+ end
66
+ end
67
+ """
68
+ When I run "stendhal spec/sample_spec.rb spec/nested/a_nested_spec.rb"
69
+ Then the exit status should be 0
70
+ And the output should contain "2 examples, 0 failures"
71
+
72
+ Scenario: running from rake
73
+ Given a directory named "stendhal_project"
74
+ And I cd to "stendhal_project"
75
+ And a directory named "spec"
76
+ And a directory named "spec/nested"
77
+ Given a file named "Rakefile" with:
78
+ """
79
+ require 'stendhal'
80
+ Stendhal::RakeTask.new
81
+ task :default => :spec
82
+ """
83
+ Given a file named "spec/sample_spec.rb" with:
84
+ """
85
+ describe "something" do
86
+ it "does something" do
87
+ # put your code here
88
+ end
89
+ end
90
+ """
91
+ And a file named "spec/another_sample_spec.rb" with:
92
+ """
93
+ describe "something" do
94
+ it "does something" do
95
+ # put your code here
96
+ end
97
+ end
98
+ """
99
+ And a file named "spec/nested/a_nested_spec.rb" with:
100
+ """
101
+ describe "something" do
102
+ it "does something" do
103
+ # put your code here
104
+ end
105
+ end
106
+ """
107
+ When I run "rake"
108
+ # Then the exit status should be 0
109
+ Then the output should contain "3 examples, 0 failures"
data/lib/stendhal.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'stendhal/rake_task'
1
2
  require 'stendhal/reporter'
2
3
  require 'stendhal/exceptions'
3
4
  require 'stendhal/matchers'
@@ -1,7 +1,13 @@
1
1
 
2
2
 
3
- ARGV.each do |file|
4
- require File.join('.',file)
3
+ unless ARGV.empty?
4
+ ARGV.each do |file|
5
+ require File.join('.',file)
6
+ end
7
+ else
8
+ Dir['spec/**/*_spec.rb'].entries.each do |entry|
9
+ require File.join('.', entry)
10
+ end
5
11
  end
6
12
 
7
13
  examples, failures, pending = Stendhal::ExampleGroup.run_all
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'stendhal'
4
+ require 'rake'
5
+ require 'rake/tasklib'
6
+
7
+ module Stendhal
8
+ # Mostly taken from rspec-core Rake task
9
+ class RakeTask < ::Rake::TaskLib
10
+
11
+ # Name of task.
12
+ #
13
+ # default:
14
+ # :spec
15
+ attr_accessor :name
16
+
17
+ # By default, if there is a Gemfile, the generated command will include
18
+ # 'bundle exec'. Set this to true to ignore the presence of a Gemfile, and
19
+ # not add 'bundle exec' to the command.
20
+ #
21
+ # default:
22
+ # false
23
+ attr_accessor :skip_bundler
24
+
25
+ # Name of Gemfile to use
26
+ #
27
+ # default:
28
+ # Gemfile
29
+ attr_accessor :gemfile
30
+
31
+ # Whether or not to fail Rake when an error occurs (typically when examples fail).
32
+ #
33
+ # default:
34
+ # true
35
+ attr_accessor :fail_on_error
36
+
37
+ # A message to print to stderr when there are failures.
38
+ attr_accessor :failure_message
39
+
40
+ # Use verbose output. If this is set to true, the task will print the
41
+ # executed spec command to stdout.
42
+ #
43
+ # default:
44
+ # true
45
+ attr_accessor :verbose
46
+
47
+ # Command line options to pass to ruby.
48
+ #
49
+ # default:
50
+ # nil
51
+ attr_accessor :ruby_opts
52
+
53
+ # Path to stendhal
54
+ #
55
+ # default:
56
+ # 'stendhal'
57
+ attr_accessor :stendhal_path
58
+
59
+ def initialize(*args)
60
+ @name = args.shift || :spec
61
+ @ruby_opts = nil
62
+ @skip_bundler = false
63
+ @verbose, @fail_on_error = true, true
64
+ @gemfile = 'Gemfile'
65
+
66
+ yield self if block_given?
67
+
68
+ @stendhal_path ||= 'stendhal'
69
+
70
+ desc("Run Stendhal code examples") unless ::Rake.application.last_comment
71
+
72
+ task name do
73
+ RakeFileUtils.send(:verbose, verbose) do
74
+ begin
75
+ ruby(stendhal_command)
76
+ rescue
77
+ puts failure_message if failure_message
78
+ raise("ruby #{stendhal_command} failed") if fail_on_error
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ private
85
+
86
+ def stendhal_command
87
+ @stendhal_command ||= begin
88
+ cmd_parts = [ruby_opts]
89
+ cmd_parts << "-S"
90
+ cmd_parts << "bundle exec" if gemfile? unless skip_bundler
91
+ cmd_parts << stendhal_path
92
+ cmd_parts.flatten.compact.reject(&blank).join(" ")
93
+ end
94
+ end
95
+
96
+ private
97
+
98
+ def blank
99
+ lambda {|s| s == ""}
100
+ end
101
+
102
+ def gemfile?
103
+ File.exist?(gemfile)
104
+ end
105
+
106
+ end
107
+ end
@@ -1,3 +1,3 @@
1
1
  module Stendhal
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 7
9
- version: 0.1.7
8
+ - 8
9
+ version: 0.1.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Josep M. Bach
@@ -129,6 +129,7 @@ files:
129
129
  - Rakefile
130
130
  - Readme.md
131
131
  - bin/stendhal
132
+ - features/cli.feature
132
133
  - features/examples.feature
133
134
  - features/expectations.feature
134
135
  - features/mocks.feature
@@ -153,6 +154,7 @@ files:
153
154
  - lib/stendhal/mocks/mockable.rb
154
155
  - lib/stendhal/mocks/stubbable.rb
155
156
  - lib/stendhal/mocks/test_double.rb
157
+ - lib/stendhal/rake_task.rb
156
158
  - lib/stendhal/reporter.rb
157
159
  - lib/stendhal/version.rb
158
160
  - script/console
@@ -204,6 +206,7 @@ signing_key:
204
206
  specification_version: 3
205
207
  summary: Stendhal is a really simple test framework.
206
208
  test_files:
209
+ - features/cli.feature
207
210
  - features/examples.feature
208
211
  - features/expectations.feature
209
212
  - features/mocks.feature