require 'spec_helper'
include Capybara::DSL

describe 'rspec matcher' do

  before(:all) do
    @black_box = 'black.png'
    @ref_path = Gatling::Configuration.reference_image_path = File.join(spec_support_root, 'ref_path')
    create_images_for_web_page
    create_square_image(@ref_path, 'black')
  end

  after(:each) do
    remove_refs(@ref_path)
  end

  it 'should initialize and run gatling' do
    visit('/fruit_app.html')

    black_element = page.find(:css, "#black")

    black_element.should look_like(@black_box)
  end

  it 'should initialize and run training mode when GATLING_TRAINER is toggled' do
    ENV['GATLING_TRAINER'] = 'true'
    visit('/fruit_app.html')
    black_element = page.find(:css, "#black")

    black_element.should look_like(@black_box)

    File.exists?(File.join(@ref_path,@black_box)).should be_true
  end

end

require 'spec_helper'
include Capybara::DSL

describe 'rspec matcher' do

  before(:all) do
    @black_box = 'black.png'
    @ref_path = Gatling::Configuration.reference_image_path = File.join(spec_support_root, 'ref_path')
    create_images_for_web_page
  end

  after(:each) do
    ENV['GATLING_TRAINER'] = 'false'
    remove_refs(@ref_path)
  end

  describe 'initializing and runnin gatling' do

    it 'will pass if images matches refernce' do
      create_square_image(@ref_path, 'black')
      black_element = element_for_spec("#black")
      black_element.should look_like(@black_box)
    end

    it 'will fail if images dosent matches refernce' do
      create_square_image(@ref_path, 'black')
      red_element = element_for_spec("#red")
      expect{red_element.should look_like(@black_box)}.should raise_error
    end

    it 'will return true if it makes a new image in trainer mode' do
      ENV['GATLING_TRAINER'] = 'true'
      black_element = element_for_spec("#black")
      black_element.should look_like(@black_box)
    end

  end
end

Add test to check rspec matcher can fail
Add test to check rspec matcher can fail
