bdd-rails 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +12 -0
- data/Rakefile +16 -0
- data/lib/bdd_rails/example_generator.rb +17 -0
- data/lib/bdd_rails/install_generator.rb +1 -1
- data/lib/bdd_rails/railtie.rb +1 -0
- data/lib/bdd_rails/templates/example/app/controllers/newsletter_subscriptions_controller.rb +21 -0
- data/lib/bdd_rails/templates/example/app/mailers/newsletter_subscription_mailer.rb +5 -0
- data/lib/bdd_rails/templates/example/app/models/newsletter_subscription.rb +15 -0
- data/lib/bdd_rails/templates/example/app/views/newsletter_subscriptions/new.html.erb +7 -0
- data/lib/bdd_rails/templates/example/spec/features/newsletter_spec.rb +17 -0
- data/lib/bdd_rails/templates/{.rspec → install/.rspec} +0 -0
- data/lib/bdd_rails/templates/{spec → install/spec}/factories/README.md +0 -0
- data/lib/bdd_rails/templates/{spec → install/spec}/features/README.md +0 -0
- data/lib/bdd_rails/templates/{spec → install/spec}/spec_helper.rb +0 -0
- data/lib/bdd_rails/templates/{spec → install/spec}/support/01_rails.rb +0 -0
- data/lib/bdd_rails/templates/{spec → install/spec}/support/capybara.rb +0 -0
- data/lib/bdd_rails/templates/{spec → install/spec}/support/database_cleaner.rb +0 -0
- data/lib/bdd_rails/templates/{spec → install/spec}/support/factory_girl.rb +0 -0
- data/lib/bdd_rails/templates/{spec → install/spec}/support/mail_cleaner.rb +0 -0
- data/lib/bdd_rails/templates/{spec → install/spec}/support/rspec_expectations.rb +0 -0
- data/lib/bdd_rails/templates/{spec → install/spec}/support/rspec_mocks.rb +0 -0
- data/lib/bdd_rails/templates/{spec → install/spec}/support/rspec_output.rb +0 -0
- data/lib/bdd_rails/templates/{spec → install/spec}/support/rspec_run_conditions.rb +0 -0
- data/lib/bdd_rails/templates/{spec → install/spec}/support/vcr.rb +0 -0
- data/lib/bdd_rails/version.rb +1 -1
- data/spec/01_setup.sh +4 -0
- data/spec/{installing_spec.sh → 02_installing_spec.sh} +2 -3
- data/spec/03_example_spec.sh +6 -0
- metadata +25 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b5839031b39c3a57de3d7135481edae5d2f106e
|
4
|
+
data.tar.gz: fd7f1c552bac87728364eed8227821ce33389a9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2be6b15c3b16c31d18c1f241df3d537de5fad316e682ec8023f151a052d2d499326609c725536fbe20142ee38bb6b671378319474a706766be29de4e786adf2
|
7
|
+
data.tar.gz: 29721d9d8224fa66c60c3d5733cc811ecc9f09fad75b836dec5e1444a2e8d7f4711806eb68d78869cc78c93d13d907e0c659d8b698f0f4cbbb75705ae2a54c4f
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -68,3 +68,15 @@ Now you can run your (empty) test suite:
|
|
68
68
|
```
|
69
69
|
bundle exec rspec
|
70
70
|
```
|
71
|
+
|
72
|
+
### How about an example?
|
73
|
+
|
74
|
+
To install a full example of feature test and code into your application run
|
75
|
+
the following:
|
76
|
+
|
77
|
+
```
|
78
|
+
bundle exec rails g bdd_rails:example
|
79
|
+
bundle exec rspec
|
80
|
+
```
|
81
|
+
|
82
|
+
Now you have a passing example! Feel free to explore the example code :)
|
data/Rakefile
CHANGED
@@ -1,2 +1,18 @@
|
|
1
1
|
require 'bundler/setup'
|
2
2
|
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
desc 'Run tests'
|
5
|
+
task default: :test
|
6
|
+
|
7
|
+
desc 'Run tests'
|
8
|
+
task :test do
|
9
|
+
puts 'Running tests...'
|
10
|
+
Dir['./spec/*.sh'].each(&method(:run_spec))
|
11
|
+
puts 'Tests complete.'
|
12
|
+
end
|
13
|
+
|
14
|
+
def run_spec(spec_path)
|
15
|
+
puts "sh #{spec_path}"
|
16
|
+
output = `sh #{spec_path} 2>&1`
|
17
|
+
raise output unless $?.success?
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module BddRails
|
2
|
+
class ExampleGenerator < ::Rails::Generators::Base
|
3
|
+
source_root File.expand_path('../templates/example', __FILE__)
|
4
|
+
|
5
|
+
def install_example_code
|
6
|
+
directory 'app'
|
7
|
+
end
|
8
|
+
|
9
|
+
def install_route
|
10
|
+
route 'resources :newsletter_subscriptions, only: [:new, :create]'
|
11
|
+
end
|
12
|
+
|
13
|
+
def install_example_spec
|
14
|
+
directory 'spec'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/bdd_rails/railtie.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
class NewsletterSubscriptionsController < ApplicationController
|
2
|
+
def new
|
3
|
+
@subscription = NewsletterSubscription.new
|
4
|
+
end
|
5
|
+
|
6
|
+
def create
|
7
|
+
@subscription = NewsletterSubscription.new(subscription_attrs)
|
8
|
+
|
9
|
+
if @subscription.save
|
10
|
+
redirect_to new_newsletter_subscription_path, notice: 'Thanks for signing up'
|
11
|
+
else
|
12
|
+
render :new
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def subscription_attrs
|
19
|
+
params.require(:newsletter_subscription).permit(:email)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class NewsletterSubscription
|
2
|
+
include ActiveModel::Model
|
3
|
+
|
4
|
+
attr_accessor :email
|
5
|
+
validates :email, presence: true, format: { with: /.+@.+/ }
|
6
|
+
|
7
|
+
def save
|
8
|
+
if valid?
|
9
|
+
NewsletterSubscriptionMailer.welcome(email).deliver_later
|
10
|
+
true
|
11
|
+
else
|
12
|
+
false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
feature 'Newsletter' do
|
2
|
+
scenario 'User signs up for newsletter' do
|
3
|
+
when_a_user_wishes_to_hear_more_about_acme
|
4
|
+
they_can_sign_up_to_the_acme_newsletter
|
5
|
+
end
|
6
|
+
|
7
|
+
def when_a_user_wishes_to_hear_more_about_acme
|
8
|
+
visit new_newsletter_subscription_path
|
9
|
+
fill_in :newsletter_subscription_email, with: FFaker::Internet.email
|
10
|
+
click_button 'Sign up'
|
11
|
+
end
|
12
|
+
|
13
|
+
def they_can_sign_up_to_the_acme_newsletter
|
14
|
+
expect(page).to have_content 'Thanks for signing up'
|
15
|
+
expect(ActionMailer::Base.deliveries.count).to be > 0
|
16
|
+
end
|
17
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/bdd_rails/version.rb
CHANGED
data/spec/01_setup.sh
ADDED
@@ -4,12 +4,11 @@
|
|
4
4
|
#
|
5
5
|
set -e
|
6
6
|
|
7
|
-
rm -rf test_app
|
8
|
-
bundle exec rails new --skip-test-unit test_app
|
9
7
|
cd test_app
|
8
|
+
export BUNDLE_GEMFILE=$PWD/Gemfile
|
10
9
|
echo "gem 'bdd-rails', path: '../'" >> Gemfile
|
11
10
|
bundle
|
12
|
-
bundle exec spring stop
|
11
|
+
bundle show spring && bundle exec spring stop
|
13
12
|
bundle exec rails g bdd_rails:install
|
14
13
|
bundle exec rake db:migrate
|
15
14
|
bundle exec rspec
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bdd-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Morton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -67,24 +67,32 @@ files:
|
|
67
67
|
- Rakefile
|
68
68
|
- bdd-rails.gemspec
|
69
69
|
- lib/bdd-rails.rb
|
70
|
+
- lib/bdd_rails/example_generator.rb
|
70
71
|
- lib/bdd_rails/install_generator.rb
|
71
72
|
- lib/bdd_rails/railtie.rb
|
72
|
-
- lib/bdd_rails/templates
|
73
|
-
- lib/bdd_rails/templates/
|
74
|
-
- lib/bdd_rails/templates/
|
75
|
-
- lib/bdd_rails/templates/
|
76
|
-
- lib/bdd_rails/templates/spec/
|
77
|
-
- lib/bdd_rails/templates/
|
78
|
-
- lib/bdd_rails/templates/spec/
|
79
|
-
- lib/bdd_rails/templates/spec/
|
80
|
-
- lib/bdd_rails/templates/spec/
|
81
|
-
- lib/bdd_rails/templates/spec/support/
|
82
|
-
- lib/bdd_rails/templates/spec/support/
|
83
|
-
- lib/bdd_rails/templates/spec/support/
|
84
|
-
- lib/bdd_rails/templates/spec/support/
|
85
|
-
- lib/bdd_rails/templates/spec/support/
|
73
|
+
- lib/bdd_rails/templates/example/app/controllers/newsletter_subscriptions_controller.rb
|
74
|
+
- lib/bdd_rails/templates/example/app/mailers/newsletter_subscription_mailer.rb
|
75
|
+
- lib/bdd_rails/templates/example/app/models/newsletter_subscription.rb
|
76
|
+
- lib/bdd_rails/templates/example/app/views/newsletter_subscriptions/new.html.erb
|
77
|
+
- lib/bdd_rails/templates/example/spec/features/newsletter_spec.rb
|
78
|
+
- lib/bdd_rails/templates/install/.rspec
|
79
|
+
- lib/bdd_rails/templates/install/spec/factories/README.md
|
80
|
+
- lib/bdd_rails/templates/install/spec/features/README.md
|
81
|
+
- lib/bdd_rails/templates/install/spec/spec_helper.rb
|
82
|
+
- lib/bdd_rails/templates/install/spec/support/01_rails.rb
|
83
|
+
- lib/bdd_rails/templates/install/spec/support/capybara.rb
|
84
|
+
- lib/bdd_rails/templates/install/spec/support/database_cleaner.rb
|
85
|
+
- lib/bdd_rails/templates/install/spec/support/factory_girl.rb
|
86
|
+
- lib/bdd_rails/templates/install/spec/support/mail_cleaner.rb
|
87
|
+
- lib/bdd_rails/templates/install/spec/support/rspec_expectations.rb
|
88
|
+
- lib/bdd_rails/templates/install/spec/support/rspec_mocks.rb
|
89
|
+
- lib/bdd_rails/templates/install/spec/support/rspec_output.rb
|
90
|
+
- lib/bdd_rails/templates/install/spec/support/rspec_run_conditions.rb
|
91
|
+
- lib/bdd_rails/templates/install/spec/support/vcr.rb
|
86
92
|
- lib/bdd_rails/version.rb
|
87
|
-
- spec/
|
93
|
+
- spec/01_setup.sh
|
94
|
+
- spec/02_installing_spec.sh
|
95
|
+
- spec/03_example_spec.sh
|
88
96
|
homepage: https://github.com/madetech/bdd-rails
|
89
97
|
licenses:
|
90
98
|
- MIT
|