Skip to content

Commit

Permalink
Scari - first functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
Scaria committed Oct 1, 2014
1 parent f37dead commit 2bbb6d0
Show file tree
Hide file tree
Showing 22 changed files with 397 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ gem "twitter-bootstrap-rails"

group :test do
gem 'cucumber-rails'
gem 'rspec'
gem 'database_cleaner'
gem 'selenium-webdriver'
end

Expand Down
15 changes: 15 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ GEM
mime-types (~> 1.16)
nokogiri (~> 1.5)
rails (>= 3, < 5)
database_cleaner (1.3.0)
diff-lcs (1.2.5)
erubis (2.7.0)
execjs (2.2.1)
Expand Down Expand Up @@ -107,6 +108,18 @@ GEM
rdoc (4.1.2)
json (~> 1.4)
ref (1.0.5)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-core (3.1.5)
rspec-support (~> 3.1.0)
rspec-expectations (3.1.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.1.0)
rspec-mocks (3.1.2)
rspec-support (~> 3.1.0)
rspec-support (3.1.1)
rubyzip (1.1.6)
sass (3.2.19)
sass-rails (4.0.3)
Expand Down Expand Up @@ -162,10 +175,12 @@ PLATFORMS
DEPENDENCIES
coffee-rails (~> 4.0.0)
cucumber-rails
database_cleaner
jbuilder (~> 1.2)
jquery-rails
less-rails
rails (= 4.0.2)
rspec
sass-rails (~> 4.0.0)
sdoc
selenium-webdriver
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/bootstrap.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
jQuery ->
$("a[rel~=popover], .has-popover").popover()
$("a[rel~=tooltip], .has-tooltip").tooltip()
3 changes: 3 additions & 0 deletions app/assets/javascripts/home.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
30 changes: 30 additions & 0 deletions app/assets/stylesheets/bootstrap_and_overrides.css.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@import "twitter/bootstrap/bootstrap";
@import "twitter/bootstrap/responsive";

// Set the correct sprite paths
@iconSpritePath: image-url("twitter/bootstrap/glyphicons-halflings.png");
@iconWhiteSpritePath: image-url("twitter/bootstrap/glyphicons-halflings-white.png");

// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
@fontAwesomeEotPath: asset-url("fontawesome-webfont.eot");
@fontAwesomeEotPath_iefix: asset-url("fontawesome-webfont.eot?#iefix");
@fontAwesomeWoffPath: asset-url("fontawesome-webfont.woff");
@fontAwesomeTtfPath: asset-url("fontawesome-webfont.ttf");
@fontAwesomeSvgPath: asset-url("fontawesome-webfont.svg#fontawesomeregular");

// Font Awesome
@import "fontawesome/font-awesome";

// Glyphicons
//@import "twitter/bootstrap/sprites.less";

// Your custom LESS stylesheets goes here
//
// Since bootstrap was imported above you have access to its mixins which
// you may use and inherit here
//
// If you'd like to override bootstrap's own variables, you can do so here as well
// See http://twitter.github.com/bootstrap/customize.html#variables for their names and documentation
//
// Example:
// @linkColor: #ff0000;
86 changes: 86 additions & 0 deletions app/assets/stylesheets/home.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Place all the styles related to the home controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

body {
padding-top: 120px;
padding-bottom: 40px;
background-color: #eee;

}
.btn
{
outline:0;
border:none;
border-top:none;
border-bottom:none;
border-left:none;
border-right:none;
box-shadow:inset 2px -3px rgba(0,0,0,0.15);
}
.btn:focus
{
outline:0;
-webkit-outline:0;
-moz-outline:0;
}
.fullscreen_bg {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-size: cover;
background-position: 50% 50%;
background-image: url('../images/home.jpg');
background-repeat:repeat;
}
.form-signin {
max-width: 280px;
padding: 15px;
margin: 0 auto;
margin-top:50px;
}
.form-signin .form-signin-heading, .form-signin {
margin-bottom: 10px;
}
.form-signin .form-control {
position: relative;
font-size: 16px;
height: auto;
padding: 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.form-signin .form-control:focus {
z-index: 2;
}
.form-signin input[type="text"] {
margin-bottom: -1px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: none;
border-left-style: solid;
border-color: #000;
width: 276px;
}
.form-signin input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
border-top-style: none;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-color: rgb(0,0,0);
border-top:1px solid rgba(0,0,0,0.08);
width: 276px;
}
.form-signin-heading {
color: #fff;
text-align: center;
text-shadow: 0 2px 2px rgba(0,0,0,0.5);
}
4 changes: 4 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class HomeController < ApplicationController
def index
end
end
2 changes: 2 additions & 0 deletions app/helpers/home_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module HomeHelper
end
34 changes: 34 additions & 0 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@


<div class="container">
<div class="row">
<div class="span9">
<%= bootstrap_flash %>

</div>
<div class="span12 home">

<div id="fullscreen_bg" class="fullscreen_bg"/>

<div class="container">

<form class="form-signin">
<h1 class="form-signin-heading text-muted">Sign In</h1>
<input type="text" class="form-control" id="email-input" placeholder="Email address" required="" autofocus="">
<input type="password" class="form-control" id="password-input" placeholder="Password" required="">
<button class="btn btn-lg btn-primary btn-block" id="sign_in" type="submit">
Sign In
</button>
</form>

</div>


</div><!--/row-->

<footer>
<p>&copy; ImageSpace Inc 2014</p>
</footer>

</div> <!-- /container -->

8 changes: 8 additions & 0 deletions config/cucumber.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
18 changes: 18 additions & 0 deletions config/locales/en.bootstrap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Sample localization file for English. Add more files in this directory for other locales.
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.

en:
helpers:
actions: "Actions"
links:
back: "Back"
cancel: "Cancel"
confirm: "Are you sure?"
destroy: "Delete"
new: "New"
edit: "Edit"
titles:
edit: "Edit %{model}"
save: "Save %{model}"
new: "New %{model}"
delete: "Delete %{model}"
16 changes: 16 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 0) do

end
10 changes: 10 additions & 0 deletions features/home_page.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: A new user comes to home page and fills the email and password to login.
But website returns the same home page as reply

Scenario: New user tries login
Given I am a new user
And I load the home page
And I fill in "email-input" with "[email protected]"
And I fill in "password-input" with "password"
When I press "sign_in"
Then the same home page is loaded
Empty file.
19 changes: 19 additions & 0 deletions features/step_definitions/home_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Given(/^I am a new user$/) do
#logout user
end

Given(/^I load the home page$/) do
visit "http://localhost:3000"
end

Given(/^I fill in "(.*?)" with "(.*?)"$/) do |field, value|
fill_in(field, :with => value)
end

When(/^I press "(.*?)"$/) do |button|
click_button(button)
end

Then(/^the same home page is loaded$/) do
page.should have_content("ImageSpace")
end
59 changes: 59 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.

require 'cucumber/rails'

# Capybara defaults to CSS3 selectors rather than XPath.
# If you'd prefer to use XPath, just uncomment this line and adjust any
# selectors in your step definitions to use the XPath syntax.
# Capybara.default_selector = :xpath

# By default, any exception happening in your Rails application will bubble up
# to Cucumber so that your scenario will fail. This is a different from how
# your application behaves in the production environment, where an error page will
# be rendered instead.
#
# Sometimes we want to override this default behaviour and allow Rails to rescue
# exceptions and display an error page (just like when the app is running in production).
# Typical scenarios where you want to do this is when you test your error pages.
# There are two ways to allow Rails to rescue exceptions:
#
# 1) Tag your scenario (or feature) with @allow-rescue
#
# 2) Set the value below to true. Beware that doing this globally is not
# recommended as it will mask a lot of errors for you!
#
ActionController::Base.allow_rescue = false

# Remove/comment out the lines below if your app doesn't have a database.
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
begin
DatabaseCleaner.strategy = :transaction
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end

# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
# See the DatabaseCleaner documentation for details. Example:
#
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
# # { :except => [:widgets] } may not do what you expect here
# # as Cucumber::Rails::Database.javascript_strategy overrides
# # this setting.
# DatabaseCleaner.strategy = :truncation
# end
#
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
# DatabaseCleaner.strategy = :transaction
# end
#

# Possible values are :truncation and :transaction
# The :transaction strategy is faster, but might give you threading problems.
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
Cucumber::Rails::Database.javascript_strategy = :truncation
Capybara.default_driver = :selenium

Loading

0 comments on commit 2bbb6d0

Please sign in to comment.