spbtv_pickle 0.5.1

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.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +10 -0
  5. data/Gemfile +3 -0
  6. data/Gemfile.lock.development +158 -0
  7. data/History.txt +499 -0
  8. data/License.txt +20 -0
  9. data/README.md +566 -0
  10. data/Rakefile +20 -0
  11. data/Rakefile.d/cucumber.rake +27 -0
  12. data/Rakefile.d/release.rake +44 -0
  13. data/Rakefile.d/rspec.rake +3 -0
  14. data/Rakefile.d/yard.rake +5 -0
  15. data/Todo.txt +3 -0
  16. data/autotest/discover.rb +9 -0
  17. data/features/app/app.rb +128 -0
  18. data/features/app/blueprints.rb +6 -0
  19. data/features/app/fabricators.rb +6 -0
  20. data/features/app/factories.rb +25 -0
  21. data/features/app/views/notifier/email.erb +1 -0
  22. data/features/app/views/notifier/user_email.erb +6 -0
  23. data/features/email/email.feature +64 -0
  24. data/features/generator/generators.feature +59 -0
  25. data/features/path/models_page.feature +44 -0
  26. data/features/path/named_route_page.feature +10 -0
  27. data/features/pickle/create_from_active_record.feature +83 -0
  28. data/features/pickle/create_from_fabrication.feature +46 -0
  29. data/features/pickle/create_from_factory_girl.feature +66 -0
  30. data/features/pickle/create_from_machinist.feature +46 -0
  31. data/features/step_definitions/email_steps.rb +1 -0
  32. data/features/step_definitions/extra_email_steps.rb +12 -0
  33. data/features/step_definitions/fork_steps.rb +4 -0
  34. data/features/step_definitions/generator_steps.rb +52 -0
  35. data/features/step_definitions/path_steps.rb +14 -0
  36. data/features/step_definitions/pickle_steps.rb +1 -0
  37. data/features/step_definitions/raise_error_steps.rb +7 -0
  38. data/features/support/email.rb +1 -0
  39. data/features/support/env.rb +14 -0
  40. data/features/support/paths.rb +47 -0
  41. data/features/support/pickle.rb +27 -0
  42. data/features/support/pickle_app.rb +4 -0
  43. data/init.rb +0 -0
  44. data/lib/generators/pickle_generator.rb +44 -0
  45. data/lib/pickle.rb +26 -0
  46. data/lib/pickle/adapter.rb +183 -0
  47. data/lib/pickle/adapters/active_record.rb +67 -0
  48. data/lib/pickle/adapters/data_mapper.rb +42 -0
  49. data/lib/pickle/adapters/mongoid.rb +54 -0
  50. data/lib/pickle/config.rb +49 -0
  51. data/lib/pickle/email.rb +87 -0
  52. data/lib/pickle/email/parser.rb +18 -0
  53. data/lib/pickle/email/world.rb +13 -0
  54. data/lib/pickle/parser.rb +65 -0
  55. data/lib/pickle/parser/matchers.rb +87 -0
  56. data/lib/pickle/path.rb +45 -0
  57. data/lib/pickle/path/world.rb +5 -0
  58. data/lib/pickle/session.rb +244 -0
  59. data/lib/pickle/session/parser.rb +34 -0
  60. data/lib/pickle/version.rb +3 -0
  61. data/lib/pickle/world.rb +14 -0
  62. data/lib/spbtv_pickle.rb +1 -0
  63. data/rails_generators/pickle/pickle_generator.rb +31 -0
  64. data/rails_generators/pickle/templates/email.rb +21 -0
  65. data/rails_generators/pickle/templates/email_steps.rb +65 -0
  66. data/rails_generators/pickle/templates/paths.rb +47 -0
  67. data/rails_generators/pickle/templates/pickle.rb +29 -0
  68. data/rails_generators/pickle/templates/pickle_steps.rb +105 -0
  69. data/spbtv_pickle.gemspec +38 -0
  70. data/spec/pickle/adapter_spec.rb +203 -0
  71. data/spec/pickle/config_spec.rb +112 -0
  72. data/spec/pickle/email/parser_spec.rb +51 -0
  73. data/spec/pickle/email_spec.rb +187 -0
  74. data/spec/pickle/parser/matchers_spec.rb +70 -0
  75. data/spec/pickle/parser_spec.rb +165 -0
  76. data/spec/pickle/path_spec.rb +120 -0
  77. data/spec/pickle/session_spec.rb +448 -0
  78. data/spec/pickle_spec.rb +24 -0
  79. data/spec/spec_helper.rb +78 -0
  80. metadata +370 -0
@@ -0,0 +1,10 @@
1
+ Feature: I can visit a page by named route
2
+ In order to nav in my features
3
+ As a feature writer
4
+ I want to be able visit named routes
5
+
6
+ Scenario: visit the new spoons page
7
+ When I go to the new spoon page
8
+ Then I should be at the new spoon page
9
+ And the new spoon page should match route /spoons/new
10
+
@@ -0,0 +1,83 @@
1
+ Feature: I can easily create models from my blueprints
2
+
3
+ As a plain old AR user
4
+ I want to be able to create models with fields
5
+ So that I can create models quickly and easily in my features
6
+
7
+
8
+ Scenario: I create a user, and see if it looks right
9
+ Given a user exists with name: "Fred", has_stale_password: true
10
+ Then the user should not have a status
11
+ And the user should have a stale password
12
+ And the user's name should be "Fred"
13
+
14
+ Scenario: I create a user, and see if it looks right
15
+ Given a user exists with name: "Fred", status: "crayzee"
16
+ Then a user should exist with name: "Fred"
17
+ And a user should exist with status: "crayzee"
18
+ But a user should not exist with name: "Wilma"
19
+
20
+ Scenario: I create a user with quotes in its status, and see if it looks right
21
+ Given a user exists with name: "Fred", status: "a little \"off\""
22
+ Then a user should exist with status: "a little \"off\""
23
+
24
+ Scenario: I create a user via a mapping
25
+ Given I exist with status: "pwned", name: "fred"
26
+ Then I should have a status
27
+ And the user: "me" should have a status
28
+
29
+ Scenario: I create positive and negative users
30
+ Given a user exists with name: "Fred", attitude_score: +5.42
31
+ And another user exists with name: "Ethel", attitude_score: -10
32
+ And another user exists with name: "Buddha", attitude_score: 2_000_000
33
+ Then 3 users should exist
34
+ And the 1st user should be a positive person
35
+ And the 2nd user should not be a positive person
36
+ And the 1st user's attitude_score should be 5.42
37
+ And the 2nd user's attitude_score should be -10
38
+ And the 3rd user's attitude_score should be 2_000_000
39
+ And the 3rd user's attitude_score should be 2000000
40
+
41
+ Scenario: I create nil values
42
+ Given a user exists with name: "Fred", attitude_score: nil
43
+ Then 1 users should exist with attitude_score: nil
44
+ And that user should be the first user
45
+ And that user should have no attitude
46
+ And that user's attitude_score should be nil
47
+
48
+ Scenario: create and find using tables
49
+ Given the following users exist:
50
+ | name | status |
51
+ | Jim | married |
52
+ | Ethel | in a relationship with x |
53
+ | Garvin | in an "open" relationship |
54
+ Then the following users should exist:
55
+ | name |
56
+ | Jim |
57
+ | Ethel |
58
+ | Garvin |
59
+ And the following users should exist:
60
+ | status |
61
+ | married |
62
+ | in a relationship with x |
63
+ | in an "open" relationship |
64
+ And the 1st user should be the 4th user
65
+ And the 3rd user should be the last user
66
+
67
+ Scenario: create and find using tables with referencable names
68
+ Given the following users exist:
69
+ | user | name | status |
70
+ | Jack | Jack | alone |
71
+ | Pete | Pete | dead |
72
+ Then the following users should exist:
73
+ | name |
74
+ | Jack |
75
+ | Pete |
76
+ And the following users should exist:
77
+ | user | status |
78
+ | lonely | alone |
79
+ | rotting | dead |
80
+ And the 1st user should be the user: "Jack"
81
+ And the 2nd user should be the user: "Pete"
82
+ And the user: "lonely" should be the user: "Jack"
83
+ And the user: "rotting" should be the user: "Pete"
@@ -0,0 +1,46 @@
1
+ Feature: I can easily create models with Fabrication
2
+
3
+ As a fabrication user
4
+ I want to be able to leverage my fabricators
5
+ So that I can create models quickly and easily in my features
6
+
7
+ Scenario: I create a knife, and see if it looks right
8
+ Given a knife exists
9
+ Then the knife should be sharp
10
+ And the knife's sharp should be true
11
+
12
+ Scenario: I create a blunt knife, and see if it looks right
13
+ Given a knife exists with sharp: false
14
+ Then the knife should not be sharp
15
+
16
+ Scenario: I create a named knife, and see if it has the name
17
+ Given a knife exists with name: "John", sharp: false
18
+ Then a knife should exist with name: "John"
19
+ And the knife should not be sharp
20
+
21
+ Scenario: I create 7 knives of various sharpness
22
+ Given 2 knives exist with sharp: false
23
+ And 2 knives exist with sharp: true
24
+ And a knife exists with sharp: false
25
+
26
+ Then the 1st knife should not be sharp
27
+ And the 2nd knife should not be sharp
28
+ And the 3rd knife should be sharp
29
+ And the 4th knife should be sharp
30
+ And the 5th knife should not be sharp
31
+
32
+ And 3 knives should exist with sharp: false
33
+ And the 1st knife should not be sharp
34
+ And the 2nd knife should not be sharp
35
+ And the last knife should not be sharp
36
+
37
+ And 2 knives should exist with sharp: true
38
+ And the first knife should be sharp
39
+ And the last knife should be sharp
40
+
41
+ Scenario: ModelNotKnownError should be informative when failing to find
42
+ Given a knife exists with sharp: true
43
+ Then the following should raise a Pickle::Session::ModelNotFoundError with "Can't find a knife with sharp: false from the orm in this scenario":
44
+ """
45
+ Then a knife should exist with sharp: false
46
+ """
@@ -0,0 +1,66 @@
1
+ Feature: I can easily create models from my factories
2
+
3
+ As a pickle user
4
+ I want to be able to leverage my factories
5
+ So that I can create models quickly and easily in my features
6
+
7
+ Scenario: I create a fork, and see if it looks right
8
+ Given a fork exists
9
+ Then the fork should not be completely rusty
10
+
11
+ Scenario: I create a fork, and see if it looks right
12
+ Given a fork exists with name: "Forky"
13
+ Then a fork should exist with name: "Forky"
14
+ And the fork should not be completely rusty
15
+
16
+ Scenario: I create some forks, and some tines
17
+ Given a fork: "one" exists
18
+ And a tine exists with fork: fork "one"
19
+ And another tine exists with fork: fork "one"
20
+
21
+ And a fancy fork exists
22
+ And a tine exists with fork: the fancy fork
23
+
24
+ Then the first tine should be tine of the fork: "one"
25
+ And the 2nd tine should be tine of fork: "one"
26
+ And the last tine should be tine of the fancy fork
27
+
28
+ Then the first tine should be in fork "one"'s tines
29
+ And the 2nd tine should be in fork: "one"'s tines
30
+ And the last tine should be in the fancy fork's tines
31
+ And the fancy fork should be the last tine's fork
32
+
33
+ But the first tine should not be in the fancy fork's tines
34
+ And the last tine should not be in fork "one"'s tines
35
+ And the fancy fork should not be the first tine's fork
36
+
37
+ Scenario: I create a fork with a tine, and find the tine by the fork
38
+ Given a fork exists
39
+ And a tine exists with fork: the fork
40
+
41
+ Then a tine should exist with fork: the fork
42
+
43
+ Scenario: create a tine with fork refs in a table
44
+ Given 2 forks exist
45
+ And the following tines exist:
46
+ | fork |
47
+ | the 1st fork |
48
+ | the 2nd fork |
49
+ | the 2nd fork |
50
+ Then the 1st tine should be in the 1st fork's tines
51
+ And the 2nd tine should be in the 2nd fork's tines
52
+ And the 3rd tine should be in the 2nd fork's tines
53
+ And the 1st fork should have 1 tines
54
+ And the 2nd fork should have 2 tines
55
+
56
+ Scenario: I create fork via a mapping
57
+ Given killah fork exists
58
+ Then the fork should be fancy
59
+ And the fancy fork: "of cornwood" should be fancy
60
+
61
+ Scenario: create a tine with a missing fork
62
+ Then the following should raise a Pickle::Session::ModelNotKnownError:
63
+ """
64
+ Given a tine exists with fork: the fork
65
+ """
66
+
@@ -0,0 +1,46 @@
1
+ Feature: I can easily create models from my blueprints
2
+
3
+ As a machinist user
4
+ I want to be able to leverage my blueprints
5
+ So that I can create models quickly and easily in my features
6
+
7
+ Scenario: I create a spoon, and see if it looks right
8
+ Given a spoon exists
9
+ Then the spoon should be round
10
+ And the spoon's round should be true
11
+
12
+ Scenario: I create a non round spoon, and see if it looks right
13
+ Given a spoon exists with round: false
14
+ Then the spoon should not be round
15
+
16
+ Scenario: I create a named spoon, and see if it has the name
17
+ Given a spoon exists with name: "Pete", round: false
18
+ Then a spoon should exist with name: "Pete"
19
+ And the spoon should not be round
20
+
21
+ Scenario: I create 7 spoons of various roundness
22
+ Given 2 spoons exist with round: false
23
+ And 2 spoons exist with round: true
24
+ And a spoon exists with round: false
25
+
26
+ Then the 1st spoon should not be round
27
+ And the 2nd spoon should not be round
28
+ And the 3rd spoon should be round
29
+ And the 4th spoon should be round
30
+ And the 5th spoon should not be round
31
+
32
+ And 3 spoons should exist with round: false
33
+ And the 1st spoon should not be round
34
+ And the 2nd spoon should not be round
35
+ And the last spoon should not be round
36
+
37
+ And 2 spoons should exist with round: true
38
+ And the first spoon should be round
39
+ And the last spoon should be round
40
+
41
+ Scenario: ModelNotKnownError should be informative when failing to find
42
+ Given a spoon exists with round: true
43
+ Then the following should raise a Pickle::Session::ModelNotFoundError with "Can't find a spoon with round: false from the orm in this scenario":
44
+ """
45
+ Then a spoon should exist with round: false
46
+ """
@@ -0,0 +1 @@
1
+ ../../rails_generators/pickle/templates/email_steps.rb
@@ -0,0 +1,12 @@
1
+ Given(/^an email "(.*?)" with body: "(.*?)" is delivered to (.+?)$/) do |subject, body, to|
2
+ Notifier.email(to, subject, body).deliver
3
+ end
4
+
5
+ Given(/^an email with a link "(.+?)" to (.+?) is delivered to (.+?)$/) do |text, page, to|
6
+ body = "some text <a href='http://example.com/#{path_to(page)}'>#{text}</a> more text"
7
+ Notifier.email(to, "example", body).deliver
8
+ end
9
+
10
+ Given(/^#{capture_model}'s email is delivered$/) do |model|
11
+ Notifier.user_email(model!(model)).deliver
12
+ end
@@ -0,0 +1,4 @@
1
+ # example of making your own matcher with the pickle backend
2
+ Then(/^#{capture_model} should be tine of #{capture_model}$/) do |tine, fork|
3
+ expect(model(fork).tines).to include(model(tine))
4
+ end
@@ -0,0 +1,52 @@
1
+ Before('@gen') do
2
+ `mv #{Rails.root}/features/ #{Rails.root}/features.orig/ > /dev/null 2>&1`
3
+ end
4
+
5
+ After('@gen') do
6
+ `rm -rf #{Rails.root}/features`
7
+ `mv #{Rails.root}/features.orig/ #{Rails.root}/features/ > /dev/null 2>&1`
8
+ end
9
+
10
+ Given(/^cucumber has been freshly generated$/) do
11
+ Bundler.with_clean_env do
12
+ `cd #{Rails.root}; rails g cucumber:install -f --capybara`
13
+ end
14
+ end
15
+
16
+ Given(/^pickle path email has been freshly generated$/) do
17
+ Bundler.with_clean_env do
18
+ `cd #{Rails.root}; rails g pickle paths email -f`
19
+ end
20
+ end
21
+
22
+ Given(/^env\.rb already requires (.+)$/) do |file|
23
+ File.open("#{Rails.root}/features/support/env.rb", "a") do |env|
24
+ env << "require '#{file}'\n"
25
+ end
26
+ end
27
+
28
+ When(/^I run "(.*)"$/) do |command|
29
+ Bundler.with_clean_env do
30
+ @output = `cd #{Rails.root}; #{command}`
31
+ end
32
+ end
33
+
34
+ Then(/^I should see "(.*)"$/) do |text|
35
+ expect(@output).to include(text)
36
+ end
37
+
38
+ Then(/^the file (.+?) should exist$/) do |file|
39
+ expect(File.exist?("#{Rails.root}/#{file}")).to eq(true)
40
+ end
41
+
42
+ Then(/^the file (.+?) should match \/(.*?)\/$/) do |file, regexp|
43
+ expect(File.read("#{Rails.root}/#{file}")).to match(/#{regexp}/m)
44
+ end
45
+
46
+ Then(/^the file (.+?) should not match \/(.*?)\/$/) do |file, regexp|
47
+ expect(File.read("#{Rails.root}/#{file}")).not_to match(/#{regexp}/m)
48
+ end
49
+
50
+ Then /^the file ([^ ]+) should be identical to the local (.+)$/ do |generated_file, source_file|
51
+ expect(File.read("#{Rails.root}/#{generated_file}")).to eq(File.read("#{File.dirname(__FILE__)}/../#{source_file}"))
52
+ end
@@ -0,0 +1,14 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
2
+
3
+ Then(/^(.+?) should match route \/(.+?)$/) do |page, route|
4
+ regexp = route.gsub(/:(\w*?)id/,'\d+')
5
+ expect(path_to(page)).to match(/#{regexp}/)
6
+ end
7
+
8
+ When(/^I go to (.+)$/) do |page|
9
+ visit path_to(page)
10
+ end
11
+
12
+ Then(/^I should be at (.+)$/) do |page|
13
+ expect(current_url).to match(/#{path_to(page)}/)
14
+ end
@@ -0,0 +1 @@
1
+ ../../rails_generators/pickle/templates/pickle_steps.rb
@@ -0,0 +1,7 @@
1
+ Then /^the following should raise an? ([\w:]+):$/ do |error, step|
2
+ expect { steps step }.to raise_error(error.constantize)
3
+ end
4
+
5
+ Then /^the following should raise an? ([\w:]+) with "([^"]*)":$/ do |error, message, step|
6
+ expect { steps step }.to raise_error(error.constantize, message)
7
+ end
@@ -0,0 +1 @@
1
+ ../../rails_generators/pickle/templates/email.rb
@@ -0,0 +1,14 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+ ENV["RAILS_ENV"] ||= "test"
8
+ ENV["RAILS_ROOT"] ||= File.expand_path(File.dirname(__FILE__) + '/../../cucumber_test_app')
9
+
10
+ require 'capybara'
11
+ require 'cucumber/rails'
12
+ Capybara.default_selector = :css
13
+ ActionController::Base.allow_rescue = false
14
+ DatabaseCleaner.strategy = :truncation
@@ -0,0 +1,47 @@
1
+ module NavigationHelpers
2
+ # Maps a name to a path. Used by the
3
+ #
4
+ # When /^I go to (.+)$/ do |page_name|
5
+ #
6
+ # step definition in web_steps.rb
7
+ #
8
+ def path_to(page_name)
9
+ case page_name
10
+
11
+ when /the home\s?page/
12
+ '/'
13
+
14
+ # the following are examples using path_to_pickle
15
+
16
+ when /^#{capture_model}(?:'s)? page$/ # eg. the forum's page
17
+ path_to_pickle $1
18
+
19
+ when /^#{capture_model}(?:'s)? #{capture_model}(?:'s)? page$/ # eg. the forum's post's page
20
+ path_to_pickle $1, $2
21
+
22
+ when /^#{capture_model}(?:'s)? #{capture_model}'s (.+?) page$/ # eg. the forum's post's comments page
23
+ path_to_pickle $1, $2, :extra => $3 # or the forum's post's edit page
24
+
25
+ when /^#{capture_model}(?:'s)? (.+?) page$/ # eg. the forum's posts page
26
+ path_to_pickle $1, :extra => $2 # or the forum's edit page
27
+
28
+ # Add more mappings here.
29
+ # Here is an example that pulls values out of the Regexp:
30
+ #
31
+ # when /^(.*)'s profile page$/i
32
+ # user_profile_path(User.find_by_login($1))
33
+
34
+ else
35
+ begin
36
+ page_name =~ /the (.*) page/
37
+ path_components = $1.split(/\s+/)
38
+ self.send(path_components.push('path').join('_').to_sym)
39
+ rescue Object => e
40
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
41
+ "Now, go and add a mapping in #{__FILE__}"
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ World(NavigationHelpers)
@@ -0,0 +1,27 @@
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
+ #
10
+ # For FactoryGirl add: features/support/factory_girl.rb
11
+ #
12
+ # require 'factory_girl'
13
+ # require File.dirname(__FILE__) + '/../../spec/factories' # or wherever your factories are
14
+ #
15
+ # For Fabrication, just include it in the adapter list when configuring pickle as explained below.
16
+ #
17
+ # You may also need to add gem dependencies on your factory of choice in <tt>config/environments/cucumber.rb</tt>
18
+
19
+ require 'pickle/world'
20
+ # Example of configuring pickle:
21
+ #
22
+ # Pickle.configure do |config|
23
+ # config.adapters = [:machinist]
24
+ # config.map 'I', 'myself', 'me', 'my', :to => 'user: "me"'
25
+ # end
26
+ require 'pickle/path/world'
27
+ require 'pickle/email/world'