Hi All, I've been using Angular 1.5 with some nodejs apps and really like the framework, so much so that I'm trying to introduce Angular to a Rails app that's been in production for a couple of years now, and have a problem with my angular related cucumber features that I'm hoping someone can help me with, or point me in the right direction.
All Angular features work fine in development and when deployed to production, so it 'appears' that I've integrated Angular correctly for these environments, the problem is with my test environment. My specific problem is that when I run my cukes, *some* of the modules don't appear to be injected. Currently, I inject four modules into the Angular App module, and cukes that run against two of the modules pass while cukes that run against the other two modules fail due to the controllers not being found. I've confirmed this in the browser console as the cukes run. The error in the browser console is as follows: Error: [ng:areq] Argument 'BankingCtrl' is not a function, got undefined Here is the content of relevant files: Gemfile: source 'https://rubygems.org' ruby '2.3.0' gem 'rails', '4.2.6' gem 'angularjs-rails' gem 'binding_of_caller' gem 'bower-rails' gem 'carrierwave' gem 'coffee-rails' gem 'declarative_authorization' gem 'devise' gem 'docsplit' gem 'foundation-rails' gem 'gretel' gem 'haml-rails' gem 'jquery-rails' gem 'jwt', '1.5.2' gem 'i18n' gem 'jbuilder' gem 'mechanize' gem 'momentjs-rails' gem 'mysql2', '~> 0.3.18' gem 'nested_form' gem 'passenger' gem 'paperless_core', '0.6.0', path: 'vendor/gems/paperless_core-0.6.11' gem "polyamorous" gem "ransack" gem 'rake' gem 'ruby_parser' gem 'spreadsheet' gem 'sprockets' gem 'sprockets-rails', :require => 'sprockets/railtie' gem 'twilio-ruby' gem 'uglifier' group :doc do gem 'sdoc', '~> 0.4.0' end group :assets do gem 'sass' gem 'sass-rails' gem 'compass-rails' end group :development do gem 'better_errors' gem 'capistrano', '~> 3.1' gem 'capistrano-rails', '~> 1.1', require: false gem 'capistrano-bundler', '~> 1.1', require: false gem 'capistrano-rbenv', '~> 2.0' gem 'capistrano-passenger' end group :development, :test do gem 'capybara' gem 'capybara-webkit' gem 'cucumber-rails', require: false gem 'database_cleaner' gem 'factory_girl_rails' gem 'minitest' gem 'quiet_assets' gem 'rails_layout' gem 'rspec-rails' gem 'selenium-webdriver' gem "shoulda-matchers" gem 'sqlite3' end assets/javascripts/app.js //= require jquery //= require jquery_ujs //= require foundation //= require angular //= require angular-resource //= require moment //= require jquery_nested_form //= require_tree . // Init Foundation $(function(){ $(document).foundation(); }); // Init Angular app = angular.module("Paperless", ["ngResource","Lead","Person","Renewal","Banking"]) app.config([ "$httpProvider", function($httpProvider) { $httpProvider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content'); $httpProvider.defaults.useXDomain = true; delete $httpProvider.defaults.headers.common['X-Requested-With']; } ]); app.controller("AppCtrl", ["$scope","$log", function($scope, $log) {}]); The failing module and related view: assets/javascripts/angular/banking.js.coffee angular.module("Banking", ["Buttons"]) .controller "BankingCtrl", ["$scope", "$http", "$log", ($scope, $http, $log) -> ... ] views/bankings/new.html.haml %section{"data-ng-controller"=>"BankingCtrl"} ... The following module appears to load fine in the test env, and all related cukes run as expected: app/javascripts/angular/renewal.js.coffee angular.module("Renewal",['Buttons']) .controller "RenewalCtrl", ["$scope","$http","$log", ($scope,$http,$log) -> ... ] and the related view: views/renewals/show.html.haml %section{"data-ng-controller" => "RenewalCtrl"} ... I have read that Cucumber and Angular don't play well together, and that I should introduce Protractor. However, before I start changing my test environment I was hoping someone could explain why RenewalCtrl is found and the data bindings are connected, while BankingCtrl is not found. Am I just lucky with RenewalCtrl? I can provide any additional info if need be. Hopefully there is an Angular/Rails dev out there that can help. I'd be happy to contribute an Angular/Rails app to the RailsApps project to help others if I can get this figured out. Thanks to all that took the time to read. Paul -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
