bdd-rails 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/Gemfile.lock +1 -1
  4. data/README.md +12 -0
  5. data/Rakefile +16 -0
  6. data/lib/bdd_rails/example_generator.rb +17 -0
  7. data/lib/bdd_rails/install_generator.rb +1 -1
  8. data/lib/bdd_rails/railtie.rb +1 -0
  9. data/lib/bdd_rails/templates/example/app/controllers/newsletter_subscriptions_controller.rb +21 -0
  10. data/lib/bdd_rails/templates/example/app/mailers/newsletter_subscription_mailer.rb +5 -0
  11. data/lib/bdd_rails/templates/example/app/models/newsletter_subscription.rb +15 -0
  12. data/lib/bdd_rails/templates/example/app/views/newsletter_subscriptions/new.html.erb +7 -0
  13. data/lib/bdd_rails/templates/example/spec/features/newsletter_spec.rb +17 -0
  14. data/lib/bdd_rails/templates/{.rspec → install/.rspec} +0 -0
  15. data/lib/bdd_rails/templates/{spec → install/spec}/factories/README.md +0 -0
  16. data/lib/bdd_rails/templates/{spec → install/spec}/features/README.md +0 -0
  17. data/lib/bdd_rails/templates/{spec → install/spec}/spec_helper.rb +0 -0
  18. data/lib/bdd_rails/templates/{spec → install/spec}/support/01_rails.rb +0 -0
  19. data/lib/bdd_rails/templates/{spec → install/spec}/support/capybara.rb +0 -0
  20. data/lib/bdd_rails/templates/{spec → install/spec}/support/database_cleaner.rb +0 -0
  21. data/lib/bdd_rails/templates/{spec → install/spec}/support/factory_girl.rb +0 -0
  22. data/lib/bdd_rails/templates/{spec → install/spec}/support/mail_cleaner.rb +0 -0
  23. data/lib/bdd_rails/templates/{spec → install/spec}/support/rspec_expectations.rb +0 -0
  24. data/lib/bdd_rails/templates/{spec → install/spec}/support/rspec_mocks.rb +0 -0
  25. data/lib/bdd_rails/templates/{spec → install/spec}/support/rspec_output.rb +0 -0
  26. data/lib/bdd_rails/templates/{spec → install/spec}/support/rspec_run_conditions.rb +0 -0
  27. data/lib/bdd_rails/templates/{spec → install/spec}/support/vcr.rb +0 -0
  28. data/lib/bdd_rails/version.rb +1 -1
  29. data/spec/01_setup.sh +4 -0
  30. data/spec/{installing_spec.sh → 02_installing_spec.sh} +2 -3
  31. data/spec/03_example_spec.sh +6 -0
  32. metadata +25 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f0697d3a3c6ada781aa0ea675cbd5e64bc37e26
4
- data.tar.gz: 9c080524f04884b191b5ca05a415338887c5ac8c
3
+ metadata.gz: 1b5839031b39c3a57de3d7135481edae5d2f106e
4
+ data.tar.gz: fd7f1c552bac87728364eed8227821ce33389a9d
5
5
  SHA512:
6
- metadata.gz: 1835ba210209d3b1a04827b47b911a52d3bda7b6d1ba9740f2ad3e0fc4bc4b65382461898e3d69412ff59e13d9f65ed822400de1b56d00232031c8ddea5c6713
7
- data.tar.gz: 52248a9512f5bb8671c8a1e9134853f0c99ccb672f07d41d0df177a75ff57833be0974e8098c06cb3e3fa1cdf8b1051a0c3dcdf0a96c072dca9d4a8441b79bb8
6
+ metadata.gz: b2be6b15c3b16c31d18c1f241df3d537de5fad316e682ec8023f151a052d2d499326609c725536fbe20142ee38bb6b671378319474a706766be29de4e786adf2
7
+ data.tar.gz: 29721d9d8224fa66c60c3d5733cc811ecc9f09fad75b836dec5e1444a2e8d7f4711806eb68d78869cc78c93d13d907e0c659d8b698f0f4cbbb75705ae2a54c4f
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@ rvm:
2
2
  - 2.1
3
3
  - 2.2
4
4
 
5
- script: sh spec/installing_spec.sh
5
+ script: bundle exec rake
6
6
 
7
7
  notifications:
8
8
  slack: madetechteam:be3g1qE6so2p2UcqQiOGBRUs
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bdd-rails (0.1.3)
4
+ bdd-rails (0.1.4)
5
5
  bundler
6
6
  rails
7
7
 
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
@@ -1,6 +1,6 @@
1
1
  module BddRails
2
2
  class InstallGenerator < ::Rails::Generators::Base
3
- source_root File.expand_path('../templates', __FILE__)
3
+ source_root File.expand_path('../templates/install', __FILE__)
4
4
 
5
5
  def install_spec_directory
6
6
  directory 'spec'
@@ -5,6 +5,7 @@ module BddRails
5
5
  class Railtie < ::Rails::Railtie
6
6
  generators do
7
7
  require 'bdd_rails/install_generator'
8
+ require 'bdd_rails/example_generator'
8
9
  end
9
10
  end
10
11
  end
@@ -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,5 @@
1
+ class NewsletterSubscriptionMailer < ActionMailer::Base
2
+ def welcome(email)
3
+ mail(from: 'example@example.com', to: email, body: 'Welcome')
4
+ end
5
+ 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,7 @@
1
+ <%= flash[:notice] %>
2
+
3
+ <%= form_for @subscription do |f| %>
4
+ <%= f.text_field :email %>
5
+ <%= @subscription.errors[:email].join(', ') %>
6
+ <%= f.submit 'Sign up' %>
7
+ <% 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
@@ -1,3 +1,3 @@
1
1
  module BddRails
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
data/spec/01_setup.sh ADDED
@@ -0,0 +1,4 @@
1
+ set -e
2
+
3
+ rm -rf test_app
4
+ bundle exec rails new --skip-test-unit test_app
@@ -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
@@ -0,0 +1,6 @@
1
+ set -e
2
+
3
+ cd test_app
4
+ export BUNDLE_GEMFILE=$PWD/Gemfile
5
+ bundle exec rails g bdd_rails:example
6
+ bundle exec rspec spec/features/newsletter_spec.rb
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.3
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-06 00:00:00.000000000 Z
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/.rspec
73
- - lib/bdd_rails/templates/spec/factories/README.md
74
- - lib/bdd_rails/templates/spec/features/README.md
75
- - lib/bdd_rails/templates/spec/spec_helper.rb
76
- - lib/bdd_rails/templates/spec/support/01_rails.rb
77
- - lib/bdd_rails/templates/spec/support/capybara.rb
78
- - lib/bdd_rails/templates/spec/support/database_cleaner.rb
79
- - lib/bdd_rails/templates/spec/support/factory_girl.rb
80
- - lib/bdd_rails/templates/spec/support/mail_cleaner.rb
81
- - lib/bdd_rails/templates/spec/support/rspec_expectations.rb
82
- - lib/bdd_rails/templates/spec/support/rspec_mocks.rb
83
- - lib/bdd_rails/templates/spec/support/rspec_output.rb
84
- - lib/bdd_rails/templates/spec/support/rspec_run_conditions.rb
85
- - lib/bdd_rails/templates/spec/support/vcr.rb
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/installing_spec.sh
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