Configuring Maven for Java Frameworks

installing/configuring maven


  1. download maven:
    1. navigate to https://maven.apache.org/download.cgi
    2. click link for Binary tar.gz archive: apache-maven-3.3.9-bin.tar.gz
    3. save it to Desktop
  2. create /usr/local/apache-maven folder:
    1. on finder, click Go tab
    2. click Go To Folder…
    3. type /usr/local    - then click Go
    4. create a folder called apache-maven
    5. copy the apache-maven-3.3.9-bin.tar.gz folder from Desktop into the apache-maven folder
  3. configure Java JDK Path and Maven path in .bash_profile:
    1. download Java JDK for Mac OS X - http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
    2. open a terminal and type: /usr/libexec/java_home   - then copy the path for the java idk that is returned
    3. type the following four commands into the terminal, hit enter after each one:export
      1. JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home    (if this path differs from the one you copied, substitute it with the one you copied)
      2. export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9   
      3. export M2=$M2_HOME/bin
      4. export PATH=$M2:$PATH
    4. type command in terminal: source ~/.bash_profile
    5. verify Java JDK and Maven are installed by typing command in terminal: mvn —v

TDD - Feature Specs with Capybara

Feature specs with Capybara

1   Installing Capybara
·      Add the capybara gem for the test database in our Gemfile:
group :test do
  gem 'capybara'
end
·      Run ‘bundle install’ in terminal to install the gem
     Next, in spec/rails_helper.rb write the following line:
require 'capybara/rails'
·      Mkdir spec/features folder which is where our feature test files will be stored
2
     Implementing a simple feature spec
·      For our first feature spec, we want to test the ability of a user to 1.visit the /sign_in page, 2. fill in the email and password fields, 3. click on the sign in button and then we want to verify that the user is signed in.
·      Create the user_sign_in_spec.rb feature spec file in spec/features and implement the “User signs in” feature spec:

      require 'rails_helper'
feature "User signs in" do
  scenario "with valid email and password" do
    bob = Fabricate(:user)
    visit sign_in_path
    fill_in "Email Address", with: bob.email
    fill_in "Password", with: bob.password
    click_button "Sign in"
    page.should have_content bob.full_name
  end
end
·   
Our assertion will look to see that the page that the user is redirected to after signing in has the full_name attribute of our user as its content.
·        Run the spec, ‘rspec spec/features/user_sign_in_path.rb' and it passes!