steak 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -36,8 +36,6 @@ 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
-
41
39
  === Not in Rails
42
40
 
43
41
  Just install and require the damned gem!
@@ -49,8 +47,8 @@ Then in your spec or spec helper:
49
47
  require 'steak'
50
48
 
51
49
  That's all. You don't really need to require RSpec.
52
-
53
- === In Rails
50
+
51
+ === In Rails 2.x (stable branch)
54
52
 
55
53
  Assuming you have already setup rspec-rails, add this to your project's <tt>config/environments/test.rb</tt>:
56
54
 
@@ -86,6 +84,51 @@ You run your acceptance specs just like your regular specs. Individually...
86
84
 
87
85
  $ rake spec:acceptance
88
86
 
87
+ === In Rails 3 (master branch)
88
+
89
+ Add this to your project's <tt>Gemfile</tt>:
90
+
91
+ gem 'steak', '>= 0.4.0.a5'
92
+
93
+ And install it:
94
+
95
+ $ bundle install
96
+
97
+ Run the generator:
98
+
99
+ $ rails generate steak
100
+
101
+ That will create some basic helper files and directory structure under the +spec/acceptance+ directory, already configured for +Capybara+. If you want to use +Webrat+, just pass it to the generator:
102
+
103
+ $ rails generate steak --webrat
104
+
105
+ Spend one minute on getting familiar with the structure and files you've got.
106
+
107
+ Now you may want to create your first acceptance spec:
108
+
109
+ $ rails generate acceptance_spec this_is_my_first_feature
110
+
111
+ You run your acceptance specs just like your regular specs. Individually...
112
+
113
+ $ spec spec/acceptance/this_is_my_first_feature_spec.rb
114
+
115
+ ...or all together:
116
+
117
+ $ spec spec/acceptance
118
+
119
+ ...you can also do:
120
+
121
+ $ rake spec:acceptance
122
+
123
+ == Resources
124
+
125
+ - Source: http://github.com/cavalle/steak
126
+ - Issues: http://github.com/cavalle/steak/issues
127
+ - Group: http://groups.google.com/group/steakrb
128
+ - IRC channel: #steakrb on freenode
129
+ - Tutorial: http://jeffkreeftmeijer.com/2010/steak-because-cucumber-is-for-vegetarians/
130
+ - Hashtag: #steakrb
131
+
89
132
  == Credits
90
133
 
91
134
  Steak was created by Luismi Cavallé and improved thanks to the love from:
@@ -94,5 +137,8 @@ Steak was created by Luismi Cavallé and improved thanks to the love from:
94
137
  - Felipe Talavera
95
138
  - Paco Guzmán
96
139
  - Jeff Kreeftmeijer
140
+ - Jaime Iniesta
141
+ - Emili Parreño
142
+ - Andreas Wolff
97
143
 
98
- Copyright (c) 2009, 2010 Luismi Cavallé, released under the MIT license
144
+ Copyright (c) 2009, 2010 Luismi Cavallé, released under the MIT license
data/Rakefile CHANGED
@@ -9,57 +9,8 @@ Spec::Rake::SpecTask.new do |t|
9
9
  t.libs = ["spec"]
10
10
  end
11
11
 
12
-
13
12
  task :default => ["spec"]
14
13
 
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.7"
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/**/*,generators/**/*}")
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("rspec")
42
- end
43
-
44
- # This task actually builds the gem. We also regenerate a static
45
- # .gemspec file, which is useful if something (i.e. GitHub) will
46
- # be automatically building a gem for this project. If you're not
47
- # using GitHub, edit as appropriate.
48
- #
49
- # To publish your gem online, install the 'gemcutter' gem; Read more
50
- # about that here: http://gemcutter.org/pages/gem_docs
51
- Rake::GemPackageTask.new(spec) do |pkg|
52
- pkg.gem_spec = spec
53
- end
54
-
55
- desc "Build the gemspec file #{spec.name}.gemspec"
56
- task :gemspec do
57
- file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
58
- File.open(file, "w") {|f| f << spec.to_ruby }
59
- end
60
-
61
- task :package => :gemspec
62
-
63
14
  # Generate documentation
64
15
  Rake::RDocTask.new do |rd|
65
16
  rd.main = "README.rdoc"
@@ -1,6 +1,6 @@
1
1
  unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
2
2
 
3
- load File.dirname(__FILE__) + '/rspec.rake'
3
+ require 'spec/rake/spectask'
4
4
 
5
5
  namespace :spec do
6
6
  desc "Run the code examples in spec/acceptance"
@@ -8,6 +8,13 @@ namespace :spec do
8
8
  t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
9
9
  t.spec_files = FileList["spec/acceptance/**/*_spec.rb"]
10
10
  end
11
+
12
+ # Setup stats to include acceptance specs
13
+ task :statsetup do
14
+ require 'code_statistics'
15
+ ::STATS_DIRECTORIES << %w(Acceptance\ specs spec/acceptance) if File.exist?('spec/acceptance')
16
+ ::CodeStatistics::TEST_TYPES << "Acceptance specs" if File.exist?('spec/acceptance')
17
+ end
11
18
  end
12
19
 
13
20
  end
@@ -0,0 +1,55 @@
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
+ FileUtils.rm path + '/public/index.html'
21
+ File.open(path + "/config/environments/test.rb", "a") do |file|
22
+ file.write "\nconfig.gem 'rspec-rails', :lib => false\n"
23
+ end
24
+ FileUtils.cp_r File.dirname(__FILE__) + "/../../", path + "/vendor/plugins/steak"
25
+
26
+ Dir.chdir path do
27
+ `script/generate rspec`
28
+ end
29
+
30
+ unless options[:setup_steak] == false
31
+ Dir.chdir path do
32
+ `script/generate steak`
33
+ end
34
+ end
35
+
36
+ path
37
+ end
38
+
39
+ end
40
+
41
+ module HelperMethods
42
+ def run_spec(file_path)
43
+ `spec #{file_path} 2>&1`
44
+ end
45
+ end
46
+
47
+ class String
48
+ CHARS = ('a'..'z').to_a + ('A'..'Z').to_a
49
+ def self.random(size = 8)
50
+ (0..size).map{ CHARS[rand(CHARS.length)] }.join
51
+ end
52
+ end
53
+
54
+ Spec::Runner.configuration.include(Factories)
55
+ Spec::Runner.configuration.include(HelperMethods)
@@ -0,0 +1,45 @@
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
@@ -0,0 +1,51 @@
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
@@ -0,0 +1,40 @@
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 be_test
17
+ end
18
+ end
19
+ SPEC
20
+ output = run_spec spec_file
21
+ output.should =~ /1 example, 0 failures/
22
+ end
23
+
24
+ scenario "Integration stuff" do
25
+ rails_app = create_rails_app
26
+ spec_file = create_spec :path => rails_app + "/spec/acceptance",
27
+ :content => <<-SPEC
28
+ require File.dirname(__FILE__) + "/acceptance_helper.rb"
29
+ feature "Minimal spec" do
30
+ scenario "First scenario" do
31
+ get "/"
32
+ response.should have_text(/No route matches/)
33
+ end
34
+ end
35
+ SPEC
36
+ output = run_spec spec_file
37
+ output.should =~ /1 example, 0 failures/
38
+ end
39
+
40
+ end
@@ -0,0 +1,96 @@
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
+ rails_app = create_rails_app(:setup_steak => false)
11
+
12
+ Dir.chdir rails_app do
13
+ `script/generate steak`
14
+ end
15
+
16
+ File.exist?(rails_app + "/spec/acceptance/acceptance_helper.rb").should be_true
17
+ File.exist?(rails_app + "/spec/acceptance/support/helpers.rb").should be_true
18
+ File.exist?(rails_app + "/spec/acceptance/support/paths.rb").should be_true
19
+ File.exist?(rails_app + "/lib/tasks/steak.rake").should be_true
20
+ end
21
+
22
+ scenario "Running generator with capybara by default" do
23
+ rails_app = create_rails_app(:setup_steak => false)
24
+
25
+ Dir.chdir rails_app do
26
+ `script/generate steak`
27
+ end
28
+
29
+ spec_file = create_spec :path => rails_app + "/spec/acceptance",
30
+ :content => <<-SPEC
31
+ require File.dirname(__FILE__) + "/acceptance_helper.rb"
32
+ feature "Capybara spec" do
33
+ scenario "First scenario" do
34
+ visit "/"
35
+ page.should have_content('No route matches')
36
+ end
37
+ end
38
+ SPEC
39
+ output = run_spec spec_file
40
+ output.should =~ /1 example, 0 failures/
41
+ end
42
+
43
+ scenario "Running generator with webrat" do
44
+ rails_app = create_rails_app(:setup_steak => false)
45
+
46
+ Dir.chdir rails_app do
47
+ `script/generate steak --webrat`
48
+ end
49
+
50
+ spec_file = create_spec :path => rails_app + "/spec/acceptance",
51
+ :content => <<-SPEC
52
+ require File.dirname(__FILE__) + "/acceptance_helper.rb"
53
+ feature "Capybara spec" do
54
+ scenario "First scenario" do
55
+ visit "/"
56
+ response.should contain('No route matches')
57
+ end
58
+ end
59
+ SPEC
60
+ output = run_spec spec_file
61
+ output.should =~ /1 example, 0 failures/
62
+ end
63
+
64
+ scenario "Running rake stats" do
65
+ rails_app = create_rails_app
66
+
67
+ Dir.chdir rails_app do
68
+ `script/generate steak`
69
+ `rake stats`.should =~ /Acceptance specs/
70
+ end
71
+ end
72
+
73
+ scenario "Running specs with rake" do
74
+ rails_app = create_rails_app(:setup_steak => true)
75
+
76
+ spec_file = create_spec :path => rails_app + "/spec/acceptance",
77
+ :content => <<-SPEC
78
+ require File.dirname(__FILE__) + "/acceptance_helper.rb"
79
+ feature "Basic spec" do
80
+ scenario "First scenario" do
81
+ true.should == true
82
+ end
83
+ end
84
+ SPEC
85
+
86
+ Dir.chdir rails_app do
87
+ `rake db:create db:migrate db:test:prepare`
88
+
89
+ output = `rake spec:acceptance`
90
+ output.should =~ /1 example, 0 failures/
91
+
92
+ output = `rake`
93
+ output.should =~ /1 example, 0 failures/
94
+ end
95
+ end
96
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steak
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 3
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 3
8
- - 7
9
- version: 0.3.7
9
+ - 8
10
+ version: 0.3.8
10
11
  platform: ruby
11
12
  authors:
12
13
  - "Luismi Cavall\xC3\xA9"
@@ -14,29 +15,33 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-06 00:00:00 +02:00
18
+ date: 2010-05-31 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rspec
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 27
27
30
  segments:
31
+ - 1
32
+ - 3
28
33
  - 0
29
- version: "0"
34
+ version: 1.3.0
30
35
  type: :runtime
31
36
  version_requirements: *id001
32
- description: Minimalist acceptance testing on top of RSpec
37
+ description: 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)
33
38
  email: luismi@lmcavalle.com
34
39
  executables: []
35
40
 
36
41
  extensions: []
37
42
 
38
- extra_rdoc_files:
39
- - README.rdoc
43
+ extra_rdoc_files: []
44
+
40
45
  files:
41
46
  - init.rb
42
47
  - MIT-LICENSE
@@ -52,36 +57,44 @@ files:
52
57
  - generators/steak/templates/paths.rb
53
58
  - generators/steak/templates/steak.rake
54
59
  - generators/steak/USAGE
60
+ - spec/acceptance/acceptance_helper.rb
61
+ - spec/acceptance/acceptance_spec_generator_spec.rb
62
+ - spec/acceptance/basic_spec.rb
63
+ - spec/acceptance/rails_spec.rb
64
+ - spec/acceptance/steak_generator_spec.rb
55
65
  has_rdoc: true
56
66
  homepage: http://github.com/cavalle/steak
57
67
  licenses: []
58
68
 
59
69
  post_install_message:
60
- rdoc_options:
61
- - --main
62
- - README.rdoc
70
+ rdoc_options: []
71
+
63
72
  require_paths:
64
73
  - lib
65
74
  required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
66
76
  requirements:
67
77
  - - ">="
68
78
  - !ruby/object:Gem::Version
79
+ hash: 3
69
80
  segments:
70
81
  - 0
71
82
  version: "0"
72
83
  required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
73
85
  requirements:
74
86
  - - ">="
75
87
  - !ruby/object:Gem::Version
88
+ hash: 3
76
89
  segments:
77
90
  - 0
78
91
  version: "0"
79
92
  requirements: []
80
93
 
81
94
  rubyforge_project:
82
- rubygems_version: 1.3.6
95
+ rubygems_version: 1.3.7
83
96
  signing_key:
84
97
  specification_version: 3
85
- 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)
98
+ summary: Minimalist acceptance testing on top of Rspec
86
99
  test_files: []
87
100