Skip to content

Commit

Permalink
Update specs
Browse files Browse the repository at this point in the history
  • Loading branch information
bricesanchez committed Apr 13, 2016
1 parent eff22f3 commit 2ab2077
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 85 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Expand Up @@ -40,6 +40,10 @@ group :development do
gem 'quiet_assets'
end

group :development, :test do
gem 'rspec-its'
end

group :test do
gem "launchy"
end
Expand Down
34 changes: 17 additions & 17 deletions spec/features/refinery/calendar/admin/events_spec.rb
@@ -1,11 +1,11 @@
# encoding: utf-8
require "spec_helper"

describe Refinery do
describe "Calendar" do
describe "Admin" do
describe "events" do
refinery_login_with :refinery_user
module Refinery
module Calendar
module Admin
describe Event, type: :feature do
refinery_login

describe "events list" do
before(:each) do
Expand All @@ -15,8 +15,8 @@

it "shows two items" do
visit refinery.calendar_admin_events_path
page.should have_content("UniqueTitleOne")
page.should have_content("UniqueTitleTwo")
expect(page).to have_content("UniqueTitleOne")
expect(page).to have_content("UniqueTitleTwo")
end
end

Expand All @@ -32,17 +32,17 @@
fill_in "Title", :with => "This is a test of the first string field"
click_button "Save"

page.should have_content("'This is a test of the first string field' was successfully added.")
Refinery::Calendar::Event.count.should == 1
expect(page).to have_content("'This is a test of the first string field' was successfully added.")
expect(Refinery::Calendar::Event.count).to eq(1)
end
end

context "invalid data" do
it "should fail" do
click_button "Save"

page.should have_content("Title can't be blank")
Refinery::Calendar::Event.count.should == 0
expect(page).to have_content("Title can't be blank")
expect(Refinery::Calendar::Event.count).to eq(0)
end
end

Expand All @@ -57,8 +57,8 @@
fill_in "Title", :with => "UniqueTitle"
click_button "Save"

page.should have_content("There were problems")
Refinery::Calendar::Event.count.should == 1
expect(page).to have_content("There were problems")
expect(Refinery::Calendar::Event.count).to eq(1)
end
end

Expand All @@ -77,8 +77,8 @@
fill_in "Title", :with => "A different title"
click_button "Save"

page.should have_content("'A different title' was successfully updated.")
page.should have_no_content("A title")
expect(page).to have_content("'A different title' was successfully updated.")
expect(page).to have_no_content("A title")
end
end

Expand All @@ -90,8 +90,8 @@

click_link "Remove this event forever"

page.should have_content("'UniqueTitleOne' was successfully removed.")
Refinery::Calendar::Event.count.should == 0
expect(page).to have_content("'UniqueTitleOne' was successfully removed.")
expect(Refinery::Calendar::Event.count).to eq(0)
end
end

Expand Down
34 changes: 17 additions & 17 deletions spec/features/refinery/calendar/admin/venues_spec.rb
@@ -1,11 +1,11 @@
# encoding: utf-8
require "spec_helper"

describe Refinery do
describe "Calendar" do
describe "Admin" do
describe "venues" do
refinery_login_with :refinery_user
module Refinery
module Calendar
module Admin
describe Venue, type: :feature do
refinery_login

describe "venues list" do
before(:each) do
Expand All @@ -15,8 +15,8 @@

it "shows two items" do
visit refinery.calendar_admin_venues_path
page.should have_content("UniqueTitleOne")
page.should have_content("UniqueTitleTwo")
expect(page).to have_content("UniqueTitleOne")
expect(page).to have_content("UniqueTitleTwo")
end
end

Expand All @@ -32,17 +32,17 @@
fill_in "Name", :with => "This is a test of the first string field"
click_button "Save"

page.should have_content("'This is a test of the first string field' was successfully added.")
Refinery::Calendar::Venue.count.should == 1
expect(page).to have_content("'This is a test of the first string field' was successfully added.")
expect(Refinery::Calendar::Venue.count).to eq(1)
end
end

context "invalid data" do
it "should fail" do
click_button "Save"

page.should have_content("Name can't be blank")
Refinery::Calendar::Venue.count.should == 0
expect(page).to have_content("Name can't be blank")
expect(Refinery::Calendar::Venue.count).to eq(0)
end
end

Expand All @@ -57,8 +57,8 @@
fill_in "Name", :with => "UniqueTitle"
click_button "Save"

page.should have_content("There were problems")
Refinery::Calendar::Venue.count.should == 1
expect(page).to have_content("There were problems")
expect(Refinery::Calendar::Venue.count).to eq(1)
end
end

Expand All @@ -77,8 +77,8 @@
fill_in "Name", :with => "A different name"
click_button "Save"

page.should have_content("'A different name' was successfully updated.")
page.should have_no_content("A name")
expect(page).to have_content("'A different name' was successfully updated.")
expect(page).to have_no_content("A name")
end
end

Expand All @@ -90,8 +90,8 @@

click_link "Remove this venue forever"

page.should have_content("'UniqueTitleOne' was successfully removed.")
Refinery::Calendar::Venue.count.should == 0
expect(page).to have_content("'UniqueTitleOne' was successfully removed.")
expect(Refinery::Calendar::Venue.count).to eq(0)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/refinery/calendar/event_spec.rb
Expand Up @@ -2,7 +2,7 @@

module Refinery
module Calendar
describe Event do
describe Event, type: :model do
describe "validations" do
subject do
FactoryGirl.create(:event, :title => "Refinery CMS")
Expand Down
2 changes: 1 addition & 1 deletion spec/models/refinery/calendar/venue_spec.rb
Expand Up @@ -2,7 +2,7 @@

module Refinery
module Calendar
describe Venue do
describe Venue, type: :model do
describe "validations" do
subject do
FactoryGirl.create(:venue,
Expand Down
67 changes: 21 additions & 46 deletions spec/spec_helper.rb
@@ -1,52 +1,27 @@
def setup_environment
# Configure Rails Environment
ENV["RAILS_ENV"] ||= 'test'
require 'rubygems'

require File.expand_path("../dummy/config/environment", __FILE__)
# Configure Rails Environment
ENV["RAILS_ENV"] ||= 'test'

require 'rspec/rails'
require 'capybara/rspec'
require File.expand_path("../dummy/config/environment", __FILE__)

Rails.backtrace_cleaner.remove_silencers!
require 'rspec/rails'
require 'capybara/rspec'

RSpec.configure do |config|
config.mock_with :rspec
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.extend Refinery::Testing::FeatureMacros::Authentication, type: :feature

config.run_all_when_everything_filtered = true
end
end

def each_run
Rails.cache.clear
ActiveSupport::Dependencies.clear
FactoryGirl.reload

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories including factories.
([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p|
Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
}.flatten.sort.each do |support_file|
require support_file
end
RSpec.configure do |config|
config.mock_with :rspec
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
config.backtrace_exclusion_patterns = %w(
rails actionpack railties capybara activesupport rack warden rspec actionview
activerecord dragonfly benchmark
).map { |noisy| /#{noisy}/ }
end

# If spork is available in the Gemfile it'll be used but we don't force it.
unless (begin; require 'spork'; rescue LoadError; nil end).nil?
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
setup_environment
end

Spork.each_run do
# This code will be run each time you run your specs.
each_run
end
else
setup_environment
each_run
end
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories including factories.
([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p|
Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
}.flatten.sort.each do |support_file|
require support_file
end
4 changes: 1 addition & 3 deletions tasks/rspec.rake
@@ -1,6 +1,4 @@
require 'rspec/core/rake_task'

desc "Run specs"
RSpec::Core::RakeTask.new do |t|
t.pattern = "./spec"
end
RSpec::Core::RakeTask.new

0 comments on commit 2ab2077

Please sign in to comment.