File: spec_helper.rb

package info (click to toggle)
ruby-gon 6.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 504 kB
  • sloc: ruby: 1,383; makefile: 9
file content (39 lines) | stat: -rw-r--r-- 857 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'rails/railtie'
# We don't require rails for specs, but jbuilder works only in rails.
# And it checks version of rails. I've decided to configure jbuilder for rails v4
module Rails
  module VERSION
    MAJOR = 4
  end

  def self.version
    '4.2.0'
  end
end

# remove lib/ from loadpath, added by rspec
$:.delete(File.expand_path("../../lib",__FILE__))

require 'gon'

require 'jbuilder'

RSpec.configure do |config|
  config.before(:each) do
    RequestStore.store[:gon] = Gon::Request.new({})
    @request = RequestStore.store[:gon]
    allow(Gon).to receive(:current_gon).and_return(@request)
  end
end

def request
  @request ||= double 'request', :env => {}
end

def wrap_script(content, cdata=true)
  script = "<script>"
  script << "\n//<![CDATA[\n" if cdata
  script << content
  script << "\n//]]>\n" if cdata
  script << '</script>'
end