Skip to content

Commit

Permalink
Update rspec
Browse files Browse the repository at this point in the history
Conflicts:
	Gemfile
	Gemfile.lock
  • Loading branch information
johnam committed May 9, 2014
1 parent 79e53cd commit 1da1981
Show file tree
Hide file tree
Showing 29 changed files with 85 additions and 80 deletions.
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ end
group :development, :test do
gem 'rails_best_practices'
gem 'jslint_on_rails'
gem 'rspec-rails'
gem 'rspec-rails', '2.14.1'
gem 'rspec-instafail'
gem 'rspec-html-matchers'
gem 'rspec_junit_formatter'
gem 'guard-rspec'
gem 'poltergeist'
gem 'capybara'
Expand All @@ -105,9 +108,7 @@ group :development, :test do
gem 'sunspot_test'
gem 'wkhtmltopdf'
gem 'foreman'
gem 'rspec_junit_formatter'
gem 'simplecov'
gem 'rspec-html-matchers'
gem 'parallel_tests'
gem 'spork-rails'
gem 'shoulda-matchers'
Expand Down
33 changes: 18 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ GEM
money (5.0.0)
i18n (~> 0.4)
json
multi_json (1.9.2)
multi_json (1.10.0)
mysql2 (0.3.11)
netrc (0.7.7)
newrelic_rpm (3.5.6.55)
Expand Down Expand Up @@ -309,7 +309,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.2.1)
rake (10.3.1)
rdoc (3.12.2)
json (~> 1.4)
recurly (2.1.8)
Expand All @@ -323,24 +323,26 @@ GEM
spreadsheet (> 0.6.4)
rsolr (1.0.8)
builder (>= 2.1.2)
rspec (2.12.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
rspec-mocks (~> 2.12.0)
rspec-core (2.12.2)
rspec-expectations (2.12.1)
diff-lcs (~> 1.1.3)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-html-matchers (0.4.0)
nokogiri (>= 1.4.4)
rspec (>= 2.0.0)
rspec-mocks (2.12.2)
rspec-rails (2.12.2)
rspec-instafail (0.2.4)
rspec-mocks (2.14.6)
rspec-rails (2.14.1)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
rspec-mocks (~> 2.12.0)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec_junit_formatter (0.1.6)
builder
rspec (~> 2.0)
Expand Down Expand Up @@ -517,7 +519,8 @@ DEPENDENCIES
redcarpet
roo
rspec-html-matchers
rspec-rails
rspec-instafail
rspec-rails (= 2.14.1)
rspec_junit_formatter
sass-rails
seed-fu
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/admin/action_pages_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@
:id => @action_page.id
}

assigns(:action_page).content_modules.should =~ [ html_module_head, html_module_sidebar ]
assigns(:action_page).modules_for_container_and_language(ContentModule::SIDEBAR, language).should =~ [ html_module_sidebar ]
assigns(:action_page).content_modules.should match_array([ html_module_head, html_module_sidebar ])
assigns(:action_page).modules_for_container_and_language(ContentModule::SIDEBAR, language).should match_array([ html_module_sidebar ])
end

it "should render blank modules for a new language" do
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/admin/homepages_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
FactoryGirl.create(:homepage_content, :language => fr, :homepage => movement.homepage)

get :edit, :movement_id => movement.id
assigns(:homepage_contents).map(&:language).map(&:iso_code).should =~ ["fr", "pt"]
assigns(:homepage_contents).map(&:new_record?).should =~ [ true, false ]
assigns(:homepage_contents).map(&:language).map(&:iso_code).should match_array(["fr", "pt"])
assigns(:homepage_contents).map(&:new_record?).should match_array([ true, false ])
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/api/activities_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def user_that_has_taken_an_action_on_page
json = ActiveSupport::JSON.decode(response.body)
json.count.should == 2
user_activity_event_ids = json.collect { |uae| uae["id"] }
user_activity_event_ids.should =~ [@first_activity_event.id, @another_activity_event.id]
user_activity_event_ids.should == [@first_activity_event.id, @another_activity_event.id]
end
end

Expand Down Expand Up @@ -118,7 +118,7 @@ def user_that_has_taken_an_action_on_page
json = ActiveSupport::JSON.decode(response.body)
json.count.should eql 2
ids = json.collect { |uae| uae["id"] }
ids.should =~ [@first_activity_event.id, @another_activity_event.id]
ids.should == [@first_activity_event.id, @another_activity_event.id]
end
end
end
Expand Down Expand Up @@ -161,7 +161,7 @@ def user_that_has_taken_an_action_on_page
json = ActiveSupport::JSON.decode(response.body)
json.count.should == 2
user_activity_event_ids = json.collect { |uae| uae["id"] }
user_activity_event_ids.should =~ [subscribed_event_from_hp.id, action_taken_event.id]
user_activity_event_ids.should match_array([subscribed_event_from_hp.id, action_taken_event.id])
end

it "should not filter out actions with profane comments if comment parameter is not present" do
Expand Down Expand Up @@ -191,7 +191,7 @@ def user_that_has_taken_an_action_on_page
json = ActiveSupport::JSON.decode(response.body)
json.count.should == 2
user_activity_event_ids = json.collect { |uae| uae["id"] }
user_activity_event_ids.should =~ [subscribed_event.id, another_user_subscribed_event.id]
user_activity_event_ids.should == [subscribed_event.id, another_user_subscribed_event.id]
end
end

Expand Down
15 changes: 8 additions & 7 deletions spec/controllers/api/base_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
require 'spec_helper'

describe Api::BaseController do
class Api::BaseController

controller(Api::BaseController) do
def create; render :text => ""; end
def index; render :text => "gotten"; end
end


def perform_request
with_routing do |map|
map.draw do
post 'api/movements/(:movement_id)/members(.:format)' => 'api/base#create'
get 'api/movements/(:movement_id)' => 'api/base#index'
end
yield
routes.draw do
post 'api/movements/(:movement_id)/members(.:format)' => 'anonymous#create'
get 'api/movements/(:movement_id)' => 'anonymous#index'
end

yield
end

before do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,12 @@

it 'should return unprocessable entity status' do
post :create, movement_id: movement.slug, user: {}
response.status.should be_== 422
response.status.should == 422
end

it 'should return the external action errors' do
post :create, movement_id: movement.slug, user: {}
response.body.should be_== "this is the external action errors".to_json
response.body.should == "this is the external action errors".to_json
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/controllers/api/sendgrid_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let(:user) { FactoryGirl.create(:user, email: '[email protected]', movement: movement) }

def expect_user_to_be_permanently_unsubscribed(&block)
UserActivityEvent.should_receive(:unsubscribed!).with(user, nil)
expect(UserActivityEvent).to receive(:unsubscribed!).with(user, nil)

yield

Expand All @@ -17,7 +17,7 @@ def expect_user_to_be_permanently_unsubscribed(&block)
describe '#event_handler' do

it 'should return 200 in order to prevent sendgrid from retrying' do
Delayed::Job.should_receive(:enqueue) { raise "some error" }
expect(Delayed::Job).to receive(:enqueue) { raise "some error" }

post :event_handler, movement_id: movement.id, '_json' => [{}]

Expand All @@ -36,7 +36,7 @@ def dropped_event_params(email_address, reason)
context 'Unsubscribed Address' do

it 'should unsubscribe the user' do
UserActivityEvent.should_receive(:unsubscribed!).with(user, nil)
expect(UserActivityEvent).to receive(:unsubscribed!).with(user, nil)

post :event_handler, movement_id: movement.id, '_json' => dropped_event_params(user.email, 'Unsubscribed Address')

Expand Down Expand Up @@ -96,7 +96,7 @@ def dropped_event_params(email_address, reason)

it 'should unsubscribe the user and associate the event with an email' do
email = create(:email)
UserActivityEvent.should_receive(:unsubscribed!).with(user, email)
expect(UserActivityEvent).to receive(:unsubscribed!).with(user, email)

post :event_handler, movement_id: movement.id, '_json' => [{'email' => user.email,
'event' => 'unsubscribe',
Expand All @@ -114,8 +114,8 @@ def dropped_event_params(email_address, reason)

it 'should permanently unsubscribe the member, record a spam event, and associate both events with an email' do
email = create(:email)
UserActivityEvent.should_receive(:email_spammed!).with(user, email)
UserActivityEvent.should_receive(:unsubscribed!).with(user, email)
expect(UserActivityEvent).to receive(:email_spammed!).with(user, email)
expect(UserActivityEvent).to receive(:unsubscribed!).with(user, email)

post :event_handler, movement_id: movement.id, '_json' => [{'email' => user.email,
'event' => 'spamreport',
Expand Down
12 changes: 6 additions & 6 deletions spec/models/action_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def page_with_module(module_type)
spanish_taf_module_link = create(:taf_module_link, page: action_page)
spanish_taf_module_link.content_module.update_attributes(language: spanish)

action_page.tafs_for_locale(portuguese).should =~ [portuguese_taf_module_link.content_module]
action_page.tafs_for_locale(portuguese).should match_array([portuguese_taf_module_link.content_module])
end
end

Expand Down Expand Up @@ -716,7 +716,7 @@ def page_with_module(module_type)
let!(:taf_page) { create(:action_page) }

it "should return the newly linked content modules" do
petition_page.link_existing_modules_to(taf_page, ContentModule::HEADER).should =~ [image_html_module, text_html_module]
petition_page.link_existing_modules_to(taf_page, ContentModule::HEADER).should match_array([image_html_module, text_html_module])
end

it "should link all of the source page container's content modules that are not yet linked to the target page's container" do
Expand All @@ -727,7 +727,7 @@ def page_with_module(module_type)

petition_page.link_existing_modules_to taf_page, ContentModule::HEADER
taf_page.reload
taf_page.content_modules.should =~ [already_shared_html_module, image_html_module, text_html_module]
taf_page.content_modules.should match_array([already_shared_html_module, image_html_module, text_html_module])
end

end
Expand All @@ -739,9 +739,9 @@ def page_with_module(module_type)
donation_page = create(:action_page, action_sequence: action_sequence)
taf_page = create(:action_page, action_sequence: action_sequence)

taf_page.sibling_pages.should =~ [petition_page, donation_page]
petition_page.sibling_pages.should =~ [taf_page, donation_page]
donation_page.sibling_pages.should =~ [taf_page, petition_page]
taf_page.sibling_pages.should match_array([petition_page, donation_page])
petition_page.sibling_pages.should match_array([taf_page, donation_page])
donation_page.sibling_pages.should match_array([taf_page, petition_page])
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/content_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
portuguese = FactoryGirl.create(:portuguese)
content_page.movement.languages << portuguese

content_page.possible_languages.should =~ [english, portuguese]
content_page.possible_languages.should match_array([english, portuguese])
end

describe "converted to json format" do
Expand Down
4 changes: 2 additions & 2 deletions spec/models/donation_module_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ def validated_donation_module(attrs)

json = ask.as_json

json["options"]["suggested_amounts"].keys.should =~ ["brl", "usd"]
json["options"]["suggested_amounts"].keys.should match_array(["brl", "usd"])
json["options"]["suggested_amounts"]["brl"].should eql "15,30"
json["options"]["suggested_amounts"]["usd"].should eql "10,20"
json["options"]["recurring_suggested_amounts"].keys.should =~ ["eur", "gbp"]
json["options"]["recurring_suggested_amounts"].keys.should match_array(["eur", "gbp"])
json["options"]["recurring_suggested_amounts"]["eur"].should eql "1"
json["options"]["recurring_suggested_amounts"]["gbp"].should eql "2"
end
Expand Down
4 changes: 2 additions & 2 deletions spec/models/featured_content_collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
FactoryGirl.create(:featured_content_module, :language => spanish, :featured_content_collection => featured_content_collection)

french_module = featured_content_collection.modules_for_language(french)
french_module.should =~ [fr_featured_content_module, fr_featured_content_module2]
french_module.should match_array([fr_featured_content_module, fr_featured_content_module2])
end

it 'should return only valid featured content modules for a given language' do
Expand All @@ -34,7 +34,7 @@
fr_featured_content_module2.save!(:validate => false)

french_modules = carousel.valid_modules_for_language(french)
french_modules.should =~ [fr_featured_content_module]
french_modules.should match_array([fr_featured_content_module])
end

it 'should tell that all modules are valid when so they are' do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/homepage_content_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
homepage = movement.homepage
homepage_content_en = FactoryGirl.create(:homepage_content, :homepage => homepage, :language => english)

homepage.build_content_for_all_languages.map { |c| c.language }.should =~ [english, spanish, portuguese]
homepage.build_content_for_all_languages.map { |c| c.language }.should match_array([english, spanish, portuguese])
end

describe "Logically validate completeness of content" do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/list_cutter/campaign_rule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
FactoryGirl.create(:subscribed_activity, :user => user3, :page => action_page1, :campaign => campaign1, :movement => movement)

rule = ListCutter::CampaignRule.new(:campaigns => [campaign2.id], :movement => movement)
rule.to_relation.all.should =~ [user1]
rule.to_relation.all.should == [user1]
end

it "should return human readable form of conditions" do
Expand Down
4 changes: 2 additions & 2 deletions spec/models/list_cutter/country_rule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
it 'should return users based on commonwealth' do
rule = ListCutter::CountryRule.new(:selected_by => 'commonwealth', :values => ['true'], :not => false, :movement => @action_page.movement)
Country.should_receive(:iso_codes_with).with('commonwealth', ['true']).and_return(['EE', 'US'])
rule.to_relation.all.should =~ [ @user3, @user4 ]
rule.to_relation.all.should match_array([ @user3, @user4 ])
end

it 'should return users based on region' do
rule = ListCutter::CountryRule.new(:selected_by => 'region_id', :values => ['2', '8'], :not => false, :movement => @action_page.movement)
Country.should_receive(:iso_codes_with).with('region_id', ['2', '8']).and_return(['BR', 'AR'])
rule.to_relation.all.should =~ [ @user1, @user2 ]
rule.to_relation.all.should match_array([ @user1, @user2 ])
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/list_cutter/distance_from_point_rule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

rule = ListCutter::DistanceFromPointRule.new(@params)

rule.to_relation.all.should =~ [bob, sally]
rule.to_relation.all.should match_array([bob, sally])
end

describe "#to_human_sql" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
GeoData.should_receive(:find_by_country_iso_and_postcode).with(@params[:country_iso], @params[:postcode].to_s).and_return(mock_geo_datum)
rule = ListCutter::DistanceFromPostcodeRule.new(@params)

rule.to_relation.all.should =~ [bob, sally]
rule.to_relation.all.should match_array([bob, sally])
end

context 'postcode does not exist in geo_data table' do
Expand Down
4 changes: 2 additions & 2 deletions spec/models/list_cutter/donation_amount_rule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
donation_monthly_1 = FactoryGirl.create(:donation, {:frequency => "monthly", :amount_in_cents => 10, :subscription_amount => 10, :subscription_id => "24768374264"})
donation_monthly_2 = FactoryGirl.create(:donation, {:frequency => "monthly", :amount_in_cents => 1, :subscription_amount => 1, :subscription_id => "98798789789"})

@rule.to_relation.all.should =~ [donation_one_off_1.user, donation_monthly_1.user]
@rule.to_relation.all.should match_array([donation_one_off_1.user, donation_monthly_1.user])
end

it "should filter donations smaller than the specified amount" do
Expand All @@ -23,7 +23,7 @@
donation_monthly_1 = FactoryGirl.create(:donation, {:frequency => "monthly", :amount_in_cents => 20, :subscription_amount => 20, :subscription_id => "24768374264"})
donation_monthly_2 = FactoryGirl.create(:donation, {:frequency => "monthly", :amount_in_cents => 100, :subscription_amount => 1, :subscription_id => "98798789789"})

@rule.to_relation.all.should =~ [donation_one_off_2.user, donation_monthly_2.user]
@rule.to_relation.all.should match_array([donation_one_off_2.user, donation_monthly_2.user])
end

describe "amount_in_dollars" do
Expand Down
Loading

0 comments on commit 1da1981

Please sign in to comment.