citrusbyte-stories 0.0.2

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/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2009 Damian Janowski and Michel Martens for Citrusbyte
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,100 @@
1
+ Stories
2
+ =======
3
+
4
+ Stories and User Acceptance Tests for Test::Unit.
5
+
6
+ Description
7
+ -----------
8
+
9
+ Write user stories and user acceptace tests using Contest, the tiny add on to Test::Unit that provides nested contexts and declarative tests.
10
+
11
+ Usage
12
+ -----
13
+
14
+ Declare your stories as follows:
15
+
16
+ require 'stories'
17
+
18
+ class UserStoryTest < Test::Unit::TestCase
19
+ story "As a user I want to create stories so I can test if they pass" do
20
+ setup do
21
+ @user = "valid user"
22
+ end
23
+
24
+ scenario "A valid user" do
25
+ assert_equal "valid user", @user
26
+ end
27
+ end
28
+ end
29
+
30
+ If you are using Rails, you can use stories for your integration tests with Webrat:
31
+
32
+ require "stories"
33
+
34
+ class UserStoriesTest < ActionController::IntegrationTest
35
+ story "As a user I want to log in so that I can access restricted features" do
36
+ setup do
37
+ @user = User.spawn
38
+ end
39
+
40
+ scenario "Using good information" do
41
+ visit "/"
42
+ click_link "Log in"
43
+ fill_in :session_email, :with => user.email
44
+ fill_in :session_password, :with => user.password
45
+ click_button "Sign in"
46
+
47
+ assert_not_contain "Log in"
48
+ assert_not_contain "Sign up"
49
+ end
50
+ end
51
+ end
52
+
53
+ You can run it normally, it's Test::Unit after all. If you want to run a particular test, say "yet more tests", try this:
54
+
55
+ $ testrb my_test.rb -n test_yet_more_tests
56
+
57
+ Or with a regular expression:
58
+
59
+ $ testrb my_test.rb -n /yet_more_tests/
60
+
61
+ Installation
62
+ ------------
63
+
64
+ $ gem sources -a http://gems.github.com (you only have to do this once)
65
+ $ sudo gem install citrusbyte-stories
66
+
67
+ If you want to use it with Rails, add this to config/environment.rb:
68
+
69
+ config.gem "citrusbyte-stories", :lib => 'stories', :source => 'http://gems.github.com'
70
+
71
+ Then you can vendor the gem:
72
+
73
+ rake gems:install
74
+ rake gems:unpack
75
+
76
+ License
77
+ -------
78
+
79
+ Copyright (c) 2009 Damian Janowski and Michel Martens for Citrusbyte
80
+
81
+ Permission is hereby granted, free of charge, to any person
82
+ obtaining a copy of this software and associated documentation
83
+ files (the "Software"), to deal in the Software without
84
+ restriction, including without limitation the rights to use,
85
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
86
+ copies of the Software, and to permit persons to whom the
87
+ Software is furnished to do so, subject to the following
88
+ conditions:
89
+
90
+ The above copyright notice and this permission notice shall be
91
+ included in all copies or substantial portions of the Software.
92
+
93
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
94
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
95
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
96
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
97
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
98
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
99
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
100
+ OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ require 'rake'
2
+ require 'rake/gempackagetask'
3
+ require 'rake/testtask'
4
+ require 'rake/clean'
5
+
6
+ gem_spec_file = 'stories.gemspec'
7
+
8
+ gem_spec = eval(File.read(gem_spec_file)) rescue nil
9
+
10
+ task :default => :test
11
+
12
+ Rake::TestTask.new(:test) do |t|
13
+ t.pattern = 'test/**/*_test.rb'
14
+ t.verbose = false
15
+ end
16
+
17
+ Rake::GemPackageTask.new(gem_spec) do |pkg|
18
+ pkg.need_zip = false
19
+ pkg.need_tar = false
20
+ rm_f FileList['pkg/**/*.*']
21
+ end if gem_spec
22
+
23
+ desc "Generate the gemspec file."
24
+ task :gemspec do
25
+ require 'erb'
26
+
27
+ File.open(gem_spec_file, 'w') do |f|
28
+ f.write ERB.new(File.read("#{gem_spec_file}.erb")).result(binding)
29
+ end
30
+ end
31
+
32
+ desc "Builds and installs the gem."
33
+ task :install => :repackage do
34
+ `sudo gem install pkg/#{gem_spec.name}-#{gem_spec.version}.gem`
35
+ end
data/lib/stories.rb ADDED
@@ -0,0 +1,21 @@
1
+ require "rubygems"
2
+ require "contest"
3
+
4
+ class Test::Unit::TestCase
5
+ class << self
6
+ alias scenario test
7
+
8
+ def story(name, &block)
9
+ $stories << name
10
+ context(name, &block)
11
+ end
12
+ end
13
+ end
14
+
15
+ $stories = []
16
+
17
+ at_exit do
18
+ unless $stories.empty?
19
+ puts $stories.join("\n"); puts
20
+ end
21
+ end
data/rails/init.rb ADDED
@@ -0,0 +1,9 @@
1
+ if RAILS_ENV == 'test'
2
+
3
+ # Require webrat and configure it to work in Rails mode.
4
+ require "webrat"
5
+
6
+ Webrat.configure do |config|
7
+ config.mode = :rails
8
+ end
9
+ end
data/test/all_test.rb ADDED
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + "/../lib/stories"
2
+
3
+ class UserStoryTest < Test::Unit::TestCase
4
+ story "As a user I want to create stories so I can test if they pass" do
5
+ setup do
6
+ @user = "valid user"
7
+ end
8
+
9
+ scenario "A valid user" do
10
+ assert_equal "valid user", @user
11
+ end
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: citrusbyte-stories
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Damian Janowski
8
+ - Michel Martens
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-04-30 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description:
18
+ email: michel@soveran.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - lib/stories.rb
27
+ - README.markdown
28
+ - LICENSE
29
+ - Rakefile
30
+ - rails/init.rb
31
+ - test/all_test.rb
32
+ has_rdoc: false
33
+ homepage: http://github.com/citrusbyte/stories
34
+ post_install_message:
35
+ rdoc_options: []
36
+
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ requirements: []
52
+
53
+ rubyforge_project:
54
+ rubygems_version: 1.2.0
55
+ signing_key:
56
+ specification_version: 2
57
+ summary: Write stories and user acceptance tests using Test::Unit.
58
+ test_files: []
59
+