diff --git a/Gemfile b/Gemfile index 8714b67..15b1c78 100644 --- a/Gemfile +++ b/Gemfile @@ -28,6 +28,7 @@ end group :test do gem "capybara" + gem "launchy" gem "rspec-rails" gem "shoulda-matchers" end diff --git a/Gemfile.lock b/Gemfile.lock index ff865ee..7879b00 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -98,6 +98,8 @@ GEM railties (>= 4.2.0) thor (>= 0.14, < 2.0) jwt (1.5.6) + launchy (2.4.3) + addressable (~> 2.3) loofah (2.2.2) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -238,6 +240,7 @@ DEPENDENCIES dragonfly http jquery-rails + launchy omniauth-github pg pry diff --git a/spec/features/user_uploads_image_spec.rb b/spec/features/user_uploads_image_spec.rb new file mode 100644 index 0000000..c30a75e --- /dev/null +++ b/spec/features/user_uploads_image_spec.rb @@ -0,0 +1,26 @@ +require "rails_helper" + +OmniAuth.config.test_mode = true + +OmniAuth.config.mock_auth[:twitter] = OmniAuth::AuthHash.new( + provider: "github", + uid: "1", +) + +describe "user uploads image" do + it "uploads the image" do + visit "/" + + sign_in + + save_and_open_page + + attach_file("Image", "#{Rails.root}/spec/fixtures/spectrum.jpg") + end + + def sign_in + within(".centre-stage") do + click_link("Sign in with GitHub") + end + end +end diff --git a/spec/fixtures/spectrum.jpg b/spec/fixtures/spectrum.jpg new file mode 100644 index 0000000..bff4317 Binary files /dev/null and b/spec/fixtures/spectrum.jpg differ diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index fc6e81e..bcbc1a5 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -9,6 +9,8 @@ end require "rspec/rails" # Add additional requires below this line. Rails is not loaded until this point! +require "capybara/rspec" + # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are # run as spec files by default. This means that files in spec/support that end @@ -32,6 +34,7 @@ rescue ActiveRecord::PendingMigrationError => e puts e.to_s.strip exit 1 end + RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures config.fixture_path = "#{::Rails.root}/spec/fixtures"