pickle 0.1.22 → 0.1.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,17 @@
1
+ == 0.1.23 - 22 Nov 2009
2
+
3
+ * 1 major improvement
4
+ * script/generate pickle now adds its own pickle.rb support file, making it easier to regenerate cucumber
5
+ when a new release of cucumber appears [schlick, ianwhite]
6
+
7
+ * 1 minor improvement
8
+ * docs: more links
9
+
10
+
1
11
  == 0.1.22 - 7 Nov 2009
2
12
 
3
13
  * 2 minor enhancements
4
- * Improved docs to include instructions for FactoryGirl users, and linksresources for pickle users
14
+ * Improved docs to include instructions for FactoryGirl users, and links/resources for pickle users
5
15
  * Ruby 1.9.1 compatibility changes
6
16
 
7
17
 
@@ -19,6 +19,8 @@ building complex givens which require a bunch of models collaborating
19
19
 
20
20
  <b>Railscast</b> presentation: http://railscasts.com/episodes/186-pickle-with-cucumber
21
21
 
22
+ <b>Blog articles</b>: {dynamic50: Integration testing with cucumber and pickle}[http://blog.dynamic50.com/index.php/2009/04/integration-testing-with-cucumber-and-pickle/], {rubyflare: pickle my cucumber}[http://rubyflare.com/2009/10/28/pickle-my-cucumber/]
23
+
22
24
  == Install
23
25
 
24
26
  Install pickle either as a rails plugin, or a gem
@@ -27,7 +29,7 @@ Install pickle either as a rails plugin, or a gem
27
29
  sudo gem install pickle
28
30
 
29
31
  # gem dependency (in config/environments/cucumber.rb)
30
- gem 'pickle'
32
+ config.gem 'pickle'
31
33
 
32
34
  # plugin
33
35
  script/plugin install git://github.com/ianwhite/pickle.git
@@ -101,7 +103,9 @@ If that doesn't solve loading issues then require your factories.rb file directl
101
103
 
102
104
  You can tell pickle to use another factory adapter (see Pickle::Adapter), or
103
105
  create mappings from english expressions to pickle model names. You can also
104
- override many of the options on the Pickle::Config object if you so choose
106
+ override many of the options on the Pickle::Config object if you so choose.
107
+
108
+ In: <tt>features/support/pickle.rb</tt>
105
109
 
106
110
  require 'pickle/world'
107
111
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.22
1
+ 0.1.23
@@ -3,52 +3,58 @@ Feature: allow pickle to generate steps
3
3
  As a dev
4
4
  I want to be able to generate steps
5
5
 
6
- Scenario: cucumber is not yet installed
7
- When I run "script/generate pickle"
8
- Then I should see "try running script/generate cucumber"
9
-
10
- Scenario Outline: script/generate pickle on fresh cuc install
6
+ # Do we care anymore?
7
+ # Scenario: cucumber is not yet installed
8
+ # When I run "script/generate pickle"
9
+ # Then I should see "try running script/generate cucumber"
10
+
11
+ Scenario: script/generate pickle on fresh cuke install
11
12
  Given cucumber has been freshly generated
12
- When I run "<GENERATE PICKLE>"
13
- Then the file <STEPS FILE> should exist
14
- And the file features/support/env.rb should match /<ENV.RB SHOULD MATCH>/
15
-
16
- Examples:
17
- | GENERATE PICKLE | STEPS FILE | ENV.RB SHOULD MATCH |
18
- | script/generate pickle | features/step_definitions/pickle_steps.rb | require 'pickle\/world' |
19
- | script/generate pickle | features/step_definitions/pickle_steps.rb | Example of configuring pickle: |
20
- | script/generate pickle email| features/step_definitions/email_steps.rb | require 'pickle\/email\/world' |
13
+ When I run "script/generate pickle"
14
+ Then the file features/support/pickle.rb should exist
15
+ And the file features/support/pickle.rb should match /require 'pickle\/world'/
16
+ And the file features/step_definitions/pickle_steps.rb should be identical to the local step_definitions/pickle_steps.rb
21
17
 
22
- Scenario: script/generate pickle path on fresh cuc install
18
+ Scenario: script/generate pickle path on fresh cuke install
23
19
  Given cucumber has been freshly generated
24
20
  When I run "script/generate pickle path"
25
- Then the file features/support/env.rb should match /require 'pickle\/world'/
26
- And the file features/support/paths.rb should match /added by script/generate pickle path/
21
+ Then the file features/support/pickle.rb should exist
22
+ And the file features/support/pickle.rb should match /require 'pickle\/world'/
23
+ And the file features/support/pickle.rb should match /require 'pickle\/path\/world'/
24
+ And the file features/step_definitions/pickle_steps.rb should be identical to the local step_definitions/pickle_steps.rb
27
25
  And the file features/support/paths.rb should be identical to the local support/paths.rb
28
26
 
29
- Scenario Outline: script/generate pickle, when env.rb has already requires pickle
27
+ Scenario: script/generate pickle email on fresh cuke install
30
28
  Given cucumber has been freshly generated
31
- And env.rb already requires <ENV.RB CONTAINS>
32
- When I run "<GENERATE PICKLE>"
33
- Then the file features/support/env.rb should not match /<ENV.RB SHOULD NOT MATCH>/
34
-
35
- Examples:
36
- | ENV.RB CONTAINS | GENERATE PICKLE | ENV.RB SHOULD NOT MATCH |
37
- | pickle/world | script/generate pickle | Example of configuring pickle: |
38
- | pickle/world | script/generate pickle | require 'pickle\/world'.*require 'pickle\/world' |
39
- | pickle/path/world | script/generate pickle path | require 'pickle\/path\/world'.*require 'pickle\/path\/world' |
40
- | pickle/email/world| script/generate pickle email | require 'pickle\/email\/world'.*require 'pickle\/email\/world'|
41
-
42
- Scenario: script/generate pickle page email
29
+ When I run "script/generate pickle email"
30
+ Then the file features/support/pickle.rb should exist
31
+ And the file features/support/pickle.rb should match /require 'pickle\/world'/
32
+ And the file features/support/pickle.rb should match /require 'pickle\/email\/world'/
33
+ And the file features/step_definitions/pickle_steps.rb should be identical to the local step_definitions/pickle_steps.rb
34
+ And the file features/step_definitions/email_steps.rb should be identical to the local step_definitions/email_steps.rb
35
+
36
+ Scenario: script/generate pickle path email on fresh cuke install
43
37
  Given cucumber has been freshly generated
44
38
  When I run "script/generate pickle path email"
45
- Then the file features/step_definitions/email_steps.rb should exist
46
- And the file features/step_definitions/pickle_steps.rb should exist
47
- And the file features/support/env.rb should match /require 'pickle\/world'/
48
- And the file features/support/env.rb should match /require 'pickle\/path\/world'/
49
- And the file features/support/env.rb should match /require 'pickle\/email\/world'/
50
- And the file features/support/paths.rb should match /added by script/generate pickle path/
51
-
52
-
39
+ Then the file features/support/pickle.rb should exist
40
+ And the file features/support/pickle.rb should be identical to the local support/pickle.rb
41
+ And the file features/support/pickle.rb should match /require 'pickle\/world'/
42
+ And the file features/support/pickle.rb should match /require 'pickle\/path\/world'/
43
+ And the file features/support/pickle.rb should match /require 'pickle\/email\/world'/
44
+ And the file features/step_definitions/pickle_steps.rb should be identical to the local step_definitions/pickle_steps.rb
45
+ And the file features/support/paths.rb should be identical to the local support/paths.rb
46
+ And the file features/step_definitions/email_steps.rb should be identical to the local step_definitions/email_steps.rb
53
47
 
54
-
48
+ Scenario: regenerating pickle
49
+ Given cucumber has been freshly generated
50
+ And pickle path email has been freshly generated
51
+ When I run "script/generate pickle path email"
52
+ Then the file features/support/pickle.rb should match /require 'pickle\/world'/
53
+ And the file features/support/pickle.rb should match /require 'pickle\/path\/world'/
54
+ And the file features/support/pickle.rb should match /require 'pickle\/email\/world'/
55
+ And the file features/step_definitions/pickle_steps.rb should be identical to the local step_definitions/pickle_steps.rb
56
+ And the file features/support/paths.rb should be identical to the local support/paths.rb
57
+ And the file features/step_definitions/email_steps.rb should be identical to the local step_definitions/email_steps.rb
58
+ But the file features/support/pickle.rb should not match /require 'pickle\/world'.*require 'pickle\/world'/
59
+ And the file features/support/pickle.rb should not match /require 'pickle\/path\/world'.*require 'pickle\/path\/world'/
60
+ And the file features/support/pickle.rb should not match /require 'pickle\/email\/world'.*require 'pickle\/email\/world'/
@@ -11,6 +11,10 @@ Given(/^cucumber has been freshly generated$/) do
11
11
  `cd #{Rails.root}; script/generate cucumber -f`
12
12
  end
13
13
 
14
+ Given(/^pickle path email has been freshly generated$/) do
15
+ `cd #{Rails.root}; script/generate pickle path email`
16
+ end
17
+
14
18
  Given(/^env\.rb already requires (.+)$/) do |file|
15
19
  File.open("#{Rails.root}/features/support/env.rb", "a") do |env|
16
20
  env << "require '#{file}'\n"
@@ -37,6 +41,6 @@ Then(/^the file (.+?) should not match \/(.*?)\/$/) do |file, regexp|
37
41
  File.read("#{Rails.root}/#{file}").should_not match(/#{regexp}/m)
38
42
  end
39
43
 
40
- Then /^the file features\/support\/paths\.rb should be identical to the local support\/paths\.rb$/ do
41
- File.read("#{Rails.root}/features/support/paths.rb").should == File.read("#{File.dirname(__FILE__)}/../support/paths.rb")
42
- end
44
+ Then /^the file ([^ ]+) should be identical to the local (.+)$/ do |generated_file, source_file|
45
+ File.read("#{Rails.root}/#{generated_file}").should == File.read("#{File.dirname(__FILE__)}/../#{source_file}")
46
+ end
@@ -1,35 +1,47 @@
1
+ # IMPORTANT: This file was generated by Cucumber 0.4.4
2
+ # Edit at your own peril - it's recommended to regenerate this file
3
+ # in the future when you upgrade to a newer version of Cucumber.
4
+ # Consider adding your own code to a new file instead of editing this one.
5
+
1
6
  # Sets up the Rails environment for Cucumber
2
- ENV["RAILS_ENV"] = "test"
3
- require File.expand_path(File.dirname(__FILE__) + '../../../../../../config/environment')
7
+ ENV["RAILS_ENV"] ||= "cucumber"
8
+ require File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
4
9
  require 'cucumber/rails/world'
5
10
 
11
+ # If you set this to true, each scenario will run in a database transaction.
12
+ # You can still turn off transactions on a per-scenario basis, simply tagging
13
+ # a feature or scenario with the @no-txn tag.
14
+ #
15
+ # If you set this to false, transactions will be off for all scenarios,
16
+ # regardless of whether you use @no-txn or not.
17
+ #
18
+ # Beware that turning transactions off will leave data in your database
19
+ # after each scenario, which can lead to hard-to-debug failures in
20
+ # subsequent scenarios. If you do this, we recommend you create a Before
21
+ # block that will explicitly put your database in a known state.
22
+ Cucumber::Rails::World.use_transactional_fixtures = true
23
+
24
+ # If you set this to false, any error raised from within your app will bubble
25
+ # up to your step definition and out to cucumber unless you catch it somewhere
26
+ # on the way. You can make Rails rescue errors and render error pages on a
27
+ # per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
28
+ #
29
+ # If you set this to true, Rails will rescue all errors and render error
30
+ # pages, more or less in the same way your application would behave in the
31
+ # default production environment. It's not recommended to do this for all
32
+ # of your scenarios, as this makes it hard to discover errors in your application.
33
+ ActionController::Base.allow_rescue = false
34
+
35
+ require 'cucumber'
36
+ # Comment out the next line if you don't want Cucumber Unicode support
6
37
  require 'cucumber/formatter/unicode'
38
+ require 'cucumber/webrat/element_locator' # Lets you do table.diff!(element_at('#my_table_or_dl_or_ul_or_ol').to_table)
39
+ require 'cucumber/rails/rspec'
7
40
 
8
41
  require 'webrat'
9
-
42
+ require 'webrat/core/matchers'
10
43
  Webrat.configure do |config|
11
44
  config.mode = :rails
45
+ config.open_error_files = false # Set to true if you want error pages to pop up in the browser
12
46
  end
13
47
 
14
-
15
- # Comment out the next line if you're not using RSpec's matchers (should / should_not) in your steps.
16
- require 'cucumber/rails/rspec'
17
- require 'webrat/core/matchers'
18
-
19
- Cucumber::Rails::World.use_transactional_fixtures = true
20
-
21
- # Pickle
22
- require 'pickle/world'
23
- require 'pickle/path/world'
24
- require 'pickle/email/world'
25
-
26
- Pickle.configure do |c|
27
- c.map 'I', :to => 'user: "me"'
28
- c.map 'killah fork', :to => 'fancy fork: "of cornwood"'
29
- end
30
-
31
- # test app setup
32
- __APP__ = File.expand_path(File.join(File.dirname(__FILE__), '../app'))
33
- require "#{__APP__}/app"
34
- require "#{__APP__}/factories"
35
- require "#{__APP__}/blueprints"
@@ -0,0 +1,26 @@
1
+ # this file generated by script/generate pickle [paths] [email]
2
+ #
3
+ # Make sure that you are loading your factory of choice in your cucumber environment
4
+ #
5
+ # For machinist add: features/support/machinist.rb
6
+ #
7
+ # require 'machinist/active_record' # or your chosen adaptor
8
+ # require File.dirname(__FILE__) + '/../../spec/blueprints' # or wherever your blueprints are
9
+ # Before { Sham.reset } # to reset Sham's seed between scenarios so each run has same random sequences
10
+ #
11
+ # For FactoryGirl add: features/support/factory_girl.rb
12
+ #
13
+ # require 'factory_girl'
14
+ # require File.dirname(__FILE__) + '/../../spec/factories' # or wherever your factories are
15
+ #
16
+ # You may also need to add gem dependencies on your factory of choice in <tt>config/environments/cucumber.rb</tt>
17
+
18
+ require 'pickle/world'
19
+ # Example of configuring pickle:
20
+ #
21
+ # Pickle.configure do |config|
22
+ # config.adapters = [:machinist]
23
+ # config.map 'I', 'myself', 'me', 'my', :to => 'user: "me"'
24
+ # end
25
+ require 'pickle/path/world'
26
+ require 'pickle/email/world'
@@ -0,0 +1,10 @@
1
+ # test app setup
2
+ __APP__ = File.expand_path(File.join(File.dirname(__FILE__), '../app'))
3
+ require "#{__APP__}/app"
4
+ require "#{__APP__}/factories"
5
+ require "#{__APP__}/blueprints"
6
+
7
+ Pickle.configure do |c|
8
+ c.map 'I', :to => 'user: "me"'
9
+ c.map 'killah fork', :to => 'fancy fork: "of cornwood"'
10
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pickle}
8
- s.version = "0.1.22"
8
+ s.version = "0.1.23"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ian White"]
12
- s.date = %q{2009-11-07}
12
+ s.date = %q{2009-11-22}
13
13
  s.description = %q{Easy model creation and reference in your cucumber features}
14
14
  s.email = %q{ian.w.white@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -43,6 +43,8 @@ Gem::Specification.new do |s|
43
43
  "features/step_definitions/pickle_steps.rb",
44
44
  "features/support/env.rb",
45
45
  "features/support/paths.rb",
46
+ "features/support/pickle.rb",
47
+ "features/support/pickle_app.rb",
46
48
  "garlic.rb",
47
49
  "init.rb",
48
50
  "lib/pickle.rb",
@@ -62,8 +64,8 @@ Gem::Specification.new do |s|
62
64
  "pickle.gemspec",
63
65
  "rails_generators/pickle/pickle_generator.rb",
64
66
  "rails_generators/pickle/templates/email_steps.rb",
65
- "rails_generators/pickle/templates/env.rb",
66
67
  "rails_generators/pickle/templates/paths.rb",
68
+ "rails_generators/pickle/templates/pickle.rb",
67
69
  "rails_generators/pickle/templates/pickle_steps.rb",
68
70
  "spec/lib/pickle_adapter_spec.rb",
69
71
  "spec/lib/pickle_config_spec.rb",
@@ -1,7 +1,6 @@
1
1
  class PickleGenerator < Rails::Generator::Base
2
2
  def initialize(args, options)
3
3
  super(args, options)
4
- File.exists?('features/support/env.rb') or raise "features/support/env.rb not found, try running script/generate cucumber"
5
4
  @generate_email_steps = args.include?('email')
6
5
  if @generate_path_steps = args.include?('path') || args.include?('paths')
7
6
  File.exists?('features/support/paths.rb') or raise "features/support/paths.rb not found, is your cucumber up to date?"
@@ -11,31 +10,30 @@ class PickleGenerator < Rails::Generator::Base
11
10
  def manifest
12
11
  record do |m|
13
12
  m.directory File.join('features/step_definitions')
13
+ m.directory File.join('features/support')
14
14
 
15
- current_env = File.read('features/support/env.rb')
16
- env_assigns = {:current_env => current_env, :pickle => false, :pickle_path => false, :pickle_email => false}
15
+ current_pickle = File.exists?('features/support/pickle.rb') ? File.read('features/support/pickle.rb') : ''
16
+ pickle_assigns = {:pickle_path => false, :pickle_email => false}
17
17
 
18
18
  if @generate_path_steps
19
- env_assigns[:pickle_path] = true unless current_env.include?("require 'pickle/path/world'")
19
+ pickle_assigns[:pickle_path] = true
20
20
  current_paths = File.read('features/support/paths.rb')
21
21
  unless current_paths.include?('#{capture_model}')
22
22
  if current_paths =~ /^(.*)(\n\s+else\n\s+raise "Can't find.*".*$)/m
23
- env_assigns[:current_paths_header] = $1
24
- env_assigns[:current_paths_footer] = $2
25
- m.template 'paths.rb', File.join('features/support', "paths.rb"), :assigns => env_assigns, :collision => :force
23
+ pickle_assigns[:current_paths_header] = $1
24
+ pickle_assigns[:current_paths_footer] = $2
25
+ m.template 'paths.rb', File.join('features/support', 'paths.rb'), :assigns => pickle_assigns, :collision => :force
26
26
  end
27
27
  end
28
28
  end
29
29
 
30
30
  if @generate_email_steps
31
- env_assigns[:pickle_email] = true unless current_env.include?("require 'pickle/email/world'")
32
- m.template 'email_steps.rb', File.join('features/step_definitions', "email_steps.rb")
31
+ pickle_assigns[:pickle_email] = true
32
+ m.template 'email_steps.rb', File.join('features/step_definitions', 'email_steps.rb')
33
33
  end
34
-
35
- env_assigns[:pickle] = true unless current_env.include?("require 'pickle/world'")
36
- m.template 'pickle_steps.rb', File.join('features/step_definitions', "pickle_steps.rb")
37
-
38
- m.template 'env.rb', File.join('features/support', "env.rb"), :assigns => env_assigns, :collision => :force
34
+
35
+ m.template 'pickle_steps.rb', File.join('features/step_definitions', 'pickle_steps.rb')
36
+ m.template 'pickle.rb', File.join('features/support', 'pickle.rb'), :assigns => pickle_assigns
39
37
  end
40
38
  end
41
39
  end
@@ -0,0 +1,28 @@
1
+ # this file generated by script/generate pickle [paths] [email]
2
+ #
3
+ # Make sure that you are loading your factory of choice in your cucumber environment
4
+ #
5
+ # For machinist add: features/support/machinist.rb
6
+ #
7
+ # require 'machinist/active_record' # or your chosen adaptor
8
+ # require File.dirname(__FILE__) + '/../../spec/blueprints' # or wherever your blueprints are
9
+ # Before { Sham.reset } # to reset Sham's seed between scenarios so each run has same random sequences
10
+ #
11
+ # For FactoryGirl add: features/support/factory_girl.rb
12
+ #
13
+ # require 'factory_girl'
14
+ # require File.dirname(__FILE__) + '/../../spec/factories' # or wherever your factories are
15
+ #
16
+ # You may also need to add gem dependencies on your factory of choice in <tt>config/environments/cucumber.rb</tt>
17
+
18
+ require 'pickle/world'
19
+ # Example of configuring pickle:
20
+ #
21
+ # Pickle.configure do |config|
22
+ # config.adapters = [:machinist]
23
+ # config.map 'I', 'myself', 'me', 'my', :to => 'user: "me"'
24
+ # end
25
+ <%- if pickle_path -%>require 'pickle/path/world'
26
+ <%- end -%>
27
+ <%- if pickle_email -%>require 'pickle/email/world'
28
+ <%- end -%>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pickle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.22
4
+ version: 0.1.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian White
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-07 00:00:00 +00:00
12
+ date: 2009-11-22 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -49,6 +49,8 @@ files:
49
49
  - features/step_definitions/pickle_steps.rb
50
50
  - features/support/env.rb
51
51
  - features/support/paths.rb
52
+ - features/support/pickle.rb
53
+ - features/support/pickle_app.rb
52
54
  - garlic.rb
53
55
  - init.rb
54
56
  - lib/pickle.rb
@@ -68,8 +70,8 @@ files:
68
70
  - pickle.gemspec
69
71
  - rails_generators/pickle/pickle_generator.rb
70
72
  - rails_generators/pickle/templates/email_steps.rb
71
- - rails_generators/pickle/templates/env.rb
72
73
  - rails_generators/pickle/templates/paths.rb
74
+ - rails_generators/pickle/templates/pickle.rb
73
75
  - rails_generators/pickle/templates/pickle_steps.rb
74
76
  - spec/lib/pickle_adapter_spec.rb
75
77
  - spec/lib/pickle_config_spec.rb
@@ -1,14 +0,0 @@
1
- <%= current_env -%>
2
- <%- if pickle -%>
3
- require 'pickle/world'
4
- # Example of configuring pickle:
5
- #
6
- # Pickle.configure do |config|
7
- # config.adapters = [:machinist]
8
- # config.map 'I', 'myself', 'me', 'my', :to => 'user: "me"'
9
- # end
10
- <%- end -%>
11
- <%- if pickle_path -%>require 'pickle/path/world'
12
- <%- end -%>
13
- <%- if pickle_email -%>require 'pickle/email/world'
14
- <%- end -%>