cucumber_monitor 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/config/cucumber.yml +8 -0
- data/config/locales/cucumber_monitor_views.yml +3 -3
- data/lib/cucumber_monitor/base.rb +6 -2
- data/lib/cucumber_monitor/version.rb +1 -1
- data/lib/cucumber_monitor.rb +17 -0
- data/test/cucumber_monitor_test.rb +8 -0
- data/test/dummy/config/cucumber.yml +8 -0
- data/test/dummy/config/database.yml +4 -1
- data/test/dummy/features/administration.feature +10 -0
- data/test/dummy/features/change_my_data.feature +23 -0
- data/test/dummy/features/support/env.rb +59 -0
- data/test/dummy/lib/tasks/cucumber.rake +65 -0
- data/test/dummy/log/development.log +2 -0
- data/test/dummy/log/test.log +96 -382
- data/test/dummy/script/cucumber +10 -0
- data/test/feature_file_test.rb +1 -1
- data/test/setup.rb +16 -0
- metadata +18 -5
- data/test/dummy/db/development.sqlite3 +0 -0
data/config/cucumber.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<%
|
2
|
+
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
3
|
+
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
4
|
+
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
|
5
|
+
%>
|
6
|
+
default: <%= std_opts %> features
|
7
|
+
wip: --tags @wip:3 --wip features
|
8
|
+
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
|
@@ -3,12 +3,16 @@
|
|
3
3
|
module CucumberMonitor
|
4
4
|
class Base
|
5
5
|
|
6
|
+
def self.path
|
7
|
+
CucumberMonitor.path
|
8
|
+
end
|
9
|
+
|
6
10
|
def self.features_path
|
7
|
-
|
11
|
+
"#{path}/features"
|
8
12
|
end
|
9
13
|
|
10
14
|
def self.cucumber_output_file
|
11
|
-
|
15
|
+
"#{path}/tmp/cucumber.out"
|
12
16
|
end
|
13
17
|
|
14
18
|
def locate
|
data/lib/cucumber_monitor.rb
CHANGED
@@ -17,4 +17,21 @@ module CucumberMonitor
|
|
17
17
|
CucumberMonitor::Base.new
|
18
18
|
end
|
19
19
|
|
20
|
+
def self.path
|
21
|
+
"#{CucumberMonitor::Engine.root}#{app_test_dir}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.app_test_dir
|
25
|
+
"/test/dummy" if Rails.env == 'test'
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.cucumber_rails_ready?
|
29
|
+
files = [
|
30
|
+
"#{path}/script/cucumber",
|
31
|
+
"#{path}/features",
|
32
|
+
"#{path}/lib/tasks/cucumber.rake"
|
33
|
+
]
|
34
|
+
files.all? { |f| File.exist?(f) } && YAML.load_file("#{path}/config/database.yml").has_key?("cucumber")
|
35
|
+
end
|
36
|
+
|
20
37
|
end
|
@@ -1,4 +1,12 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class CucumberMonitorTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test "should tell cucumber-rails is ready" do
|
6
|
+
uninstall_cucumber_rails
|
7
|
+
Dir.chdir("#{@path}")
|
8
|
+
`rails generate cucumber:install`
|
9
|
+
Dir.chdir("..")
|
10
|
+
assert CucumberMonitor.cucumber_rails_ready?
|
11
|
+
end
|
4
12
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%
|
2
|
+
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
3
|
+
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
4
|
+
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
|
5
|
+
%>
|
6
|
+
default: <%= std_opts %> features
|
7
|
+
wip: --tags @wip:3 --wip features
|
8
|
+
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
|
@@ -12,7 +12,7 @@ development:
|
|
12
12
|
# Warning: The database defined as "test" will be erased and
|
13
13
|
# re-generated from your development database when you run "rake".
|
14
14
|
# Do not set this db to the same as development or production.
|
15
|
-
test:
|
15
|
+
test: &test
|
16
16
|
adapter: sqlite3
|
17
17
|
database: db/test.sqlite3
|
18
18
|
pool: 5
|
@@ -23,3 +23,6 @@ production:
|
|
23
23
|
database: db/production.sqlite3
|
24
24
|
pool: 5
|
25
25
|
timeout: 5000
|
26
|
+
|
27
|
+
cucumber:
|
28
|
+
<<: *test
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: Access the system as an administrator
|
2
|
+
Scenario: Access with valid data
|
3
|
+
Given that there is an administrator with the email "admin@domain.com" and password "123456"
|
4
|
+
When I try to access the admin dashboard with the email "admin@domain.com" and senha "123456"
|
5
|
+
Then I should be at admin dashboard page
|
6
|
+
|
7
|
+
Scenario: Access with invalid data
|
8
|
+
Given that there is an administrator with the email "admin@domain.com" and password "123456"
|
9
|
+
When I try to access the admin dashbaord with the email "admin@domain.com" and senha "654321"
|
10
|
+
Then I should see "Invalid username/password"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Feature: Change personal data
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given my name is Peter and I have an account in the system
|
5
|
+
|
6
|
+
Scenario: Changing personal data flow
|
7
|
+
When I access the system
|
8
|
+
And I press "My account"
|
9
|
+
Then I should see my personal information
|
10
|
+
When I press "Change my data"
|
11
|
+
And I fill in "Name" with "Peter Summers"
|
12
|
+
And I press "Save"
|
13
|
+
Then I should see "Personal data successfully changed"
|
14
|
+
And I should see "Petter Summers"
|
15
|
+
|
16
|
+
Scenario: Listing my roles
|
17
|
+
When I access the system
|
18
|
+
And I press "My roles"
|
19
|
+
I should see the following table:
|
20
|
+
| # | Role name |
|
21
|
+
| 1 | Admin |
|
22
|
+
| 2 | Member |
|
23
|
+
| 3 | Publisher |
|
@@ -0,0 +1,59 @@
|
|
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
|
+
require 'cucumber/rails'
|
8
|
+
|
9
|
+
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
|
10
|
+
# order to ease the transition to Capybara we set the default here. If you'd
|
11
|
+
# prefer to use XPath just remove this line and adjust any selectors in your
|
12
|
+
# steps to use the XPath syntax.
|
13
|
+
Capybara.default_selector = :css
|
14
|
+
|
15
|
+
# By default, any exception happening in your Rails application will bubble up
|
16
|
+
# to Cucumber so that your scenario will fail. This is a different from how
|
17
|
+
# your application behaves in the production environment, where an error page will
|
18
|
+
# be rendered instead.
|
19
|
+
#
|
20
|
+
# Sometimes we want to override this default behaviour and allow Rails to rescue
|
21
|
+
# exceptions and display an error page (just like when the app is running in production).
|
22
|
+
# Typical scenarios where you want to do this is when you test your error pages.
|
23
|
+
# There are two ways to allow Rails to rescue exceptions:
|
24
|
+
#
|
25
|
+
# 1) Tag your scenario (or feature) with @allow-rescue
|
26
|
+
#
|
27
|
+
# 2) Set the value below to true. Beware that doing this globally is not
|
28
|
+
# recommended as it will mask a lot of errors for you!
|
29
|
+
#
|
30
|
+
ActionController::Base.allow_rescue = false
|
31
|
+
|
32
|
+
# Remove/comment out the lines below if your app doesn't have a database.
|
33
|
+
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
|
34
|
+
begin
|
35
|
+
DatabaseCleaner.strategy = :transaction
|
36
|
+
rescue NameError
|
37
|
+
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
|
38
|
+
end
|
39
|
+
|
40
|
+
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
|
41
|
+
# See the DatabaseCleaner documentation for details. Example:
|
42
|
+
#
|
43
|
+
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
44
|
+
# # { :except => [:widgets] } may not do what you expect here
|
45
|
+
# # as tCucumber::Rails::Database.javascript_strategy overrides
|
46
|
+
# # this setting.
|
47
|
+
# DatabaseCleaner.strategy = :truncation
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
|
51
|
+
# DatabaseCleaner.strategy = :transaction
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
|
55
|
+
# Possible values are :truncation and :transaction
|
56
|
+
# The :transaction strategy is faster, but might give you threading problems.
|
57
|
+
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
|
58
|
+
Cucumber::Rails::Database.javascript_strategy = :truncation
|
59
|
+
|
@@ -0,0 +1,65 @@
|
|
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
|
+
|
8
|
+
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
|
9
|
+
|
10
|
+
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
11
|
+
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'cucumber/rake/task'
|
15
|
+
|
16
|
+
namespace :cucumber do
|
17
|
+
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
|
18
|
+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
19
|
+
t.fork = true # You may get faster startup if you set this to false
|
20
|
+
t.profile = 'default'
|
21
|
+
end
|
22
|
+
|
23
|
+
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
|
24
|
+
t.binary = vendored_cucumber_bin
|
25
|
+
t.fork = true # You may get faster startup if you set this to false
|
26
|
+
t.profile = 'wip'
|
27
|
+
end
|
28
|
+
|
29
|
+
Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
|
30
|
+
t.binary = vendored_cucumber_bin
|
31
|
+
t.fork = true # You may get faster startup if you set this to false
|
32
|
+
t.profile = 'rerun'
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Run all features'
|
36
|
+
task :all => [:ok, :wip]
|
37
|
+
|
38
|
+
task :statsetup do
|
39
|
+
require 'rails/code_statistics'
|
40
|
+
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
|
41
|
+
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
desc 'Alias for cucumber:ok'
|
45
|
+
task :cucumber => 'cucumber:ok'
|
46
|
+
|
47
|
+
task :default => :cucumber
|
48
|
+
|
49
|
+
task :features => :cucumber do
|
50
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
51
|
+
end
|
52
|
+
|
53
|
+
# In case we don't have ActiveRecord, append a no-op task that we can depend upon.
|
54
|
+
task 'db:test:prepare' do
|
55
|
+
end
|
56
|
+
|
57
|
+
task :stats => 'cucumber:statsetup'
|
58
|
+
rescue LoadError
|
59
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
60
|
+
task :cucumber do
|
61
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|