Skip to content

Commit

Permalink
update tests for rspec 3
Browse files Browse the repository at this point in the history
  • Loading branch information
mejackreed committed Apr 16, 2015
1 parent fcf98f6 commit 6b44c9f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 29 deletions.
6 changes: 3 additions & 3 deletions spec/controllers/catalog_controller_spec.rb
Expand Up @@ -9,12 +9,12 @@
before { get :map }

it "should respond to the #map action" do
response.should be_success
assigns(:document_list).should_not be_nil
expect(response).to be_success
expect(assigns(:document_list)).to_not be_nil
end

it "should render the '/map' page" do
response.body.should have_selector("body.blacklight-catalog-map")
expect(response.body).to have_css 'body.blacklight-catalog-map'
end

end
Expand Down
36 changes: 12 additions & 24 deletions spec/helpers/blacklight_maps_helper_spec.rb
Expand Up @@ -11,19 +11,19 @@ def create_response
end

let(:r) { create_response }
let(:geojson_hash) { { type: 'Feature', geometry: { type: 'Point', coordinates: [91.117212, 29.646923] }, properties: { placename: 'Tibet' } } }
let(:coords) { [91.117212, 29.646923] }
let(:bbox) { [78.3955448, 26.8548157, 99.116241, 36.4833345] }

before :each do
allow(helper).to receive_messages(blacklight_config: blacklight_config)
CatalogController.blacklight_config = Blacklight::Configuration.new
helper.stub(blacklight_config: blacklight_config)
@request = ActionDispatch::TestRequest.new
@catalog = CatalogController.new
@catalog.request = @request
@catalog.action_name = "index"
helper.instance_variable_set(:@_controller, @catalog)
@docs = r.facet_by_field_name(blacklight_config.view.maps.geojson_field).items
@geojson_hash = {type:"Feature", geometry:{type:"Point",coordinates:[91.117212, 29.646923]},properties:{placename:"Tibet"}}
@coords = [91.117212,29.646923]
@bbox = [78.3955448,26.8548157,99.116241,36.4833345]
end

describe "blacklight_map_tag" do
Expand Down Expand Up @@ -59,22 +59,16 @@ def create_response
describe "placename_value" do

it "should return the placename value" do
expect(helper.placename_value(@geojson_hash)).to eq('Tibet')
expect(helper.placename_value(geojson_hash)).to eq('Tibet')
end

end

describe "link_to_bbox_search" do

before do
@bbox = [78.3955448,26.8548157,99.116241,36.4833345]
end

it "should create a spatial search link" do
expect(helper.link_to_bbox_search(@bbox)).to include('catalog?coordinates')
expect(helper.link_to_bbox_search(@bbox)).to include('spatial_search_type=bbox')
expect(helper.link_to_bbox_search(bbox)).to include('catalog?coordinates')
expect(helper.link_to_bbox_search(bbox)).to include('spatial_search_type=bbox')
end

end

describe "link_to_placename_field" do
Expand All @@ -90,16 +84,10 @@ def create_response
end

describe "link_to_point_search" do

before do
@coords = [91.117212,29.646923]
end

it "should create a link to a coordinate point" do
expect(helper.link_to_point_search(@coords)).to include('catalog?coordinates')
expect(helper.link_to_point_search(@coords)).to include('spatial_search_type=point')
expect(helper.link_to_point_search(coords)).to include('catalog?coordinates')
expect(helper.link_to_point_search(coords)).to include('spatial_search_type=point')
end

end

describe "map_facet_field" do
Expand Down Expand Up @@ -127,7 +115,7 @@ def create_response
describe "render_placename_heading" do

it "should return the placename heading" do
expect(helper.render_placename_heading(@geojson_hash)).to eq('Tibet')
expect(helper.render_placename_heading(geojson_hash)).to eq('Tibet')
end

end
Expand All @@ -147,11 +135,11 @@ def create_response
describe "render_spatial_search_link" do

it "should return link_to_bbox_search if bbox coordinates are passed" do
expect(helper.render_spatial_search_link(@bbox)).to include('spatial_search_type=bbox')
expect(helper.render_spatial_search_link(bbox)).to include('spatial_search_type=bbox')
end

it "should return link_to_point_search if point coordinates are passed" do
expect(helper.render_spatial_search_link(@coords)).to include('spatial_search_type=point')
expect(helper.render_spatial_search_link(coords)).to include('spatial_search_type=point')
end

end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/blacklight/maps/export_spec.rb
Expand Up @@ -9,7 +9,7 @@
@request = ActionDispatch::TestRequest.new
@controller.request = @request
@response = ActionDispatch::TestResponse.new
@response.stub(:docs) {[{ "published_display"=>["Dharamsala, Distt. Kangra, H.P."], "pub_date"=>["2007"], "format"=>"Book", "title_display"=>"Ses yon", "material_type_display"=>["xii, 419 p."], "id"=>"2008308478", "placename_field"=>["China", "Tibet", "India"], "subject_topic_facet"=>["Education and state", "Tibetans", "Tibetan language", "Teaching"], "language_facet"=>["Tibetan"], "geojson"=>["{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[104.195397,35.86166]},\"properties\":{\"placename\":\"China\"}}", "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[91.117212,29.646923]},\"properties\":{\"placename\":\"Tibet\"}}", "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[78.96288,20.593684]},\"properties\":{\"placename\":\"India\"}}"], "coordinates"=>["68.162386 6.7535159 97.395555 35.5044752", "104.195397 35.86166", "91.117212 29.646923", "20.593684,78.96288"], "score"=>0.0026767207 }]}
expect(@response).to receive(:docs).and_return([{ "published_display"=>["Dharamsala, Distt. Kangra, H.P."], "pub_date"=>["2007"], "format"=>"Book", "title_display"=>"Ses yon", "material_type_display"=>["xii, 419 p."], "id"=>"2008308478", "placename_field"=>["China", "Tibet", "India"], "subject_topic_facet"=>["Education and state", "Tibetans", "Tibetan language", "Teaching"], "language_facet"=>["Tibetan"], "geojson"=>["{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[104.195397,35.86166]},\"properties\":{\"placename\":\"China\"}}", "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[91.117212,29.646923]},\"properties\":{\"placename\":\"Tibet\"}}", "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[78.96288,20.593684]},\"properties\":{\"placename\":\"India\"}}"], "coordinates"=>["68.162386 6.7535159 97.395555 35.5044752", "104.195397 35.86166", "91.117212 29.646923", "20.593684,78.96288"], "score"=>0.0026767207 }])
end

# TODO: use @response.facet_by_field_name('geojson').items instead of @response
Expand Down
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Expand Up @@ -29,7 +29,6 @@
require 'blacklight/maps'

require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'


Expand Down

0 comments on commit 6b44c9f

Please sign in to comment.