mouse_melon 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +125 -0
- data/Rakefile +6 -0
- data/bin/console +15 -0
- data/bin/setup +7 -0
- data/examples/login/login.feature +25 -0
- data/examples/login/login_spec.rb +31 -0
- data/examples/varations/common_steps.rb +15 -0
- data/examples/varations/mouse_melon_spec.rb +92 -0
- data/exe/mouse_melon +10 -0
- data/lib/mouse_melon.rb +5 -0
- data/lib/mouse_melon/dsl.rb +60 -0
- data/lib/mouse_melon/step_definition.rb +17 -0
- data/lib/mouse_melon/tools.rb +11 -0
- data/lib/mouse_melon/tools/basic_report_formatter.rb +38 -0
- data/lib/mouse_melon/tools/feature_steps_parser.rb +34 -0
- data/lib/mouse_melon/tools/spec_steps_report.rb +30 -0
- data/lib/mouse_melon/tools/spec_steps_result.rb +28 -0
- data/lib/mouse_melon/tools/step_definitions_parser.rb +26 -0
- data/lib/mouse_melon/version.rb +3 -0
- data/mouse_melon.gemspec +25 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0cbac59d8c02e88a4bda4f237319b533b92b6630
|
4
|
+
data.tar.gz: 75389d980d9614e48186694ee6d99f52c7d1436d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e557a23cb19c61b35c5de25e25f78382df3c1c77785ac953d4b200ef35d14ca454cb7e56a9741df1417fbe105009be6011022c2e66599460d425e52839aaf89d
|
7
|
+
data.tar.gz: a45536b1063a7ca20510ebd853faf71331da01e90c22d1b5cfc9fa53d377e47d7bbbe1e0f1cd45822065b53c2026ec277ba507a614cc288d4a98047a3887a947
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Vojtech Kusy
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
# MouseMelon a.k.a. Mexikan Gherkin
|
2
|
+
|
3
|
+
MouseMelon is a pseudo-Gherkin DSL designed to be used in RSpec acceptance specs but it may be used elsewhere.
|
4
|
+
|
5
|
+
Notable features:
|
6
|
+
|
7
|
+
* It runs inside RSpec (Minispec will come later), just include module and you're ready
|
8
|
+
* `Given`, `When`, `Then` are just methods which calls the step definitions directly
|
9
|
+
* You can use symbols `I_am_registered_user` or feature steps `I am registered user`
|
10
|
+
* You can define the steps globally, locally or mix them into the specs
|
11
|
+
* Steps can have arguments `I register user`
|
12
|
+
* Command line tool to generate step definitions
|
13
|
+
* No fancy output of tested steps like Cucumber or Spinach
|
14
|
+
|
15
|
+
Currently supported/tested environment:
|
16
|
+
|
17
|
+
* RSpec 3.3.x
|
18
|
+
* Ruby 2.1.x
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
Add this line to your application's Gemfile:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem 'mouse_melon'
|
26
|
+
```
|
27
|
+
|
28
|
+
And then execute:
|
29
|
+
|
30
|
+
$ bundle
|
31
|
+
|
32
|
+
Or install it yourself as:
|
33
|
+
|
34
|
+
$ gem install mouse_melon
|
35
|
+
|
36
|
+
Include it to RSpec helper
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
RSpec.configure do |config|
|
40
|
+
config.include MouseMelon::DSL, :type => :feature
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
## Usage
|
45
|
+
|
46
|
+
Here is demonstration of varios possible styles:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
feature 'MouseMelon features' do
|
50
|
+
# Steps shared via modules
|
51
|
+
include CommonSteps
|
52
|
+
|
53
|
+
scenario 'Steps as methods' do
|
54
|
+
given_is_defined
|
55
|
+
when_is_defined
|
56
|
+
then_is_defined
|
57
|
+
end
|
58
|
+
|
59
|
+
scenario 'Steps as symbols' do
|
60
|
+
Given :given_is_defined
|
61
|
+
When :when_is_defined
|
62
|
+
Then :then_is_defined
|
63
|
+
end
|
64
|
+
|
65
|
+
scenario 'Steps as strings' do
|
66
|
+
Given 'given is defined'
|
67
|
+
When 'when is defined'
|
68
|
+
Then 'then is defined'
|
69
|
+
And 'and is defined'
|
70
|
+
And 'and it has arguments', 'hello', 1
|
71
|
+
end
|
72
|
+
|
73
|
+
scenario 'Steps as triangle bullets' do
|
74
|
+
‣ 'given is defined'
|
75
|
+
‣ 'when is defined'
|
76
|
+
‣ 'then is defined'
|
77
|
+
end
|
78
|
+
|
79
|
+
scenario 'Steps as circle bullets' do
|
80
|
+
• 'given is defined'
|
81
|
+
• 'when is defined'
|
82
|
+
• 'then is defined'
|
83
|
+
end
|
84
|
+
|
85
|
+
# INLINE STEP DEFINITIONS
|
86
|
+
|
87
|
+
def given_is_defined
|
88
|
+
puts 'GIVEN'
|
89
|
+
end
|
90
|
+
|
91
|
+
def when_is_defined
|
92
|
+
puts 'WHEN'
|
93
|
+
end
|
94
|
+
|
95
|
+
step 'then is defined' do
|
96
|
+
puts 'THEN'
|
97
|
+
end
|
98
|
+
|
99
|
+
step 'and is defined' do
|
100
|
+
puts 'AND'
|
101
|
+
end
|
102
|
+
|
103
|
+
step 'and it has arguments' do |*args|
|
104
|
+
puts "AND with args #{args.inspect}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
```
|
108
|
+
|
109
|
+
For more examples look inside `examples` and `spec` folders.
|
110
|
+
|
111
|
+
## Development
|
112
|
+
|
113
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
114
|
+
|
115
|
+
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).
|
116
|
+
|
117
|
+
## Contributing
|
118
|
+
|
119
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mouse_melon. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
120
|
+
|
121
|
+
|
122
|
+
## License
|
123
|
+
|
124
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
125
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'mouse_melon'
|
5
|
+
require 'mouse_melon/tools'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Feature: Login
|
2
|
+
As a registered user
|
3
|
+
I want to be able to login
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given I am registered user
|
7
|
+
|
8
|
+
Scenario: Successfull login with username
|
9
|
+
When I am on the home page
|
10
|
+
And I click on login link
|
11
|
+
And I submit my username and password
|
12
|
+
Then I should be on the dashboard page
|
13
|
+
|
14
|
+
Scenario: Successfull login with email
|
15
|
+
When I am on the home page
|
16
|
+
And I click on login link
|
17
|
+
And I submit my email and password
|
18
|
+
Then I should be on the dashboard page
|
19
|
+
|
20
|
+
Scenario: Unsuccessfull login
|
21
|
+
When I am on the home page
|
22
|
+
And I click on login link
|
23
|
+
And I submit my email and wrong password
|
24
|
+
Then I should be on the login page
|
25
|
+
And I should see form errors
|
@@ -0,0 +1,31 @@
|
|
1
|
+
feature 'Login' do
|
2
|
+
# As a registered user
|
3
|
+
# I want to be able to login
|
4
|
+
|
5
|
+
before do
|
6
|
+
Given 'I am registered user'
|
7
|
+
end
|
8
|
+
|
9
|
+
scenario 'Successfull login with username' do
|
10
|
+
When 'I am on the home page'
|
11
|
+
And 'I click on login link'
|
12
|
+
And 'I submit my username and password'
|
13
|
+
Then 'I should be on the dashboard page'
|
14
|
+
end
|
15
|
+
|
16
|
+
scenario 'Successfull login with email' do
|
17
|
+
When 'I am on the home page'
|
18
|
+
And 'I click on login link'
|
19
|
+
And 'I submit my email and password'
|
20
|
+
Then 'I should be on the dashboard page'
|
21
|
+
end
|
22
|
+
|
23
|
+
scenario 'Unsuccessfull login' do
|
24
|
+
When 'I am on the home page'
|
25
|
+
And 'I click on login link'
|
26
|
+
And 'I submit my email and wrong password'
|
27
|
+
Then 'I should be on the login page'
|
28
|
+
And 'I should see form errors'
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
require_relative 'common_steps'
|
3
|
+
|
4
|
+
describe MouseMelon do
|
5
|
+
it 'has a version number' do
|
6
|
+
expect(MouseMelon::VERSION).not_to be nil
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
feature 'MouseMelon features' do
|
11
|
+
include CommonSteps
|
12
|
+
|
13
|
+
scenario 'Without gherkin' do
|
14
|
+
given_is_defined
|
15
|
+
when_is_defined
|
16
|
+
then_is_defined
|
17
|
+
and_is_defined
|
18
|
+
step_is_defined
|
19
|
+
step_can_have_arguments1('X')
|
20
|
+
step_can_be_included1
|
21
|
+
end
|
22
|
+
|
23
|
+
scenario 'Gherkin steps as symbols' do
|
24
|
+
Given :given_is_defined
|
25
|
+
When :when_is_defined
|
26
|
+
Then :then_is_defined
|
27
|
+
And :and_is_defined
|
28
|
+
Step :step_is_defined
|
29
|
+
And :step_can_have_arguments2, 'Y'
|
30
|
+
And :step_can_be_included2
|
31
|
+
end
|
32
|
+
|
33
|
+
scenario 'Gherkin steps as strings' do
|
34
|
+
Given 'given is defined'
|
35
|
+
When 'when is defined'
|
36
|
+
Then 'then is defined'
|
37
|
+
And 'and is defined'
|
38
|
+
Step 'step is defined'
|
39
|
+
And 'step can have arguments3', 'Z'
|
40
|
+
And 'step can have "quotes"3'
|
41
|
+
And 'step can be included3'
|
42
|
+
end
|
43
|
+
|
44
|
+
scenario 'Gherkin steps as triangle bullets' do
|
45
|
+
‣ 'given is defined'
|
46
|
+
‣ 'when is defined'
|
47
|
+
‣ 'then is defined'
|
48
|
+
end
|
49
|
+
|
50
|
+
scenario 'Gherkin steps as circle bullets' do
|
51
|
+
• 'given is defined'
|
52
|
+
• 'when is defined'
|
53
|
+
• 'then is defined'
|
54
|
+
end
|
55
|
+
|
56
|
+
def given_is_defined
|
57
|
+
puts 'GIVEN'
|
58
|
+
end
|
59
|
+
|
60
|
+
def when_is_defined
|
61
|
+
puts 'WHEN'
|
62
|
+
end
|
63
|
+
|
64
|
+
def then_is_defined
|
65
|
+
puts 'THEN'
|
66
|
+
end
|
67
|
+
|
68
|
+
def and_is_defined
|
69
|
+
puts 'AND'
|
70
|
+
end
|
71
|
+
|
72
|
+
step 'step is defined' do
|
73
|
+
puts 'STEP'
|
74
|
+
end
|
75
|
+
|
76
|
+
step 'step can have "quotes"3' do
|
77
|
+
puts "QUOTES 3"
|
78
|
+
end
|
79
|
+
|
80
|
+
def step_can_have_arguments1(arg)
|
81
|
+
puts "STEP #{arg}"
|
82
|
+
end
|
83
|
+
|
84
|
+
def step_can_have_arguments2(arg)
|
85
|
+
puts "STEP #{arg}"
|
86
|
+
end
|
87
|
+
|
88
|
+
step 'step can have arguments3' do |arg|
|
89
|
+
puts "STEP #{arg}"
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
data/exe/mouse_melon
ADDED
data/lib/mouse_melon.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
module MouseMelon
|
2
|
+
|
3
|
+
class StepNotFound < StandardError
|
4
|
+
def initialize(name)
|
5
|
+
@method_name = name
|
6
|
+
@step_name = name.to_s.gsub(/_/, ' ')
|
7
|
+
super "undefined step '#{@step_name}'
|
8
|
+
|
9
|
+
Please define the step by one of the following definition:
|
10
|
+
|
11
|
+
step \"#{@step_name}\" do
|
12
|
+
end
|
13
|
+
|
14
|
+
or
|
15
|
+
|
16
|
+
def #{@method_name} do
|
17
|
+
end
|
18
|
+
"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module DSL
|
23
|
+
|
24
|
+
module StepDefinitions
|
25
|
+
def step(name, *args, &block)
|
26
|
+
normalized_name = name.to_s.gsub(/ /, '_')
|
27
|
+
define_method(normalized_name, *args, &block)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module ScenarioDefinitions
|
32
|
+
def Step(name, *args)
|
33
|
+
normalized_name =
|
34
|
+
case name
|
35
|
+
when Symbol
|
36
|
+
name
|
37
|
+
when String
|
38
|
+
name.to_s.gsub(/ /, '_')
|
39
|
+
else
|
40
|
+
raise ArgumentError.new("Expects Symbol or String but #{name.inspect} was given")
|
41
|
+
end
|
42
|
+
raise StepNotFound.new(normalized_name) unless respond_to?(normalized_name)
|
43
|
+
send(normalized_name, *args)
|
44
|
+
end
|
45
|
+
alias :Given :Step
|
46
|
+
alias :When :Step
|
47
|
+
alias :Then :Step
|
48
|
+
alias :And :Step
|
49
|
+
alias :But :Step
|
50
|
+
alias :‣ :Step
|
51
|
+
alias :• :Step
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.included(base)
|
55
|
+
base.extend StepDefinitions
|
56
|
+
base.include ScenarioDefinitions
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module MouseMelon
|
2
|
+
class StepDefinition
|
3
|
+
attr_reader :name, :body, :spaces
|
4
|
+
|
5
|
+
def initialize(name, body: nil, spaces: 0)
|
6
|
+
@name, @body, @spaces = name, body, spaces
|
7
|
+
end
|
8
|
+
|
9
|
+
def code
|
10
|
+
prefix = " " * @spaces
|
11
|
+
out = "#{prefix}step '#{name}' do\n"
|
12
|
+
out << "#{prefix} #{body}\n" if body
|
13
|
+
out << "#{prefix}end\n"
|
14
|
+
end
|
15
|
+
alias :to_s :code
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require_relative 'step_definition'
|
2
|
+
require_relative 'tools/feature_steps_parser'
|
3
|
+
require_relative 'tools/step_definitions_parser'
|
4
|
+
require_relative 'tools/spec_steps_report'
|
5
|
+
require_relative 'tools/spec_steps_result'
|
6
|
+
require_relative 'tools/basic_report_formatter'
|
7
|
+
|
8
|
+
module MouseMelon
|
9
|
+
module Tools
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module MouseMelon
|
2
|
+
module Tools
|
3
|
+
class BasicReportFormatter
|
4
|
+
|
5
|
+
def format(report)
|
6
|
+
@report = report
|
7
|
+
"
|
8
|
+
DEFINED:
|
9
|
+
#{defined_steps_list}
|
10
|
+
|
11
|
+
UNUSED:
|
12
|
+
#{unused_steps_list}
|
13
|
+
|
14
|
+
MISSING:
|
15
|
+
|
16
|
+
#{missing_steps_list}
|
17
|
+
"
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def defined_steps_list(spaces: 2)
|
23
|
+
prefix = " " * spaces
|
24
|
+
@report.implemented_steps.map { |step| "#{prefix}#{step}" }.join("\n")
|
25
|
+
end
|
26
|
+
|
27
|
+
def unused_steps_list(spaces: 2)
|
28
|
+
prefix = " " * spaces
|
29
|
+
@report.unused_steps.map { |step| "#{prefix}#{step}" }.join("\n")
|
30
|
+
end
|
31
|
+
|
32
|
+
def missing_steps_list
|
33
|
+
@report.not_implemented_steps.map { |name| StepDefinition.new(name, spaces: 2).to_s }.join("\n")
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module MouseMelon
|
2
|
+
module Tools
|
3
|
+
class FeatureStepsParser
|
4
|
+
|
5
|
+
def parse(string)
|
6
|
+
@steps = find_steps(string)
|
7
|
+
strip_step_arguments
|
8
|
+
strip_end_quotes
|
9
|
+
drop_duplicate_steps
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def find_steps(string)
|
15
|
+
string.scan(/^\s*(?:Given|When|Then|And|But|Step)\s+['"](.+)['"]$/).flatten
|
16
|
+
end
|
17
|
+
|
18
|
+
def drop_duplicate_steps
|
19
|
+
@steps.uniq!
|
20
|
+
end
|
21
|
+
|
22
|
+
def strip_end_quotes
|
23
|
+
@steps.map { |step| step.gsub(/\A["']+|["']+\z/, '') }
|
24
|
+
end
|
25
|
+
|
26
|
+
def strip_step_arguments
|
27
|
+
@steps = @steps.map do |step|
|
28
|
+
step.split(/['"], /).first
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module MouseMelon
|
2
|
+
module Tools
|
3
|
+
class SpecStepsReport
|
4
|
+
|
5
|
+
attr_reader :feature, :result
|
6
|
+
|
7
|
+
def initialize(feature, formatter = nil)
|
8
|
+
@feature = feature
|
9
|
+
feature_steps = feature_parser.parse(feature)
|
10
|
+
defined_steps = definition_parser.parse(feature)
|
11
|
+
@result = SpecStepsResult.new(feature_steps, defined_steps)
|
12
|
+
@formatter = formatter || BasicReportFormatter.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def feature_parser
|
16
|
+
FeatureStepsParser.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def definition_parser
|
20
|
+
StepDefinitionsParser.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def report
|
24
|
+
@formatter.format(self.result)
|
25
|
+
end
|
26
|
+
alias :to_s :report
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module MouseMelon
|
4
|
+
module Tools
|
5
|
+
class SpecStepsResult
|
6
|
+
|
7
|
+
attr_reader :feature_steps, :defined_steps
|
8
|
+
|
9
|
+
def initialize(feature_steps, defined_steps)
|
10
|
+
@feature_steps = Set.new(feature_steps)
|
11
|
+
@defined_steps = Set.new(defined_steps)
|
12
|
+
end
|
13
|
+
|
14
|
+
def not_implemented_steps
|
15
|
+
feature_steps - defined_steps
|
16
|
+
end
|
17
|
+
|
18
|
+
def unused_steps
|
19
|
+
defined_steps - feature_steps
|
20
|
+
end
|
21
|
+
|
22
|
+
def implemented_steps
|
23
|
+
defined_steps - unused_steps
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module MouseMelon
|
2
|
+
module Tools
|
3
|
+
class StepDefinitionsParser
|
4
|
+
|
5
|
+
def parse(string)
|
6
|
+
@steps = find_steps(string)
|
7
|
+
strip_end_quotes
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def find_steps(string)
|
13
|
+
string.scan(/^\s*step\s+['"](.+)['"]/).flatten
|
14
|
+
end
|
15
|
+
|
16
|
+
def drop_duplicate_steps
|
17
|
+
@steps.uniq!
|
18
|
+
end
|
19
|
+
|
20
|
+
def strip_end_quotes
|
21
|
+
@steps.map { |step| step.gsub(/\A["']+|["']+\z/, '') }
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/mouse_melon.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mouse_melon/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mouse_melon"
|
8
|
+
spec.version = MouseMelon::VERSION
|
9
|
+
spec.authors = ["Vojtech Kusy"]
|
10
|
+
spec.email = ["wojtha@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "mouse_melon-#{MouseMelon::VERSION}"
|
13
|
+
spec.description = "MouseMelon is a simple DSL which allows to write acceptance specs in Gherkin-like language without any parser."
|
14
|
+
spec.homepage = "http://github.com/wojtha/mouse_melon"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mouse_melon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vojtech Kusy
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: MouseMelon is a simple DSL which allows to write acceptance specs in
|
56
|
+
Gherkin-like language without any parser.
|
57
|
+
email:
|
58
|
+
- wojtha@gmail.com
|
59
|
+
executables:
|
60
|
+
- mouse_melon
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".travis.yml"
|
67
|
+
- CODE_OF_CONDUCT.md
|
68
|
+
- Gemfile
|
69
|
+
- LICENSE.txt
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/console
|
73
|
+
- bin/setup
|
74
|
+
- examples/login/login.feature
|
75
|
+
- examples/login/login_spec.rb
|
76
|
+
- examples/varations/common_steps.rb
|
77
|
+
- examples/varations/mouse_melon_spec.rb
|
78
|
+
- exe/mouse_melon
|
79
|
+
- lib/mouse_melon.rb
|
80
|
+
- lib/mouse_melon/dsl.rb
|
81
|
+
- lib/mouse_melon/step_definition.rb
|
82
|
+
- lib/mouse_melon/tools.rb
|
83
|
+
- lib/mouse_melon/tools/basic_report_formatter.rb
|
84
|
+
- lib/mouse_melon/tools/feature_steps_parser.rb
|
85
|
+
- lib/mouse_melon/tools/spec_steps_report.rb
|
86
|
+
- lib/mouse_melon/tools/spec_steps_result.rb
|
87
|
+
- lib/mouse_melon/tools/step_definitions_parser.rb
|
88
|
+
- lib/mouse_melon/version.rb
|
89
|
+
- mouse_melon.gemspec
|
90
|
+
homepage: http://github.com/wojtha/mouse_melon
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.4.8
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: mouse_melon-0.0.1
|
114
|
+
test_files: []
|
115
|
+
has_rdoc:
|