cucumber-persona 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67ca3dac52f886c22400a3d62c809e78918e6c4f
4
- data.tar.gz: f6da74e2404f8357c40bea92294a9278ca5ef16a
3
+ metadata.gz: b04d033d3ae87bd9768831b27e5dd2147cfa1305
4
+ data.tar.gz: 7b413bc87e2111a03612eedb4e3f0d80051ae68c
5
5
  SHA512:
6
- metadata.gz: 8208684bd12f12a93ecef34f9d8aff28d08548be961b119e05109b8c7b5387bfea23ba8e786fd2babf185828a29d75992e1fd068fe9c35d17bdddda111d4cb79
7
- data.tar.gz: b5e84fc2938e12bda9632983295df59f3f4e9ef66d407be4c3ecd09af49722693141d79fea8e41571e8631515aefebcc33ee7700680510ce8a96556138e810b1
6
+ metadata.gz: 863ff69b86e4cc9a45151019067974ecd7effd3064e70cba791a1506c0abe55e9d2488fc3f51a630135e4a303859a9f412378e144ebd9e9a28c1f37494e00ad6
7
+ data.tar.gz: 83e49cf08a067ec9403c0da66bcf07cf6a2e1ff1a4ce7a94135b105b140ee90e3c2a0691d70e2fdd7e902427f9342041f08796cd31935c03569be8b3af200356
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ *.gem
1
2
  /.bundle/
2
3
  /.yardoc
3
4
  /Gemfile.lock
data/README.md CHANGED
@@ -1,8 +1,26 @@
1
1
  # Cucumber::Persona
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cucumber/persona`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Code Climate](https://codeclimate.com/github/starfighterheavy/edward/badges/gpa.svg)](https://codeclimate.com/github/starfighterheavy/edward)
4
+ [![Dependency Status](https://gemnasium.com/starfighterheavy/cucumber-persona.svg)](https://gemnasium.com/starfighterheavy/cucumber-persona)
5
+ [![Gem Version](https://badge.fury.io/rb/cucumber-persona.svg)](https://badge.fury.io/rb/cucumber-persona)
4
6
 
5
- TODO: Delete this and the text above, and describe your gem
7
+ One of the hardest things to do in Cucumber is define the state of the world, from a data perspective, that a test should be run in. Gems like [cucumber_factory](https://github.com/makandra/cucumber_factory) try to make this easier, but can introduce more complexity rather than less, as even simple tests can require extensive background data to be run well. Cucumber::Persona attempts to solve this by completely removing data setup from your cucumber feature scripts and allowing total flexibility in how you create your data.
8
+
9
+ To use Cucumber::Persona, take the persona's you have already created for various user types (you've done that, right? ;), and create a Cucumber::Persona for each. Then, in your feature test setup, instantiate the Cucumber::Persona you need by adding a `Given` statement in the form:
10
+
11
+ ```
12
+ Given I am "Han Solo"
13
+ ...
14
+ ```
15
+
16
+ or
17
+
18
+ ```
19
+ Given "Han Solo" exists
20
+ ...
21
+ ```
22
+
23
+ And wala! All the data you need is ready to go.
6
24
 
7
25
  ## Installation
8
26
 
@@ -22,17 +40,66 @@ Or install it yourself as:
22
40
 
23
41
  ## Usage
24
42
 
25
- TODO: Write usage instructions here
43
+ In your `feaqtures/support/env.rb` file, add `require 'cucumber/persona'`.
44
+
45
+ To create your first Persona, create add a `personas` directory to your `features` directory (or wherever you'd like to place it) and create a `.rb` new file, typically named after a Persona, e.g. `han_solo.rb`, or a category of personas, e.g. `customers.rb`, similar to how you would define a model with FactoryGirl. That file will look something like this:
46
+
47
+ ```
48
+ Cucumber::Persona.define "Han Solo" do
49
+ # Create the user
50
+ user = User.create!(first_name: "Han", last_name: "Solo", email: "han@solo.com", password: "Password1")
51
+ # Create any additional data needed to flesh out the user's state of the world at the time of the test.
52
+ # Example below is for a todo list application where our user Han has 3 tasks and completed 1.
53
+ user.tasks.create!(title: "First task", completed: Time.now)
54
+ user.tasks.create!(title: "Second task")
55
+ user.tasks.create!(title: "Third task")
56
+ end
57
+ ```
58
+
59
+ To use your persona in your tests, you can create your own persona related step definition, or use the default ones provided by including the requiring in your `env.rb` file:
60
+
61
+ ```
62
+ require 'cucumber/persona/step_definitions/persona_steps`
63
+ ```
64
+
65
+ You can create your own definition like the following:
66
+
67
+ ```
68
+ Given /^my "(.*)" workflow exists$/ do |name|
69
+ Cucumber::Persona.find(name).create
70
+ end
71
+ ```
72
+
73
+ To use your Personas elsewhere, like in your `db/seed` file, add the following:
74
+
75
+ ```
76
+ require 'cucumber/persona'
77
+ require_relative '../features/personas'
78
+
79
+ Cucumber::Persona.create_all
80
+ ```
81
+
82
+ ## Examples
83
+
84
+ ### Edward
26
85
 
27
- ## Development
86
+ This project was originally extracted from [Edward](https://github.com/starfighterheavy/edward), which outgrew what [factory_bot](https://github.com/thoughtbot/factory_bot_rails) could provide cleanly.
28
87
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
88
+ See: https://github.com/starfighterheavy/edward/tree/master/features/personas
30
89
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
90
+ ### BridgeCare Finance
91
+
92
+ [BridgeCare Finance](https://www.bridgecarefinance.com) uses Cucumber::Persona to create tests centered around common user personas that have their own quirks and history, rather than nameless data objects.
93
+
94
+ #### Are you using Cucumber::Persona?
95
+
96
+ Open a pull request against this README to add yourself to this list!
32
97
 
33
98
  ## Contributing
34
99
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cucumber-persona. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
100
+ Cucumber::Personas is an intentionally simple library, and should not often need updates or new features. But if you'd like to contribute, an area that could definitely use some help is in building out tests, preferably in Cucumber.
101
+
102
+ Bug reports and pull requests are welcome on GitHub at https://github.com/starfighterheavy/cucumber-persona. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
103
 
37
104
 
38
105
  ## License
@@ -0,0 +1,8 @@
1
+ Given /^"([^"]*)" exists$/ do |name|
2
+ Cucumber::Persona.find(name).create
3
+ end
4
+
5
+ Given /^I am "([^"]*)"$/ do |name|
6
+ Cucumber::Persona.find(name).create
7
+ end
8
+
@@ -1,5 +1,5 @@
1
1
  module Cucumber
2
2
  module Persona
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-persona
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Kirst
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-02 00:00:00.000000000 Z
11
+ date: 2017-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,6 +84,7 @@ files:
84
84
  - bin/setup
85
85
  - cucumber-persona.gemspec
86
86
  - lib/cucumber/persona.rb
87
+ - lib/cucumber/persona/step_definitions/persona_steps.rb
87
88
  - lib/cucumber/persona/version.rb
88
89
  homepage: https://github.com/starfighterheavy/cucumber-persona
89
90
  licenses: