steak 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Luismi Cavallé
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -36,15 +36,16 @@ If you are not in Rails but use RSpec, then Steak is just some aliases providing
36
36
 
37
37
  == Getting started
38
38
 
39
+ <em><b>NOTE:</b> Please note that the stable version of Steak only works with Rails 2.x and RSpec 1.x. If you want to try with Rails 3 or RSpec 2, then you can install the prerelease version of Steak (using <tt>gem install steak --pre</tt>) which is based on the experimental <tt>rails3</tt> branch.</em>
40
+
39
41
  === Not in Rails
40
42
 
41
43
  Just install and require the damned gem!
42
44
 
43
- $ [sudo] gem install steak
45
+ $ gem install steak
44
46
 
45
47
  Then in your spec or spec helper:
46
48
 
47
- require 'rubygems'
48
49
  require 'steak'
49
50
 
50
51
  That's all. You don't really need to require RSpec.
@@ -57,7 +58,7 @@ Assuming you have already setup rspec-rails, add this to your project's <tt>conf
57
58
 
58
59
  Install the gem from the command line:
59
60
 
60
- $ [sudo] RAILS_ENV=test rake gems:install
61
+ $ RAILS_ENV=test rake gems:install
61
62
 
62
63
  Run the generator:
63
64
 
@@ -0,0 +1,76 @@
1
+ require "rubygems"
2
+ require "rake/gempackagetask"
3
+ require "rake/rdoctask"
4
+
5
+ require "spec"
6
+ require "spec/rake/spectask"
7
+ Spec::Rake::SpecTask.new do |t|
8
+ t.spec_opts = %w(--format specdoc --colour)
9
+ t.libs = ["spec"]
10
+ end
11
+
12
+
13
+ task :default => ["spec"]
14
+
15
+ # This builds the actual gem. For details of what all these options
16
+ # mean, and other ones you can add, check the documentation here:
17
+ #
18
+ # http://rubygems.org/read/chapter/20
19
+ #
20
+ spec = Gem::Specification.new do |s|
21
+
22
+ # Change these as appropriate
23
+ s.name = "steak"
24
+ s.version = "0.3.3"
25
+ s.summary = "If you are not in Rails but use RSpec, then Steak is just some aliases providing you with the language of acceptance testing (feature, scenario, background). If you are in Rails, you also have a couple of generators, a rake task and full Rails integration testing (meaning Webrat support, for instance)"
26
+ s.description = "Minimalist acceptance testing on top of RSpec"
27
+ s.author = "Luismi Cavallé"
28
+ s.email = "luismi@lmcavalle.com"
29
+ s.homepage = "http://github.com/cavalle/steak"
30
+
31
+ s.has_rdoc = true
32
+ s.extra_rdoc_files = %w(README.rdoc)
33
+ s.rdoc_options = %w(--main README.rdoc)
34
+
35
+ # Add any extra files to include in the gem
36
+ s.files = %w(init.rb MIT-LICENSE Rakefile README.rdoc) + Dir.glob("{spec,lib/**/*}")
37
+ s.require_paths = ["lib"]
38
+
39
+ # If you want to depend on other gems, add them here, along with any
40
+ # relevant versions
41
+ # s.add_dependency("some_other_gem", "~> 0.1.0")
42
+
43
+ # If your tests use any gems, include them here
44
+ s.add_development_dependency("rspec")
45
+ end
46
+
47
+ # This task actually builds the gem. We also regenerate a static
48
+ # .gemspec file, which is useful if something (i.e. GitHub) will
49
+ # be automatically building a gem for this project. If you're not
50
+ # using GitHub, edit as appropriate.
51
+ #
52
+ # To publish your gem online, install the 'gemcutter' gem; Read more
53
+ # about that here: http://gemcutter.org/pages/gem_docs
54
+ Rake::GemPackageTask.new(spec) do |pkg|
55
+ pkg.gem_spec = spec
56
+ end
57
+
58
+ desc "Build the gemspec file #{spec.name}.gemspec"
59
+ task :gemspec do
60
+ file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
61
+ File.open(file, "w") {|f| f << spec.to_ruby }
62
+ end
63
+
64
+ task :package => :gemspec
65
+
66
+ # Generate documentation
67
+ Rake::RDocTask.new do |rd|
68
+ rd.main = "README.rdoc"
69
+ rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
70
+ rd.rdoc_dir = "rdoc"
71
+ end
72
+
73
+ desc 'Clear out RDoc and generated packages'
74
+ task :clean => [:clobber_rdoc, :clobber_package] do
75
+ rm "#{spec.name}.gemspec"
76
+ end
data/init.rb ADDED
@@ -0,0 +1,8 @@
1
+ # Placeholder to satisfy Rails.
2
+ #
3
+ # Do NOT add any require statements to this file. Doing
4
+ # so will cause Rails to load this plugin all of the time.
5
+ #
6
+ # spec/acceptance/acceptance_helper.rb should include the necessary
7
+ # require statements and configuration. This file should
8
+ # be required by all of your acceptance specs.
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 3
9
+ version: 0.3.3
5
10
  platform: ruby
6
11
  authors:
7
12
  - "Luismi Cavall\xC3\xA9"
@@ -9,19 +14,21 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-01-02 00:00:00 +01:00
17
+ date: 2010-05-01 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rspec
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
23
29
  version: "0"
24
- version:
30
+ type: :development
31
+ version_requirements: *id001
25
32
  description: Minimalist acceptance testing on top of RSpec
26
33
  email: luismi@lmcavalle.com
27
34
  executables: []
@@ -31,16 +38,10 @@ extensions: []
31
38
  extra_rdoc_files:
32
39
  - README.rdoc
33
40
  files:
41
+ - init.rb
42
+ - MIT-LICENSE
43
+ - Rakefile
34
44
  - README.rdoc
35
- - generators/acceptance_spec/USAGE
36
- - generators/acceptance_spec/acceptance_spec_generator.rb
37
- - generators/acceptance_spec/templates/acceptance_spec.rb
38
- - generators/steak/USAGE
39
- - generators/steak/steak_generator.rb
40
- - generators/steak/templates/acceptance_helper.rb
41
- - generators/steak/templates/helpers.rb
42
- - generators/steak/templates/paths.rb
43
- - generators/steak/templates/steak.rake
44
45
  - lib/steak.rb
45
46
  has_rdoc: true
46
47
  homepage: http://github.com/cavalle/steak
@@ -48,31 +49,30 @@ licenses: []
48
49
 
49
50
  post_install_message:
50
51
  rdoc_options:
51
- - --charset=UTF-8
52
+ - --main
53
+ - README.rdoc
52
54
  require_paths:
53
55
  - lib
54
56
  required_ruby_version: !ruby/object:Gem::Requirement
55
57
  requirements:
56
58
  - - ">="
57
59
  - !ruby/object:Gem::Version
60
+ segments:
61
+ - 0
58
62
  version: "0"
59
- version:
60
63
  required_rubygems_version: !ruby/object:Gem::Requirement
61
64
  requirements:
62
65
  - - ">="
63
66
  - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
64
69
  version: "0"
65
- version:
66
70
  requirements: []
67
71
 
68
72
  rubyforge_project:
69
- rubygems_version: 1.3.5
73
+ rubygems_version: 1.3.6
70
74
  signing_key:
71
75
  specification_version: 3
72
76
  summary: If you are not in Rails but use RSpec, then Steak is just some aliases providing you with the language of acceptance testing (feature, scenario, background). If you are in Rails, you also have a couple of generators, a rake task and full Rails integration testing (meaning Webrat support, for instance)
73
- test_files:
74
- - spec/acceptance/acceptance_helper.rb
75
- - spec/acceptance/acceptance_spec_generator_spec.rb
76
- - spec/acceptance/basic_spec.rb
77
- - spec/acceptance/rails_spec.rb
78
- - spec/acceptance/steak_generator_spec.rb
77
+ test_files: []
78
+
File without changes
@@ -1,9 +0,0 @@
1
- class AcceptanceSpecGenerator < Rails::Generator::NamedBase
2
- def manifest
3
- record do |m|
4
- m.directory File.join('spec/acceptance', class_path)
5
- file_name.gsub!(/_spec$/,"")
6
- m.template 'acceptance_spec.rb', File.join('spec/acceptance', class_path, "#{file_name}_spec.rb")
7
- end
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- require File.dirname(__FILE__) + '/acceptance_helper'
2
-
3
- feature "Feature name", %q{
4
- In order to ...
5
- As a ...
6
- I want to ...
7
- } do
8
-
9
- scenario "Scenario name" do
10
- true.should == true
11
- end
12
-
13
- end
@@ -1,8 +0,0 @@
1
- Description:
2
- Sets up Steak in your Rails project. This will generate the spec/acceptance directory
3
- and the necessary files.
4
-
5
- If you haven't already, You should also run `./script/generate rspec` to complete the set up.
6
-
7
- Examples:
8
- `./script/generate steak`
@@ -1,12 +0,0 @@
1
- class SteakGenerator < Rails::Generator::Base
2
- def manifest
3
- record do |m|
4
- m.directory 'spec/acceptance/support'
5
- m.directory 'lib/tasks'
6
- m.file "acceptance_helper.rb", "spec/acceptance/acceptance_helper.rb"
7
- m.file "helpers.rb", "spec/acceptance/support/helpers.rb"
8
- m.file "paths.rb", "spec/acceptance/support/paths.rb"
9
- m.file "steak.rake", "lib/tasks/steak.rake"
10
- end
11
- end
12
- end
@@ -1,10 +0,0 @@
1
- require File.dirname(__FILE__) + "/../spec_helper"
2
- require "steak"
3
- require "webrat"
4
-
5
- Webrat.configure do |config|
6
- config.mode = :rails
7
- end
8
-
9
- # Put your acceptance spec helpers inside /spec/acceptance/support
10
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
@@ -1,6 +0,0 @@
1
- module HelperMethods
2
- # Put here any helper method you need to be available in all your acceptance tests
3
-
4
- end
5
-
6
- Spec::Runner.configuration.include(HelperMethods)
@@ -1,9 +0,0 @@
1
- module NavigationHelpers
2
- # Put here the helper methods related to the paths of your applications
3
-
4
- def homepage
5
- "/"
6
- end
7
- end
8
-
9
- Spec::Runner.configuration.include(NavigationHelpers)
@@ -1,9 +0,0 @@
1
- load File.dirname(__FILE__) + '/rspec.rake'
2
-
3
- namespace :spec do
4
- desc "Run the code examples in spec/acceptance"
5
- Spec::Rake::SpecTask.new(:acceptance => "db:test:prepare") do |t|
6
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
7
- t.spec_files = FileList["spec/acceptance/**/*_spec.rb"]
8
- end
9
- end
@@ -1,51 +0,0 @@
1
- require 'rubygems'
2
- require 'spec'
3
- require File.dirname(__FILE__) + "/../../lib/steak"
4
- require 'tempfile'
5
-
6
- module Factories
7
- def create_spec(options)
8
- options = {:content => options} unless options.is_a?(Hash)
9
- path = (options[:path] || Dir.tmpdir) + "/#{String.random}_spec.rb"
10
- File.open(path, "w") do |file|
11
- file.write options[:content]
12
- end
13
- path
14
- end
15
-
16
- def create_rails_app(options = {})
17
- path = Dir.tmpdir + "rails_app_#{String.random}"
18
- FileUtils.rm_rf path
19
- `rails #{path}`
20
- File.open(path + "/config/environments/test.rb", "a") do |file|
21
- file.write "\nconfig.gem 'rspec-rails', :lib => false\n"
22
- end
23
- FileUtils.cp_r File.dirname(__FILE__) + "/../../", path + "/vendor/plugins/steak"
24
-
25
- unless options[:setup_steak] == false
26
- Dir.chdir path do
27
- `script/generate rspec`
28
- `script/generate steak`
29
- end
30
- end
31
-
32
- path
33
- end
34
-
35
- end
36
-
37
- module HelperMethods
38
- def run_spec(file_path)
39
- `spec #{file_path} 2>&1`
40
- end
41
- end
42
-
43
- class String
44
- CHARS = ('a'..'z').to_a + ('A'..'Z').to_a
45
- def self.random(size = 8)
46
- (0..size).map{ CHARS[rand(CHARS.length)] }.join
47
- end
48
- end
49
-
50
- Spec::Runner.configuration.include(Factories)
51
- Spec::Runner.configuration.include(HelperMethods)
@@ -1,45 +0,0 @@
1
- require File.dirname(__FILE__) + "/acceptance_helper.rb"
2
-
3
- feature "Acceptance spec generator for rails", %q{
4
- In order to quickly add a new acceptance spec
5
- As a developer
6
- I want to run a generator that creates it for me
7
- } do
8
-
9
- background do
10
- @rails_app = create_rails_app
11
- end
12
-
13
- scenario "Adding new acceptance spec" do
14
- Dir.chdir @rails_app do
15
- `script/generate acceptance_spec document_creation`
16
- end
17
-
18
- File.exist?(@rails_app + "/spec/acceptance/document_creation_spec.rb").should be_true
19
- end
20
-
21
- scenario "Adding new acceptance spec (plural name)" do
22
- Dir.chdir @rails_app do
23
- `script/generate acceptance_spec creating_documents`
24
- end
25
-
26
- File.exist?(@rails_app + "/spec/acceptance/creating_documents_spec.rb").should be_true
27
- end
28
-
29
- scenario "Adding new acceptance spec (pascalized name)" do
30
- Dir.chdir @rails_app do
31
- `script/generate acceptance_spec DocumentCreation`
32
- end
33
-
34
- File.exist?(@rails_app + "/spec/acceptance/document_creation_spec.rb").should be_true
35
- end
36
-
37
- scenario "Adding new acceptance spec (name ending with _spec)" do
38
- Dir.chdir @rails_app do
39
- `script/generate acceptance_spec document_creation_spec`
40
- end
41
-
42
- File.exist?(@rails_app + "/spec/acceptance/document_creation_spec.rb").should be_true
43
- end
44
-
45
- end
@@ -1,51 +0,0 @@
1
- require File.dirname(__FILE__) + "/acceptance_helper.rb"
2
-
3
- feature "Acceptance spec execution", %q{
4
- In order to write better software
5
- As a ruby developer
6
- I want to execute acceptance specs
7
- } do
8
-
9
- scenario "Minimal acceptance spec" do
10
- spec_file = create_spec <<-SPEC
11
- require '#{File.dirname(__FILE__) + "/../../lib/steak"}'
12
- feature "Minimal spec" do
13
- scenario "First scenario" do
14
- true.should be_true
15
- end
16
- end
17
- SPEC
18
- output = run_spec spec_file
19
- output.should =~ /1 example, 0 failures/
20
- end
21
-
22
- scenario "Minimal acceptance spec that fails" do
23
- spec_file = create_spec <<-SPEC
24
- require '#{File.dirname(__FILE__) + "/../../lib/steak"}'
25
- feature "Minimal spec" do
26
- scenario "First scenario" do
27
- true.should be_false
28
- end
29
- end
30
- SPEC
31
- output = run_spec spec_file
32
- output.should =~ /1 example, 1 failure/
33
- end
34
-
35
- scenario "Acceptance spec with background" do
36
- spec_file = create_spec <<-SPEC
37
- require '#{File.dirname(__FILE__) + "/../../lib/steak"}'
38
- feature "Minimal spec" do
39
- background do
40
- @value = 17
41
- end
42
- scenario "First scenario" do
43
- @value.should == 17
44
- end
45
- end
46
- SPEC
47
- output = run_spec spec_file
48
- output.should =~ /1 example, 0 failures/
49
- end
50
-
51
- end
@@ -1,41 +0,0 @@
1
- require File.dirname(__FILE__) + "/acceptance_helper.rb"
2
-
3
- feature "Acceptance spec execution", %q{
4
- In order to write better web apps
5
- As a rails developer
6
- I want to execute acceptance specs
7
- } do
8
-
9
- scenario "Minimal acceptance spec" do
10
- rails_app = create_rails_app
11
- spec_file = create_spec :path => rails_app + "/spec/acceptance",
12
- :content => <<-SPEC
13
- require File.dirname(__FILE__) + "/acceptance_helper.rb"
14
- feature "Minimal spec" do
15
- scenario "First scenario" do
16
- RAILS_ENV.should_not be_empty
17
- RAILS_ENV.should == "test"
18
- end
19
- end
20
- SPEC
21
- output = run_spec spec_file
22
- output.should =~ /1 example, 0 failures/
23
- end
24
-
25
- scenario "Integration stuff" do
26
- rails_app = create_rails_app
27
- spec_file = create_spec :path => rails_app + "/spec/acceptance",
28
- :content => <<-SPEC
29
- require File.dirname(__FILE__) + "/acceptance_helper.rb"
30
- feature "Minimal spec" do
31
- scenario "First scenario" do
32
- get "/"
33
- response.should have_text(/No route matches/)
34
- end
35
- end
36
- SPEC
37
- output = run_spec spec_file
38
- output.should =~ /1 example, 0 failures/
39
- end
40
-
41
- end
@@ -1,24 +0,0 @@
1
- require File.dirname(__FILE__) + "/acceptance_helper.rb"
2
-
3
- feature "Steak generator for rails", %q{
4
- In order to quickly start to hack my rails project with steak
5
- As a developer
6
- I want to run a generator that sets everything up for me
7
- } do
8
-
9
- scenario "Running generator in an empty project" do
10
-
11
- rails_app = create_rails_app(:setup_steak => false)
12
-
13
- Dir.chdir rails_app do
14
- `script/generate steak`
15
- end
16
-
17
- File.exist?(rails_app + "/spec/acceptance/acceptance_helper.rb").should be_true
18
- File.exist?(rails_app + "/spec/acceptance/support/helpers.rb").should be_true
19
- File.exist?(rails_app + "/spec/acceptance/support/paths.rb").should be_true
20
- File.exist?(rails_app + "/lib/tasks/steak.rake").should be_true
21
-
22
- end
23
-
24
- end